Class ComponentIterator

  • All Implemented Interfaces:
    Iterator<org.zkoss.zk.ui.Component>

    public class ComponentIterator
    extends Object
    implements Iterator<org.zkoss.zk.ui.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 Detail

      • ComponentIterator

        public ComponentIterator​(org.zkoss.zk.ui.Page page,
                                 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​(org.zkoss.zk.ui.Component root,
                                 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​(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​(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 Iterator<org.zkoss.zk.ui.Component>
      • next

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

        public void remove()
        Throws UnsupportedOperationException.
        Specified by:
        remove in interface Iterator<org.zkoss.zk.ui.Component>
      • peek

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

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