KickJava   Java API By Example, From Geeks To Geeks.

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


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.attachments.OctetStream;
20
21 import javax.mail.internet.MimeMultipart JavaDoc;
22 import javax.xml.namespace.QName JavaDoc;
23 import javax.xml.transform.Source JavaDoc;
24 import java.awt.*;
25
26 /**
27  * A JAFDataHandlerSerializer Factory
28  *
29  * @author Rich Scheuerle (scheu@us.ibm.com)
30  */

31 public class JAFDataHandlerSerializerFactory extends BaseSerializerFactory {
32
33     public JAFDataHandlerSerializerFactory(Class JavaDoc javaType, QName JavaDoc xmlType) {
34         super(getSerializerClass(javaType, xmlType), xmlType, javaType);
35     }
36     public JAFDataHandlerSerializerFactory() {
37         super(JAFDataHandlerSerializer.class);
38     }
39
40     private static Class JavaDoc getSerializerClass(Class JavaDoc javaType, QName JavaDoc xmlType) {
41         Class JavaDoc ser;
42         if (Image.class.isAssignableFrom(javaType)) {
43             ser = ImageDataHandlerSerializer.class;
44         }
45         else if (String JavaDoc.class.isAssignableFrom(javaType)) {
46             ser = PlainTextDataHandlerSerializer.class;
47         }
48         else if (Source JavaDoc.class.isAssignableFrom(javaType)) {
49             ser = SourceDataHandlerSerializer.class;
50         }
51         else if (MimeMultipart JavaDoc.class.isAssignableFrom(javaType)) {
52             ser = MimeMultipartDataHandlerSerializer.class;
53         }
54         else if (OctetStream.class.isAssignableFrom(javaType)) {
55             ser = OctetStreamDataHandlerSerializer.class;
56         }
57         else {
58             ser = JAFDataHandlerSerializer.class;
59         }
60         return ser;
61     } // getSerializerClass
62
}
63
Popular Tags