From: adam Date: Fri, 18 Mar 2005 09:11:45 +0000 (+0000) Subject: added Misc class X-Git-Url: http://git.megacz.com/?p=org.ibex.util.git;a=commitdiff_plain;h=d2f4bfe1ff1122d355edf6288fd6223a99889d0d added Misc class darcs-hash:20050318091145-5007d-65cfddbde4a3c5a2538c8a2cd94b6e251a7ab1dd.gz --- diff --git a/src/org/ibex/util/Misc.java b/src/org/ibex/util/Misc.java new file mode 100644 index 0000000..5c69c99 --- /dev/null +++ b/src/org/ibex/util/Misc.java @@ -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(); } + } + +} +