KickJava   Java API By Example, From Geeks To Geeks.

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


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.ser;
18
19 import org.apache.axis.components.logger.LogFactory;
20 import org.apache.axis.attachments.OctetStream;
21 import org.apache.commons.logging.Log;
22
23 import javax.mail.internet.MimeMultipart JavaDoc;
24 import javax.xml.namespace.QName JavaDoc;
25 import javax.xml.transform.Source JavaDoc;
26 import java.awt.*;
27
28 /**
29  * A JAFDataHandlerDeserializer Factory
30  *
31  * @author Rich Scheuerle (scheu@us.ibm.com)
32  */

33 public class JAFDataHandlerDeserializerFactory extends BaseDeserializerFactory {
34     protected static Log log =
35             LogFactory.getLog(JAFDataHandlerDeserializerFactory.class.getName());
36
37     public JAFDataHandlerDeserializerFactory(Class JavaDoc javaType, QName JavaDoc xmlType) {
38         super(getDeserializerClass(javaType, xmlType), xmlType, javaType);
39         log.debug("Enter/Exit: JAFDataHandlerDeserializerFactory(" + javaType + ", "
40                 + xmlType + ")");
41     }
42     public JAFDataHandlerDeserializerFactory() {
43         super(JAFDataHandlerDeserializer.class);
44         log.debug("Enter/Exit: JAFDataHandlerDeserializerFactory()");
45     }
46
47     private static Class JavaDoc getDeserializerClass(Class JavaDoc javaType, QName JavaDoc xmlType) {
48         Class JavaDoc deser;
49         if (Image.class.isAssignableFrom(javaType)) {
50             deser = ImageDataHandlerDeserializer.class;
51         }
52         else if (String JavaDoc.class.isAssignableFrom(javaType)) {
53             deser = PlainTextDataHandlerDeserializer.class;
54         }
55         else if (Source JavaDoc.class.isAssignableFrom(javaType)) {
56             deser = SourceDataHandlerDeserializer.class;
57         }
58         else if (MimeMultipart JavaDoc.class.isAssignableFrom(javaType)) {
59             deser = MimeMultipartDataHandlerDeserializer.class;
60         }
61         else if (OctetStream.class.isAssignableFrom(javaType)) {
62             deser = OctetStreamDataHandlerDeserializer.class;
63         }
64         else {
65             deser = JAFDataHandlerDeserializer.class;
66         }
67         return deser;
68     } // getDeserializerClass
69
}
70
Popular Tags