All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----collections.MappingEnumeration
MappingEnumerations 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 Function object (i.e., implementing interface Function). For example, if you want to process only the parent() fields of java.awt.Component elements held by a collection coll you could write something of the form:
Enumeration e = coll.elements(); Enumeration parents = MappingEnumeration(e, ParentFunction); while (parents.hasMoreElements()) doSomethingWith((Container)(parents.nextElement()));To use this, you will also need to write a little class of the form:
class ParentFunction implements Function { Object function(Object v) { if (v instanceOf Component) return ((Component)v).getParent(); else return null; } }
(This requires too much set-up to be reasonable in most situations, but is invaluable in others.)
public MappingEnumeration(Enumeration src, Function p)
public synchronized boolean hasMoreElements()
public synchronized Object nextElement()
All Packages Class Hierarchy This Package Previous Next Index