Class FilterEnumerator

  • All Implemented Interfaces:
    Enumeration, Iterator

    public class FilterEnumerator
    extends Base
    implements Enumeration, Iterator
    Provide a generic implementation of an enumerator which can enumerate items based on an inclusion test.
    Author:
    cp 1997.09.05, cp 1998.08.07
    • Field Detail

      • m_iter

        protected Iterator m_iter
        Objects to filter/enumerate.
      • m_test

        protected Filter m_test
        Test to perform on each item.
      • m_fNext

        protected boolean m_fNext
        Is there a next item which passed the test?
      • m_fPrev

        protected boolean m_fPrev
        Is there a previous item which passed the test and can be removed?
      • m_oNext

        protected Object m_oNext
        The next item which passed the test.
    • Constructor Detail

      • FilterEnumerator

        public FilterEnumerator​(Enumeration enmr,
                                Filter test)
        Construct the Filter enumerator based on an Enumeration.
        Parameters:
        enmr - Enumeration of objects to filter
        test - an inclusion test
      • FilterEnumerator

        public FilterEnumerator​(Iterator iter,
                                Filter test)
        Construct the Filter enumerator based on an Iterator.
        Parameters:
        iter - Iterator of objects to filter
        test - an inclusion test
      • FilterEnumerator

        public FilterEnumerator​(Object[] aoItem,
                                Filter test)
        Construct the Filter enumerator based on an array of objects.
        Parameters:
        aoItem - array of objects to enumerate
        test - an inclusion test
    • Method Detail

      • hasMoreElements

        public boolean hasMoreElements()
        Tests if this enumeration contains more elements.
        Specified by:
        hasMoreElements in interface Enumeration
        Returns:
        false if the enumeration has been exhausted
      • nextElement

        public Object nextElement()
        Get the next element in the enumeration.
        Specified by:
        nextElement in interface Enumeration
        Returns:
        the next element of this enumeration
      • hasNext

        public boolean hasNext()
        Tests if this Iterator contains more elements.
        Specified by:
        hasNext in interface Iterator
        Returns:
        true if the Iterator contains more elements, false otherwise
      • next

        public Object next()
        Returns the next element of this Iterator.
        Specified by:
        next in interface Iterator
        Returns:
        the next element in the Iterator
      • remove

        public void remove()
        Remove the last-returned element that was returned by the Iterator.
        Specified by:
        remove in interface Iterator