added Misc class
authoradam <adam@megacz.com>
Fri, 18 Mar 2005 09:11:45 +0000 (09:11 +0000)
committeradam <adam@megacz.com>
Fri, 18 Mar 2005 09:11:45 +0000 (09:11 +0000)
darcs-hash:20050318091145-5007d-65cfddbde4a3c5a2538c8a2cd94b6e251a7ab1dd.gz

src/org/ibex/util/Misc.java [new file with mode: 0644]

diff --git a/src/org/ibex/util/Misc.java b/src/org/ibex/util/Misc.java
new file mode 100644 (file)
index 0000000..5c69c99
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Licensed under the Apache Public Source License 2.0 ("the License").
+// You may not use this file except in compliance with the License.
+
+package org.ibex.util;
+
+import java.io.*;
+import java.util.*;
+
+public final class Misc {
+
+    public static class ArrayEnumeration implements Enumeration {
+        private final Object[] o;
+        private int i = 0;
+        public ArrayEnumeration(Object[] o) { this.o = o; }
+        public boolean hasMoreElements() { return o != null && i < o.length; }
+        public Object nextElement() { return hasMoreElements() ? o[i++] : null; }
+    }
+
+    public static class JoinEnumeration implements Enumeration {
+        private final Enumeration e1;
+        private final Enumeration e2;
+        public JoinEnumeration(Enumeration e1, Enumeration e2) { this.e1 = e1; this.e2 = e2; }
+        public boolean hasMoreElements() { return e1.hasMoreElements() || e2.hasMoreElements(); }
+        public Object nextElement() { return e1.hasMoreElements() ? e1.nextElement() : e2.nextElement(); }
+    }
+
+}
+