01: package uk.org.ponder.util;
02:
03: import java.util.Enumeration;
04:
05: /** Converts a single object into an enumeration that dispenses just that object.
06: */
07:
08: public class SingleEnumeration implements Enumeration {
09: private Object element;
10:
11: public boolean hasMoreElements() {
12: return element != null;
13: }
14:
15: public Object nextElement() {
16: Object togo = element;
17: element = null;
18: return togo;
19: }
20:
21: /** Constructs an Enumeration that will enumerate over just the object supplied.
22: * @param element The object to be enumerated over.
23: */
24: public SingleEnumeration(Object element) {
25: this.element = element;
26: }
27: }
|