Class ComponentIterator

  • All Implemented Interfaces:
    java.util.Iterator<Component>

    public class ComponentIterator
    extends java.lang.Object
    implements java.util.Iterator<Component>
    An implementation of Iterator<Component> that realizes the selector matching algorithm. The iteration is lazily evaluated. i.e. The iterator will not perform extra computation until .next() is called.
    Since:
    6.0.0
    Author:
    simonpai
    • Constructor Summary

      Constructors 
      Constructor Description
      ComponentIterator​(Component root, java.lang.String selector)
      Create an iterator which selects from all the descendants of a given component, including itself.
      ComponentIterator​(Page page, java.lang.String selector)
      Create an iterator which selects from all the components in the page.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearPseudoClassDefs()
      Clear all custom pseudo class definitions.
      boolean hasNext()
      Return true if it has next component.
      Component next()
      Return the next matched component.
      int nextIndex()
      Return the index of the next component.
      Component peek()
      Return the next matched component, but the iteration is not proceeded.
      void remove()
      Throws UnsupportedOperationException.
      PseudoClassDef removePseudoClassDef​(java.lang.String name)
      Remove a pseudo class definition.
      void setPseudoClassDef​(java.lang.String name, PseudoClassDef def)
      Add or set pseudo class definition.
      • 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
    • Constructor Detail

      • ComponentIterator

        public ComponentIterator​(Page page,
                                 java.lang.String selector)
        Create an iterator which selects from all the components in the page.
        Parameters:
        page - the reference page for selector
        selector - the selector string
      • ComponentIterator

        public ComponentIterator​(Component root,
                                 java.lang.String selector)
        Create an iterator which selects from all the descendants of a given component, including itself.
        Parameters:
        root - the reference component for selector
        selector - the selector string
    • Method Detail

      • setPseudoClassDef

        public void setPseudoClassDef​(java.lang.String name,
                                      PseudoClassDef def)
        Add or set pseudo class definition.
        Parameters:
        name - the pseudo class name
        def - the pseudo class definition
      • removePseudoClassDef

        public PseudoClassDef removePseudoClassDef​(java.lang.String name)
        Remove a pseudo class definition.
        Parameters:
        name - the pseudo class name
        Returns:
        the original definition
      • clearPseudoClassDefs

        public void clearPseudoClassDefs()
        Clear all custom pseudo class definitions.
      • hasNext

        public boolean hasNext()
        Return true if it has next component.
        Specified by:
        hasNext in interface java.util.Iterator<Component>
      • next

        public Component next()
        Return the next matched component. A NoSuchElementException will be throw if next component is not available.
        Specified by:
        next in interface java.util.Iterator<Component>
      • remove

        public void remove()
        Throws UnsupportedOperationException.
        Specified by:
        remove in interface java.util.Iterator<Component>
      • peek

        public Component peek()
        Return the next matched component, but the iteration is not proceeded.
      • nextIndex

        public int nextIndex()
        Return the index of the next component.