1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
10 public final class Misc {
12 public static class ArrayEnumeration implements Enumeration {
13 private final Object[] o;
15 public ArrayEnumeration(Object[] o) { this.o = o; }
16 public boolean hasMoreElements() { return o != null && i < o.length; }
17 public Object nextElement() { return hasMoreElements() ? o[i++] : null; }
20 public static class JoinEnumeration implements Enumeration {
21 private final Enumeration e1;
22 private final Enumeration e2;
23 public JoinEnumeration(Enumeration e1, Enumeration e2) { this.e1 = e1; this.e2 = e2; }
24 public boolean hasMoreElements() { return e1.hasMoreElements() || e2.hasMoreElements(); }
25 public Object nextElement() { return e1.hasMoreElements() ? e1.nextElement() : e2.nextElement(); }