View Javadoc
1   package org.exolab.castor.mapping.loader.collection.handler;
2   
3   import java.util.Enumeration;
4   
5   import org.exolab.castor.mapping.CollectionHandler;
6   import org.exolab.castor.mapping.loader.CollectionHandlers;
7   
8   public final class EnumerateCollectionHandler<T> implements CollectionHandler<T> {
9      public Object add(Object collection, T object) {
10        // -- do nothing, cannot add elements to an enumeration
11        return null;
12     }
13  
14     @SuppressWarnings("unchecked")
15     public Enumeration<T> elements(Object collection) {
16        if (collection == null)
17           return new CollectionHandlers.EmptyEnumerator<T>();
18        return ((Enumeration<T>) collection);
19     }
20  
21     public int size(Object collection) {
22        // -- Nothing we can do without destroying the enumeration
23        return 0;
24     }
25  
26     public Object clear(Object collection) {
27        // -- Should we iterate over nextElement?
28        return null;
29     }
30  
31     public String toString() {
32        return "Enumeration";
33     }
34  }