Package cambridge.model

Examples of cambridge.model.TemplateNode


      return template;
   }

   private void getNode() throws IOException, TemplateParsingException {
      TemplateNode node;
      switch (currentToken.getType()) {
         case COMMENT:
            node = new CommentNode();
            CommentNode comment = (CommentNode) node;
            comment.setContents(currentToken.getValue());
            node.setBeginLine(currentToken.getLineNo());
            node.setBeginColumn(currentToken.getColumn());
            node.setEndLine(peek(1).getLineNo());
            node.setEndColumn(peek(1).getColumn());
            matchedNodes.add(node);
            break;
         case CDATA:
         case DOC_TYPE:
         case EOL:
         case STRING:
         case WS:
            node = textNode();
            matchedNodes.add(node);
            break;
         case EXPRESSION:
            node = expression();
            matchedNodes.add(node);
            break;
         case EXTENSION:
            ExtensionToken tok = (ExtensionToken) currentToken;
            node = tok.createNode(expressionLanguage);
            matchedNodes.add(node);
            break;
         case OPEN_TAG:
            node = tag();
            matchedNodes.add(node);
            break;
         case PARSER_DIRECTIVE:
            node = parserDirective();
            if (node != null) {
               matchedNodes.add(node);
            }
            break;
         case CLOSE_TAG:
            CloseTagToken token = (CloseTagToken) currentToken;
            TagNode tag = null;
            int openIndex = -1;
            for (int i = matchedNodes.size() - 1; i != -1; i--) {
               TemplateNode n = matchedNodes.get(i);
               if (n instanceof TagNode) {
                  TagNode tn = (TagNode) n;
                  if (tn.getEndLine() == 0 && tn.getEndColumn() == 0 && tn.tagNameString.equals(token.getTagName())) {
                     tag = tn;
                     openIndex = i;
                     break;
                  }
               }
            }

            if (openIndex != -1 && tag != null) {
               ArrayList<TemplateNode> sub = new ArrayList<TemplateNode>();
               for (int i = openIndex + 1; i < matchedNodes.size(); i++) {
                  TemplateNode n = matchedNodes.get(i);
                  n.setParent(tag);
                  sub.add(n);
               }

               tag.addChildren(sub);
View Full Code Here


        return template;
    }

    private void getNode() throws IOException, TemplateParsingException {
        TemplateNode node;
        switch (currentToken.getType()) {
            case COMMENT:
                node = new CommentNode();
                CommentNode comment = (CommentNode) node;
                comment.setContents(currentToken.getValue());
                node.setBeginLine(currentToken.getLineNo());
                node.setBeginColumn(currentToken.getColumn());
                node.setEndLine(peek(1).getLineNo());
                node.setEndColumn(peek(1).getColumn());
                matchedNodes.add(node);
                break;
            case CDATA:
            case DOC_TYPE:
            case EOL:
            case STRING:
            case WS:
                node = textNode();
                matchedNodes.add(node);
                break;
            case EXPRESSION:
                node = expression();
                matchedNodes.add(node);
                break;
            case EXTENSION:
                ExtensionToken tok = (ExtensionToken) currentToken;
                node = tok.createNode(expressionLanguage);
                matchedNodes.add(node);
                break;
            case OPEN_TAG:
                node = tag();
                matchedNodes.add(node);
                break;
            case PARSER_DIRECTIVE:
                node = parserDirective();
                if (node != null) {
                    matchedNodes.add(node);
                }
                break;
            case CLOSE_TAG:
                CloseTagToken token = (CloseTagToken) currentToken;
                TagNode tag = null;
                int openIndex = -1;
                for (int i = matchedNodes.size() - 1; i != -1; i--) {
                    TemplateNode n = matchedNodes.get(i);
                    if (n instanceof TagNode) {
                        TagNode tn = (TagNode) n;
                        if (tn.getEndLine() == 0 && tn.getEndColumn() == 0 && tn.tagNameString.equals(token.getTagName())) {
                            tag = tn;
                            openIndex = i;
                            break;
                        }
                    }
                }

                if (openIndex != -1 && tag != null) {
                    ArrayList<TemplateNode> sub = new ArrayList<TemplateNode>();
                    for (int i = openIndex + 1; i < matchedNodes.size(); i++) {
                        TemplateNode n = matchedNodes.get(i);
                        n.setParent(tag);
                        sub.add(n);
                    }

                    tag.addChildren(sub);
View Full Code Here

TOP

Related Classes of cambridge.model.TemplateNode

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.