1 22 package org.objectweb.petals.util; 23 24 import java.util.Enumeration ; 25 import java.util.NoSuchElementException ; 26 27 31 public class CollectionsUtil { 32 33 private static final class CompoundEnumeration implements Enumeration { 34 35 private final Enumeration e1, e2; 36 37 public CompoundEnumeration(Enumeration e1, Enumeration e2) { 38 this.e1 = e1; 39 this.e2 = e2; 40 } 41 42 public boolean hasMoreElements() { 43 return e1.hasMoreElements() || e2.hasMoreElements(); 44 } 45 46 public Object nextElement() throws NoSuchElementException { 47 if (e1.hasMoreElements()) { 48 return e1.nextElement(); 49 } else { 50 return e2.nextElement(); 51 } 52 } 53 54 } 55 56 public static Enumeration append(Enumeration e1, Enumeration e2) { 57 return new CompoundEnumeration(e1, e2); 58 } 59 60 } 61 | Popular Tags |