01: /*
02: * Created on May 28, 2006
03: */
04: package uk.org.ponder.saxalizer.mapping;
05:
06: import java.util.HashMap;
07:
08: import uk.org.ponder.arrayutil.TypedListWrapper;
09:
10: public class ContainerTypeRegistry {
11:
12: private HashMap collectionmap = new HashMap();
13:
14: public Class getContaineeType(Object container) {
15: Class collectiontype = container instanceof Class ? (Class) container
16: : container.getClass();
17: if (collectiontype.isArray()) {
18: Class component = collectiontype.getComponentType();
19: return component;
20: } else if (container instanceof TypedListWrapper) {
21: return ((TypedListWrapper) container).getWrappedType();
22: }
23: return (Class) collectionmap.get(collectiontype);
24: }
25:
26: public void addCollectionType(Class collectiontype,
27: Class containeetype) {
28: collectionmap.put(collectiontype, containeetype);
29: }
30: }
|