KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > axis > client > TypeInfo


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.axis.client;
18
19 import java.io.Serializable JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.util.List JavaDoc;
22
23 import javax.xml.namespace.QName JavaDoc;
24 import javax.xml.rpc.encoding.DeserializerFactory JavaDoc;
25 import javax.xml.rpc.encoding.SerializerFactory JavaDoc;
26 import javax.xml.rpc.encoding.TypeMapping JavaDoc;
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 /**
34  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
35  */

36 public class TypeInfo implements Serializable JavaDoc {
37     private final Class JavaDoc clazz;
38     private final QName JavaDoc qName;
39     private final Class JavaDoc serFactoryClass;
40     private final Class JavaDoc deserFactoryClass;
41     private final boolean canSearchParents;
42     private final FieldDesc[] fields;
43
44     public static void register(List JavaDoc typeInfo, TypeMapping JavaDoc typeMapping) {
45         for (Iterator JavaDoc iter = typeInfo.iterator(); iter.hasNext();) {
46             TypeInfo info = (TypeInfo) iter.next();
47             info.register(typeMapping);
48         }
49     }
50
51     public TypeInfo(Class JavaDoc clazz, QName JavaDoc qName, Class JavaDoc serializerClass, Class JavaDoc 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 JavaDoc getClazz() {
61         return clazz;
62     }
63
64     public QName JavaDoc getqName() {
65         return qName;
66     }
67
68     public Class JavaDoc getSerFactoryClass() {
69         return serFactoryClass;
70     }
71
72     public Class JavaDoc 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 JavaDoc typeMapping) {
92         SerializerFactory JavaDoc ser = BaseSerializerFactory.createFactory(serFactoryClass, clazz, qName);
93         DeserializerFactory JavaDoc deser = BaseDeserializerFactory.createFactory(deserFactoryClass, clazz, qName);
94
95         typeMapping.register(clazz, qName, ser, deser);
96     }
97
98     public static class UpdatableTypeInfo {
99         protected Class JavaDoc clazz;
100         protected QName JavaDoc qName;
101         protected Class JavaDoc serializerClass;
102         protected Class JavaDoc deserializerClass;
103         protected boolean canSearchParents;
104         protected FieldDesc[] fields;
105
106         public TypeInfo buildTypeInfo() {
107             if (null == clazz) {
108                 throw new IllegalStateException JavaDoc("clazz is null");
109             } else if (null == qName) {
110                 throw new IllegalStateException JavaDoc("qName is null");
111             } else if (null == serializerClass) {
112                 throw new IllegalStateException JavaDoc("serializerClass is null");
113             } else if (null == deserializerClass) {
114                 throw new IllegalStateException JavaDoc("deserializerClass is null");
115             } else if (null == fields) {
116                 throw new IllegalStateException JavaDoc("fields is null");
117             }
118             return new TypeInfo(clazz, qName, serializerClass, deserializerClass, canSearchParents, fields);
119         }
120
121         public void setClazz(Class JavaDoc clazz) {
122             this.clazz = clazz;
123         }
124
125         public void setDeserializerClass(Class JavaDoc deserializerClass) {
126             this.deserializerClass = deserializerClass;
127         }
128
129         public void setFields(FieldDesc[] fields) {
130             this.fields = fields;
131         }
132
133         public void setQName(QName JavaDoc name) {
134             qName = name;
135         }
136
137         public void setSerializerClass(Class JavaDoc serializerClass) {
138             this.serializerClass = serializerClass;
139         }
140
141         public void setCanSearchParents(boolean canSearchParents) {
142             this.canSearchParents = canSearchParents;
143         }
144     }
145 }
146
Popular Tags