1 22 package org.jboss.util.collection; 23 24 import java.util.ArrayList ; 25 import java.util.Collection ; 26 import java.util.Enumeration ; 27 import java.util.NoSuchElementException ; 28 29 35 public class SerializableEnumeration 36 extends ArrayList 37 implements Enumeration 38 { 39 private int index; 40 41 public SerializableEnumeration () { 42 index = 0; 43 } 44 45 public SerializableEnumeration (Collection c) { 46 super(c); 47 index = 0; 48 } 49 50 public SerializableEnumeration (int initialCapacity) { 51 super(initialCapacity); 52 index = 0; 53 } 54 55 public boolean hasMoreElements() { 56 return (index < size()); 57 } 58 59 public Object nextElement() throws NoSuchElementException 60 { 61 try { 62 Object nextObj = get(index); 63 index++; 64 return nextObj; 65 } 66 catch (IndexOutOfBoundsException e) { 67 throw new NoSuchElementException (); 68 } 69 } 70 71 private void writeObject(java.io.ObjectOutputStream out) 72 throws java.io.IOException 73 { 74 out.defaultWriteObject(); 76 } 77 78 private void readObject(java.io.ObjectInputStream in) 79 throws java.io.IOException , ClassNotFoundException 80 { 81 in.defaultReadObject(); 82 } 83 } 84 | Popular Tags |