1 17 package org.apache.geronimo.axis.client; 18 19 import java.io.Serializable ; 20 import java.util.Iterator ; 21 import java.util.List ; 22 23 import javax.xml.namespace.QName ; 24 import javax.xml.rpc.encoding.DeserializerFactory ; 25 import javax.xml.rpc.encoding.SerializerFactory ; 26 import javax.xml.rpc.encoding.TypeMapping ; 27 28 import org.apache.axis.description.FieldDesc; 29 import org.apache.axis.description.TypeDesc; 30 import org.apache.axis.encoding.ser.BaseDeserializerFactory; 31 import org.apache.axis.encoding.ser.BaseSerializerFactory; 32 33 36 public class TypeInfo implements Serializable { 37 private final Class clazz; 38 private final QName qName; 39 private final Class serFactoryClass; 40 private final Class deserFactoryClass; 41 private final boolean canSearchParents; 42 private final FieldDesc[] fields; 43 44 public static void register(List typeInfo, TypeMapping typeMapping) { 45 for (Iterator iter = typeInfo.iterator(); iter.hasNext();) { 46 TypeInfo info = (TypeInfo) iter.next(); 47 info.register(typeMapping); 48 } 49 } 50 51 public TypeInfo(Class clazz, QName qName, Class serializerClass, Class deserializerClass, boolean canSearchParents, FieldDesc[] fields) { 52 this.clazz = clazz; 53 this.qName = qName; 54 this.serFactoryClass = serializerClass; 55 this.deserFactoryClass = deserializerClass; 56 this.canSearchParents =canSearchParents; 57 this.fields = fields; 58 } 59 60 public Class getClazz() { 61 return clazz; 62 } 63 64 public QName getqName() { 65 return qName; 66 } 67 68 public Class getSerFactoryClass() { 69 return serFactoryClass; 70 } 71 72 public Class getDeserFactoryClass() { 73 return deserFactoryClass; 74 } 75 76 public boolean isCanSearchParents() { 77 return canSearchParents; 78 } 79 80 public FieldDesc[] getFields() { 81 return fields; 82 } 83 84 public TypeDesc buildTypeDesc() { 85 TypeDesc typeDesc = new TypeDesc(clazz, canSearchParents); 86 typeDesc.setXmlType(qName); 87 typeDesc.setFields(fields); 88 return typeDesc; 89 } 90 91 public void register(TypeMapping typeMapping) { 92 SerializerFactory ser = BaseSerializerFactory.createFactory(serFactoryClass, clazz, qName); 93 DeserializerFactory deser = BaseDeserializerFactory.createFactory(deserFactoryClass, clazz, qName); 94 95 typeMapping.register(clazz, qName, ser, deser); 96 } 97 98 public static class UpdatableTypeInfo { 99 protected Class clazz; 100 protected QName qName; 101 protected Class serializerClass; 102 protected Class deserializerClass; 103 protected boolean canSearchParents; 104 protected FieldDesc[] fields; 105 106 public TypeInfo buildTypeInfo() { 107 if (null == clazz) { 108 throw new IllegalStateException ("clazz is null"); 109 } else if (null == qName) { 110 throw new IllegalStateException ("qName is null"); 111 } else if (null == serializerClass) { 112 throw new IllegalStateException ("serializerClass is null"); 113 } else if (null == deserializerClass) { 114 throw new IllegalStateException ("deserializerClass is null"); 115 } else if (null == fields) { 116 throw new IllegalStateException ("fields is null"); 117 } 118 return new TypeInfo(clazz, qName, serializerClass, deserializerClass, canSearchParents, fields); 119 } 120 121 public void setClazz(Class clazz) { 122 this.clazz = clazz; 123 } 124 125 public void setDeserializerClass(Class deserializerClass) { 126 this.deserializerClass = deserializerClass; 127 } 128 129 public void setFields(FieldDesc[] fields) { 130 this.fields = fields; 131 } 132 133 public void setQName(QName name) { 134 qName = name; 135 } 136 137 public void setSerializerClass(Class serializerClass) { 138 this.serializerClass = serializerClass; 139 } 140 141 public void setCanSearchParents(boolean canSearchParents) { 142 this.canSearchParents = canSearchParents; 143 } 144 } 145 } 146 | Popular Tags |