Class OutputStack

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<OutputNode>, java.util.Collection<OutputNode>, java.util.List<OutputNode>, java.util.RandomAccess

    class OutputStack
    extends java.util.ArrayList<OutputNode>
    The OutputStack is used to keep track of the nodes that have been written to the document. This ensures that when nodes are written to the XML document that the writer can tell whether a child node for a given OutputNode can be created. Each created node is pushed, and popped when ended.
    See Also:
    OutputNode
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  OutputStack.Sequence
      The is used to order the OutputNode objects from the top down.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Set active
      Represents the set of nodes that have not been committed.
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      OutputStack​(java.util.Set active)
      Constructor for the OutputStack object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      OutputNode bottom()
      This is used to acquire the OutputNode from the bottom of the output stack.
      java.util.Iterator<OutputNode> iterator()
      This is returns an Iterator that is used to loop through the ouptut nodes from the top down.
      OutputNode pop()
      This is used to remove the OutputNode from the top of the output stack.
      OutputNode purge​(int index)
      The purge method is used to purge a match from the provided position.
      OutputNode push​(OutputNode value)
      This method is used to add an OutputNode to the top of the stack.
      OutputNode top()
      This is used to acquire the OutputNode from the top of the output stack.
      • Methods inherited from class java.util.ArrayList

        add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
      • Methods inherited from class java.util.AbstractCollection

        containsAll, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
      • Methods inherited from interface java.util.List

        containsAll
    • Field Detail

      • active

        private final java.util.Set active
        Represents the set of nodes that have not been committed.
    • Constructor Detail

      • OutputStack

        public OutputStack​(java.util.Set active)
        Constructor for the OutputStack object. This is used to create a stack that can be used to keep track of the elements that have been written to the XML document.
    • Method Detail

      • pop

        public OutputNode pop()
        This is used to remove the OutputNode from the top of the output stack. This is used when an element has been ended and the output writer wants to block child creation.
        Returns:
        this returns the node from the top of the stack
      • top

        public OutputNode top()
        This is used to acquire the OutputNode from the top of the output stack. This is used when the writer wants to determine the current element written to the XML document.
        Returns:
        this returns the node from the top of the stack
      • bottom

        public OutputNode bottom()
        This is used to acquire the OutputNode from the bottom of the output stack. This is used when the writer wants to determine the root element for the written XML document.
        Returns:
        this returns the node from the bottom of the stack
      • push

        public OutputNode push​(OutputNode value)
        This method is used to add an OutputNode to the top of the stack. This is used when an element is written to the XML document, and allows the writer to determine if a child node can be created from a given output node.
        Parameters:
        value - this is the output node to add to the stack
      • purge

        public OutputNode purge​(int index)
        The purge method is used to purge a match from the provided position. This also ensures that the active set has the node removed so that it is no longer relevant.
        Parameters:
        index - the index of the node that is to be removed
        Returns:
        returns the node removed from the specified index
      • iterator

        public java.util.Iterator<OutputNode> iterator()
        This is returns an Iterator that is used to loop through the ouptut nodes from the top down. This allows the node writer to determine what Mode should be used by an output node. This reverses the iteration of the list.
        Specified by:
        iterator in interface java.util.Collection<OutputNode>
        Specified by:
        iterator in interface java.lang.Iterable<OutputNode>
        Specified by:
        iterator in interface java.util.List<OutputNode>
        Overrides:
        iterator in class java.util.ArrayList<OutputNode>
        Returns:
        returns an iterator to iterate from the top down