KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > encoding > DefaultJAXRPC11TypeMappingImpl


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

16
17 package org.apache.axis.encoding;
18
19 import org.apache.axis.Constants;
20 import org.apache.axis.encoding.ser.CalendarDeserializerFactory;
21 import org.apache.axis.encoding.ser.CalendarSerializerFactory;
22 import org.apache.axis.encoding.ser.DateDeserializerFactory;
23 import org.apache.axis.encoding.ser.DateSerializerFactory;
24 import org.apache.axis.encoding.ser.TimeDeserializerFactory;
25 import org.apache.axis.encoding.ser.TimeSerializerFactory;
26
27 /**
28  * This is the implementation of the axis Default JAX-RPC SOAP Encoding TypeMapping
29  * See DefaultTypeMapping for more information.
30  */

31 public class DefaultJAXRPC11TypeMappingImpl extends DefaultTypeMappingImpl {
32
33     private static DefaultJAXRPC11TypeMappingImpl tm = null;
34
35     /**
36      * Obtain the singleton default typemapping.
37      */

38     public static synchronized TypeMappingImpl getSingleton() {
39         if (tm == null) {
40             tm = new DefaultJAXRPC11TypeMappingImpl();
41         }
42         return tm;
43     }
44
45     protected DefaultJAXRPC11TypeMappingImpl() {
46         registerXSDTypes();
47     }
48
49     /**
50      * Register the XSD data types in JAXRPC11 spec.
51      */

52     private void registerXSDTypes() {
53         // Table 4-1 of the JAXRPC 1.1 spec
54
myRegisterSimple(Constants.XSD_UNSIGNEDINT, Long JavaDoc.class);
55         myRegisterSimple(Constants.XSD_UNSIGNEDINT, long.class);
56         myRegisterSimple(Constants.XSD_UNSIGNEDSHORT, Integer JavaDoc.class);
57         myRegisterSimple(Constants.XSD_UNSIGNEDSHORT, int.class);
58         myRegisterSimple(Constants.XSD_UNSIGNEDBYTE, Short JavaDoc.class);
59         myRegisterSimple(Constants.XSD_UNSIGNEDBYTE, short.class);
60         myRegister(Constants.XSD_DATETIME, java.util.Calendar JavaDoc.class,
61                 new CalendarSerializerFactory(java.util.Calendar JavaDoc.class,
62                         Constants.XSD_DATETIME),
63                 new CalendarDeserializerFactory(java.util.Calendar JavaDoc.class,
64                         Constants.XSD_DATETIME));
65         myRegister(Constants.XSD_DATE, java.util.Calendar JavaDoc.class,
66                 new DateSerializerFactory(java.util.Calendar JavaDoc.class,
67                         Constants.XSD_DATE),
68                 new DateDeserializerFactory(java.util.Calendar JavaDoc.class,
69                         Constants.XSD_DATE));
70         myRegister(Constants.XSD_TIME, java.util.Calendar JavaDoc.class,
71                 new TimeSerializerFactory(java.util.Calendar JavaDoc.class,
72                         Constants.XSD_TIME),
73                 new TimeDeserializerFactory(java.util.Calendar JavaDoc.class,
74                         Constants.XSD_TIME));
75         try {
76             myRegisterSimple(Constants.XSD_ANYURI,
77                     Class.forName("java.net.URI"));
78         } catch (ClassNotFoundException JavaDoc e) {
79             myRegisterSimple(Constants.XSD_ANYURI, java.lang.String JavaDoc.class);
80         }
81             
82         // Table 4-2 of JAXRPC 1.1 spec
83
myRegisterSimple(Constants.XSD_DURATION, java.lang.String JavaDoc.class);
84         myRegisterSimple(Constants.XSD_YEARMONTH, java.lang.String JavaDoc.class);
85         myRegisterSimple(Constants.XSD_YEAR, java.lang.String JavaDoc.class);
86         myRegisterSimple(Constants.XSD_MONTHDAY, java.lang.String JavaDoc.class);
87         myRegisterSimple(Constants.XSD_DAY, java.lang.String JavaDoc.class);
88         myRegisterSimple(Constants.XSD_MONTH, java.lang.String JavaDoc.class);
89         myRegisterSimple(Constants.XSD_NORMALIZEDSTRING,
90                 java.lang.String JavaDoc.class);
91         myRegisterSimple(Constants.XSD_TOKEN, java.lang.String JavaDoc.class);
92         myRegisterSimple(Constants.XSD_LANGUAGE, java.lang.String JavaDoc.class);
93         myRegisterSimple(Constants.XSD_NAME, java.lang.String JavaDoc.class);
94         myRegisterSimple(Constants.XSD_NCNAME, java.lang.String JavaDoc.class);
95         myRegisterSimple(Constants.XSD_ID, java.lang.String JavaDoc.class);
96         myRegisterSimple(Constants.XSD_NMTOKEN, java.lang.String JavaDoc.class);
97         myRegisterSimple(Constants.XSD_NMTOKENS, java.lang.String JavaDoc.class);
98         myRegisterSimple(Constants.XSD_STRING, java.lang.String JavaDoc.class);
99         myRegisterSimple(Constants.XSD_NONPOSITIVEINTEGER,
100                 java.math.BigInteger JavaDoc.class);
101         myRegisterSimple(Constants.XSD_NEGATIVEINTEGER,
102                 java.math.BigInteger JavaDoc.class);
103         myRegisterSimple(Constants.XSD_NONNEGATIVEINTEGER,
104                 java.math.BigInteger JavaDoc.class);
105         myRegisterSimple(Constants.XSD_UNSIGNEDLONG,
106                 java.math.BigInteger JavaDoc.class);
107         myRegisterSimple(Constants.XSD_POSITIVEINTEGER,
108                 java.math.BigInteger JavaDoc.class);
109     }
110 }
Popular Tags