Package cambridge.model

Examples of cambridge.model.ExtensionNode


                                 }

                                 break;
                              case EXTENSION:
                                 ExtensionToken extensionToken = (ExtensionToken) attrToken;
                                 ExtensionNode extensionNode = extensionToken.createNode(expressionLanguage);
                                 fragments.add(extensionNode);
                                 break;
                              case WS:
                              case STRING:
                                 StaticFragment st = new StaticFragment(attrToken.value);
                                 fragments.add(st);
                                 break;
                           }
                        }

                        if (fragments.size() == 0 || fragments.size() == 1 && fragments.get(0) instanceof StaticFragment) {
                           element = new SimpleAttribute(currentToken.getLineNo(), currentToken.getColumn());
                           ((SimpleAttribute) element).setValue(currentToken.value);
                        } else {
                           element = new ComplexAttribute(currentToken.getLineNo(), currentToken.getColumn());
                           ((ComplexAttribute) element).setFragments(fragments);
                           AttributeValueToken aTok = (AttributeValueToken) currentToken;
                           if (aTok.getQuotes() == -2) {
                              ((ComplexAttribute) element).setQuote('"');
                           } else if (aTok.getQuotes() == -3) {
                              ((ComplexAttribute) element).setQuote('\'');
                           }
                        }

                        exitLoop = true;
                        break;
                  }

                  if (exitLoop) break;
               }

               if (element == null) {
                  throw new TemplateParsingException("Error parsing template file. Unterminated tag?", currentToken.getLineNo(), currentToken.getColumn());
               }

               element.setAttributeName(tok.getAttributeName());
               element.setAttributeNameSpace(tok.getNameSpace());
               element.setTextContent(textContent.toString());


               int s = node.getTagParts().size();
               if (s > 0) {
                  TagPart te = node.getTagParts().get(s - 1);
                  if (te instanceof TextTagPart) {
                     if (te.isWhiteSpace()) {
                        node.getTagParts().remove(s - 1);
                     }
                  }
               }

               if (firstTag && "xmlns".equalsIgnoreCase(element.getAttributeNameSpace())) {
                  putNamespaceMapping(element.getAttributeName(), element.getValue());
               }

               node.addAttribute(element);
               break;
            case EXPRESSION:
               try {

                  ExpressionToken t = (ExpressionToken) currentToken;
                  ExpressionTagPart p = new ExpressionTagPart(currentToken.value,
                          expressionLanguage.parse(currentToken.value, currentToken.getLineNo(), currentToken.getColumn()),
                          t.isRawExpression(), currentToken.getLineNo(), currentToken.getColumn());

                  if (t.getFilters() != null) {
                     p.setFilters(t.getFilters());
                  }

                  node.addExpression(p);

               } catch (ExpressionParsingException e1) {
                  throw new TemplateParsingException("Error parsing expression", e1, currentToken.getLineNo(), currentToken.getColumn());
               }
               break;
            case EXTENSION:
               ExtensionToken extensionToken = (ExtensionToken) currentToken;
               ExtensionNode extensionTagPart = extensionToken.createNode(expressionLanguage);
               node.addTagPart(extensionTagPart);
               break;
            case TAG_END:
               node.setTagEndText(currentToken.getActualValue());
               break;
View Full Code Here


                                            }

                                            break;
                                        case EXTENSION:
                                            ExtensionToken extensionToken = (ExtensionToken) attrToken;
                                            ExtensionNode extensionNode = extensionToken.createNode(expressionLanguage);
                                            fragments.add(extensionNode);
                                            break;
                                        case WS:
                                        case STRING:
                                            StaticFragment st = new StaticFragment(attrToken.value);
                                            fragments.add(st);
                                            break;
                                    }
                                }

                                if (fragments.size() == 0 || fragments.size() == 1 && fragments.get(0) instanceof StaticFragment) {
                                    element = new SimpleAttribute(currentToken.getLineNo(), currentToken.getColumn());
                                    ((SimpleAttribute) element).setValue(currentToken.value);
                                } else {
                                    element = new ComplexAttribute(currentToken.getLineNo(), currentToken.getColumn());
                                    ((ComplexAttribute) element).setFragments(fragments);
                                    AttributeValueToken aTok = (AttributeValueToken) currentToken;
                                    if (aTok.getQuotes() == -2) {
                                        ((ComplexAttribute) element).setQuote('"');
                                    } else if (aTok.getQuotes() == -3) {
                                        ((ComplexAttribute) element).setQuote('\'');
                                    }
                                }

                                exitLoop = true;
                                break;
                        }

                        if (exitLoop) break;
                    }

                    if (element == null) {
                        if (tok != null) {
                            element = new SimpleAttribute(tok.getAttributeName(), tok.getNameSpace(), tok.getLineNo(), tok.getLineNo());
                        } else {
                            throw new TemplateParsingException("Error parsing template file. Unterminated tag?", currentToken.getLineNo(), currentToken.getColumn());
                        }
                    }

                    element.setAttributeName(tok.getAttributeName());
                    element.setAttributeNameSpace(tok.getNameSpace());
                    element.setTextContent(textContent.toString());

                    int s = node.getTagParts().size();
                    if (s > 0) {
                        TagPart te = node.getTagParts().get(s - 1);
                        if (te instanceof TextTagPart) {
                            if (te.isWhiteSpace()) {
                                node.getTagParts().remove(s - 1);
                            }
                        }
                    }

                    if (firstTag && "xmlns".equalsIgnoreCase(element.getAttributeNameSpace())) {
                        putNamespaceMapping(element.getAttributeName(), element.getValue());
                    }

                    node.addAttribute(element);
                    break;
                case EXPRESSION:
                    try {

                        ExpressionToken t = (ExpressionToken) currentToken;
                        ExpressionTagPart p = new ExpressionTagPart(currentToken.value,
                            expressionLanguage.parse(currentToken.value, currentToken.getLineNo(), currentToken.getColumn()),
                            t.isRawExpression(), currentToken.getLineNo(), currentToken.getColumn());

                        if (t.getFilters() != null) {
                            p.setFilters(t.getFilters());
                        }

                        node.addExpression(p);

                    } catch (ExpressionParsingException e1) {
                        throw new TemplateParsingException("Error parsing expression", e1, currentToken.getLineNo(), currentToken.getColumn());
                    }
                    break;
                case EXTENSION:
                    ExtensionToken extensionToken = (ExtensionToken) currentToken;
                    ExtensionNode extensionTagPart = extensionToken.createNode(expressionLanguage);
                    node.addTagPart(extensionTagPart);
                    break;
                case TAG_END:
                    node.setTagEndText(currentToken.getActualValue());
                    break;
View Full Code Here

TOP

Related Classes of cambridge.model.ExtensionNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.