KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > encoding > ser > SimpleSerializerFactory


1 /*
2  * Copyright 2002-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 /**
18  * @author Glen Daniels (gdaniels@apache.org)
19  */

20 package org.apache.axis.encoding.ser;
21
22 import org.apache.axis.utils.JavaUtils;
23
24 import javax.xml.namespace.QName JavaDoc;
25 import javax.xml.rpc.JAXRPCException JavaDoc;
26
27 public class SimpleSerializerFactory extends BaseSerializerFactory {
28
29     private boolean isBasicType = false;
30
31     /**
32      * Note that the factory is constructed with the QName and xmlType. This is important
33      * to allow distinction between primitive values and java.lang wrappers.
34      **/

35     public SimpleSerializerFactory(Class JavaDoc javaType, QName JavaDoc xmlType) {
36         super(SimpleSerializer.class, xmlType, javaType);
37         this.isBasicType = JavaUtils.isBasic(javaType);
38     }
39
40     public javax.xml.rpc.encoding.Serializer JavaDoc getSerializerAs(String JavaDoc mechanismType) throws JAXRPCException JavaDoc {
41         if (this.isBasicType) {
42             return new SimpleSerializer(javaType, xmlType);
43         } else {
44             return super.getSerializerAs(mechanismType);
45         }
46     }
47     
48 }
49
Popular Tags