Class BaseNode

    • Field Detail

      • parent

        protected Node parent
        the parent node
      • children

        protected List<Node> children
        the child nodes
    • Constructor Detail

      • BaseNode

        public BaseNode()
    • Method Detail

      • get

        public freemarker.template.TemplateModel get​(String key)
                                              throws freemarker.template.TemplateModelException
        Specified by:
        get in interface freemarker.template.TemplateHashModel
        Throws:
        freemarker.template.TemplateModelException
      • getSimpleName

        public String getSimpleName()
      • getInnerText

        protected String getInnerText()
      • prepend

        public void prepend​(Node n)
      • getAsString

        public String getAsString()
        Specified by:
        getAsString in interface freemarker.template.TemplateScalarModel
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface freemarker.template.TemplateHashModel
      • hasKeyWord

        public boolean hasKeyWord​(String keyWord)
      • getLiteralText

        protected String getLiteralText()
      • getTokenSource

        public JavaCCLexer getTokenSource()
        Specified by:
        getTokenSource in interface Node
        Returns:
        the #JavaCCLexer from which this Node object originated. There is no guarantee that this doesn't return null. Most likely that would simply be because you constructed the Node yourself, i.e. it didn't really come about via the parsing/tokenizing machinery.
      • setListClass

        public static void setListClass​(Class<? extends List> listClass)
        Sets the List class that is used to store child nodes. By default, this is java.util.ArrayList. There is probably very little reason to ever use anything else, though you could use this method to replace this with LinkedList or your own java.util.List implementation even.
        Parameters:
        listClass - the #java.util.List implementation to use internally for the child nodes. By default #java.util.ArrayList is used.
      • isUnparsed

        public boolean isUnparsed()
        Specified by:
        isUnparsed in interface Node
        Returns:
        whether this Node was created by regular operations of the parsing machinery.
      • setUnparsed

        public void setUnparsed​(boolean unparsed)
        Description copied from interface: Node
        Mark whether this Node is unparsed, i.e. not the result of normal parsing
        Specified by:
        setUnparsed in interface Node
        Parameters:
        unparsed - whether to set the Node as unparsed or parsed.
      • setParent

        public void setParent​(Node n)
        Specified by:
        setParent in interface Node
        Parameters:
        n - The Node to set as the parent. Mostly used internally. The various addChild or appendChild sorts of methods should use this to set the node's parent.
      • getParent

        public Node getParent()
        Specified by:
        getParent in interface Node
        Returns:
        this node's parent Node
      • addChild

        public void addChild​(Node n)
        Description copied from interface: Node
        appends a child node to this Node
        Specified by:
        addChild in interface Node
        Parameters:
        n - the Node to append
      • addChild

        public void addChild​(int i,
                             Node n)
        Description copied from interface: Node
        inserts a child Node at a specific index, displacing the nodes after the index by 1.
        Specified by:
        addChild in interface Node
        Parameters:
        i - the (zero-based) index at which to insert the node
        n - the Node to insert
      • getChild

        public Node getChild​(int i)
        Specified by:
        getChild in interface Node
        Parameters:
        i - the index of the Node to return
        Returns:
        the Node at the specific offset
      • setChild

        public void setChild​(int i,
                             Node n)
        Description copied from interface: Node
        Replace the node at index i
        Specified by:
        setChild in interface Node
        Parameters:
        i - the index
        n - the node
      • removeChild

        public Node removeChild​(int i)
        Description copied from interface: Node
        Remove the node at index i. Any Nodes after i are shifted to the left.
        Specified by:
        removeChild in interface Node
        Parameters:
        i - the index at which to remove
        Returns:
        the removed Node
      • clearChildren

        public void clearChildren()
        Description copied from interface: Node
        Remove all the child nodes
        Specified by:
        clearChildren in interface Node
      • getChildCount

        public int getChildCount()
        Specified by:
        getChildCount in interface Node
        Returns:
        the number of child nodes
      • getBeginOffset

        public int getBeginOffset()
        Specified by:
        getBeginOffset in interface Node
        Returns:
        the offset in the input source where the token begins, expressed in code units.
      • setBeginOffset

        public void setBeginOffset​(int beginOffset)
        Description copied from interface: Node
        Set the offset where the token begins, expressed in code units.
        Specified by:
        setBeginOffset in interface Node
      • getEndOffset

        public int getEndOffset()
        Specified by:
        getEndOffset in interface Node
        Returns:
        the offset in the input source where the token ends, expressed in code units. This is actually the offset where the very next token would begin.
      • setEndOffset

        public void setEndOffset​(int endOffset)
        Description copied from interface: Node
        Set the offset where the token ends, actually the location where the very next token should begin.
        Specified by:
        setEndOffset in interface Node
      • getChildNodes

        public freemarker.template.TemplateSequenceModel getChildNodes()
        Specified by:
        getChildNodes in interface freemarker.template.TemplateNodeModel
      • getParentNode

        public freemarker.template.TemplateNodeModel getParentNode()
        Specified by:
        getParentNode in interface freemarker.template.TemplateNodeModel
      • getNodeName

        public String getNodeName()
        Specified by:
        getNodeName in interface freemarker.template.TemplateNodeModel
      • getNodeType

        public String getNodeType()
        Specified by:
        getNodeType in interface freemarker.template.TemplateNodeModel
      • getNodeNamespace

        public String getNodeNamespace()
        Specified by:
        getNodeNamespace in interface freemarker.template.TemplateNodeModel