Class XMPIteratorImpl.NodeIterator

  • All Implemented Interfaces:
    java.util.Iterator
    Direct Known Subclasses:
    XMPIteratorImpl.NodeIteratorChildren
    Enclosing class:
    XMPIteratorImpl

    private class XMPIteratorImpl.NodeIterator
    extends java.lang.Object
    implements java.util.Iterator
    The XMPIterator implementation. It first returns the node itself, then recursivly the children and qualifier of the node.
    Since:
    29.06.2006
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Iterator childrenIterator
      the iterator that goes through the children and qualifier list
      private int index
      index of node with parent, only interesting for arrays
      protected static int ITERATE_CHILDREN
      iteration state
      protected static int ITERATE_NODE
      iteration state
      protected static int ITERATE_QUALIFIER
      iteration state
      private java.lang.String path
      the recursively accumulated path
      private XMPPropertyInfo returnProperty
      the cached PropertyInfo to return
      private int state
      the state of the iteration
      private java.util.Iterator subIterator
      the iterator for each child
      private XMPNode visitedNode
      the currently visited node
    • Constructor Summary

      Constructors 
      Constructor Description
      NodeIterator()
      Default constructor
      NodeIterator​(XMPNode visitedNode, java.lang.String parentPath, int index)
      Constructor for the node iterator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String accumulatePath​(XMPNode currNode, java.lang.String parentPath, int currentIndex)  
      protected XMPPropertyInfo createPropertyInfo​(XMPNode node, java.lang.String baseNS, java.lang.String path)
      Creates a property info object from an XMPNode.
      protected java.util.Iterator getChildrenIterator()  
      protected XMPPropertyInfo getReturnProperty()  
      boolean hasNext()
      Prepares the next node to return if not already done.
      private boolean iterateChildren​(java.util.Iterator iterator)
      Handles the iteration of the children or qualfier
      java.lang.Object next()
      Calls hasNext() and returnes the prepared node.
      void remove()
      Not supported.
      protected boolean reportNode()
      Sets the returnProperty as next item or recurses into hasNext().
      protected void setChildrenIterator​(java.util.Iterator childrenIterator)  
      protected void setReturnProperty​(XMPPropertyInfo returnProperty)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Field Detail

      • ITERATE_CHILDREN

        protected static final int ITERATE_CHILDREN
        iteration state
        See Also:
        Constant Field Values
      • ITERATE_QUALIFIER

        protected static final int ITERATE_QUALIFIER
        iteration state
        See Also:
        Constant Field Values
      • state

        private int state
        the state of the iteration
      • visitedNode

        private XMPNode visitedNode
        the currently visited node
      • path

        private java.lang.String path
        the recursively accumulated path
      • childrenIterator

        private java.util.Iterator childrenIterator
        the iterator that goes through the children and qualifier list
      • index

        private int index
        index of node with parent, only interesting for arrays
      • subIterator

        private java.util.Iterator subIterator
        the iterator for each child
      • returnProperty

        private XMPPropertyInfo returnProperty
        the cached PropertyInfo to return
    • Constructor Detail

      • NodeIterator

        public NodeIterator()
        Default constructor
      • NodeIterator

        public NodeIterator​(XMPNode visitedNode,
                            java.lang.String parentPath,
                            int index)
        Constructor for the node iterator.
        Parameters:
        visitedNode - the currently visited node
        parentPath - the accumulated path of the node
        index - the index within the parent node (only for arrays)
    • Method Detail

      • hasNext

        public boolean hasNext()
        Prepares the next node to return if not already done.
        Specified by:
        hasNext in interface java.util.Iterator
        See Also:
        Iterator.hasNext()
      • reportNode

        protected boolean reportNode()
        Sets the returnProperty as next item or recurses into hasNext().
        Returns:
        Returns if there is a next item to return.
      • iterateChildren

        private boolean iterateChildren​(java.util.Iterator iterator)
        Handles the iteration of the children or qualfier
        Parameters:
        iterator - an iterator
        Returns:
        Returns if there are more elements available.
      • next

        public java.lang.Object next()
        Calls hasNext() and returnes the prepared node. Afterwards its set to null. The existance of returnProperty indicates if there is a next node, otherwise an exceptio is thrown.
        Specified by:
        next in interface java.util.Iterator
        See Also:
        Iterator.next()
      • remove

        public void remove()
        Not supported.
        Specified by:
        remove in interface java.util.Iterator
        See Also:
        Iterator.remove()
      • accumulatePath

        protected java.lang.String accumulatePath​(XMPNode currNode,
                                                  java.lang.String parentPath,
                                                  int currentIndex)
        Parameters:
        currNode - the node that will be added to the path.
        parentPath - the path up to this node.
        currentIndex - the current array index if an arrey is traversed
        Returns:
        Returns the updated path.
      • createPropertyInfo

        protected XMPPropertyInfo createPropertyInfo​(XMPNode node,
                                                     java.lang.String baseNS,
                                                     java.lang.String path)
        Creates a property info object from an XMPNode.
        Parameters:
        node - an XMPNode
        baseNS - the base namespace to report
        path - the full property path
        Returns:
        Returns a XMPProperty-object that serves representation of the node.
      • getChildrenIterator

        protected java.util.Iterator getChildrenIterator()
        Returns:
        the childrenIterator
      • setChildrenIterator

        protected void setChildrenIterator​(java.util.Iterator childrenIterator)
        Parameters:
        childrenIterator - the childrenIterator to set
      • getReturnProperty

        protected XMPPropertyInfo getReturnProperty()
        Returns:
        Returns the returnProperty.
      • setReturnProperty

        protected void setReturnProperty​(XMPPropertyInfo returnProperty)
        Parameters:
        returnProperty - the returnProperty to set