All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----collections.FilteringEnumeration
FilteringEnumerations work as wrappers around other Enumerations. To build one, you need an existing Enumeration (perhaps one from coll.elements(), for some Collection coll), and a Predicate object (i.e., implementing interface Predicate). For example, if you want to screen out everything but Panel objects from a collection coll that might hold things other than Panels, write something of the form:
Enumeration e = coll.elements(); Enumeration panels = FilteringEnumeration(e, IsPanel); while (panels.hasMoreElements()) doSomethingWith((Panel)(panels.nextElement()));To use this, you will also need to write a little class of the form:
class IsPanel implements Predicate {
boolean predicate(Object v) { return (v instanceof Panel); }
}
public FilteringEnumeration(Enumeration src,
Predicate p)
public FilteringEnumeration(Enumeration src,
Predicate p,
boolean sense)
public synchronized boolean hasMoreElements()
public synchronized Object nextElement()
All Packages Class Hierarchy This Package Previous Next Index