1 3 package jodd.util.collection; 4 5 import java.util.Enumeration ; 6 import java.util.NoSuchElementException ; 7 8 11 public class JoinedEnumeration implements Enumeration { 12 13 private Enumeration mOne; 14 private Enumeration mTwo; 15 16 public JoinedEnumeration(Enumeration enumeration1, Enumeration enumeration2) { 17 mOne = enumeration1; 18 mTwo = enumeration2; 19 } 20 21 public boolean hasMoreElements() { 22 if (mOne != null) { 23 if (mOne.hasMoreElements()) { 24 return true; 25 } 26 mOne = null; 27 } 28 return mTwo.hasMoreElements(); 29 } 30 31 public Object nextElement() { 32 if (mOne != null) 33 try { 34 return mOne.nextElement(); 35 } catch (NoSuchElementException _ex) { 36 mOne = null; 37 } 38 return mTwo.nextElement(); 39 } 40 41 } 42 | Popular Tags |