1 25 26 27 package org.objectweb.jonas_ejb.lib; 28 29 import java.io.Serializable ; 30 import java.lang.Object ; 31 import java.util.Enumeration ; 32 import java.util.NoSuchElementException ; 33 import java.util.Vector ; 34 35 45 46 public class CollectionEnum implements Serializable , Enumeration { 47 48 51 private Vector mCollection = null; 52 55 private int mIndex = 0; 56 57 61 public CollectionEnum() { 62 mCollection = new Vector (); 63 mIndex = 0; 64 } 65 66 69 public synchronized void addElement(Object obj) { 70 mCollection.addElement(obj); 71 } 72 73 76 public CollectionEnum(Vector v) { 77 mCollection = new Vector (); 78 for (int i=0; i<v.size(); i++) { 79 mCollection.addElement(v.elementAt(i)); 80 } 81 mIndex = 0; 82 } 83 84 87 public boolean hasMoreElements() { 88 return(mIndex<mCollection.size()); 89 } 90 91 94 public Object nextElement() throws NoSuchElementException { 95 if (mIndex>=mCollection.size()) { 96 throw new NoSuchElementException ("CollectionEnum ("+mIndex+">="+mCollection.size()+")"); 97 } 98 mIndex++; 99 return(mCollection.elementAt(mIndex-1)); 100 } 101 102 } 103 104 | Popular Tags |