Class XmlLiteral

  • All Implemented Interfaces:
    Comparable<AstNode>, Iterable<Node>

    public class XmlLiteral
    extends AstNode
    AST node for an E4X (Ecma-357) embedded XML literal. Node type is Token.XML. The parser generates a simple list of strings and expressions. In the future we may parse the XML and produce a richer set of nodes, but for now it's just a set of expressions evaluated to produce a string to pass to the XML constructor function.

    • Constructor Detail

      • XmlLiteral

        public XmlLiteral()
      • XmlLiteral

        public XmlLiteral​(int pos)
      • XmlLiteral

        public XmlLiteral​(int pos,
                          int len)
    • Method Detail

      • getFragments

        public List<XmlFragment> getFragments()
        Returns fragment list - a list of expression nodes.
      • setFragments

        public void setFragments​(List<XmlFragment> fragments)
        Sets fragment list, removing any existing fragments first. Sets the parent pointer for each fragment in the list to this node.
        fragments - fragment list. Replaces any existing fragments.
        IllegalArgumentException - } if fragments is null
      • addFragment

        public void addFragment​(XmlFragment fragment)
        Adds a fragment to the fragment list. Sets its parent to this node.
        IllegalArgumentException - } if fragment is null
      • toSource

        public String toSource​(int depth)
        Description copied from class: AstNode
        Emits source code for this node. Callee is responsible for calling this function recursively on children, incrementing indent as appropriate.

        Note: if the parser was in error-recovery mode, some AST nodes may have null children that are expected to be non-null when no errors are present. In this situation, the behavior of the toSource method is undefined: toSource implementations may assume that the AST node is error-free, since it is intended to be invoked only at runtime after a successful parse.

        Specified by:
        toSource in class AstNode
        depth - the current recursion depth, typically beginning at 0 when called on the root node.
      • visit

        public void visit​(NodeVisitor v)
        Visits this node, then visits each child fragment in lexical order.
        Specified by:
        visit in class AstNode
        v - the object to call with this node and its children