Class NodeWithChildren

  • All Implemented Interfaces:
    Node, Parent
    Direct Known Subclasses:
    Document, Element

    public abstract class NodeWithChildren
    extends java.lang.Object
    implements Parent
    This class contains all the code necessary to implement nodes which can have child nodes (like Document or Element).
    • Field Detail

      • nodes

        private java.util.List<Node> nodes
    • Constructor Detail

      • NodeWithChildren

        public NodeWithChildren()
    • Method Detail

      • getNodes

        public java.util.List<Node> getNodes()
        Description copied from interface: Parent
        Get the list of child nodes.

        CAUTION: Changes to this list will modify the actual data structure! So don't do this unless you know what you're doing!

        Specified by:
        getNodes in interface Parent
      • hasNodes

        public boolean hasNodes()
        Description copied from interface: Parent
        Does this node have children?
        Specified by:
        hasNodes in interface Parent
      • nodeCount

        public int nodeCount()
        Description copied from interface: Parent
        The number of nodes in the list
        Specified by:
        nodeCount in interface Parent
      • nodeIndexOf

        public int nodeIndexOf​(Node node)
        Description copied from interface: Parent
        The index of the node in the node list or -1 if it isn't in the list
        Specified by:
        nodeIndexOf in interface Parent
      • getNode

        public Node getNode​(int index)
        Description copied from interface: Parent
        Get a specific node from the list
        Specified by:
        getNode in interface Parent
      • removeNode

        public Node removeNode​(int index)
        Description copied from interface: Parent
        Remove a node from the list
        Specified by:
        removeNode in interface Parent
        Returns:
        The removed node.
      • removeNode

        public boolean removeNode​(Node n)
        Description copied from interface: Parent
        Remove a node from the list
        Specified by:
        removeNode in interface Parent
        Returns:
        true, if the node is in the list
      • getNodes

        public <T> java.util.List<T> getNodes​(NodeFilter<T> filter)
      • toXML

        public java.lang.String toXML()
        Description copied from interface: Node
        Slow way to convert a node to XML
        Specified by:
        toXML in interface Node
      • toXML

        public NodeWithChildren toXML​(XMLWriter writer)
                               throws java.io.IOException
        Description copied from interface: Node
        Fast way to convert many nodes to XML
        Specified by:
        toXML in interface Node
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • copy

        public NodeWithChildren copy​(Node orig)
        Description copied from interface: Node
        Copy all data from orig into this
        Specified by:
        copy in interface Node