KickJava   Java API By Example, From Geeks To Geeks.

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


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.encoding.DeserializationContext;
21 import org.apache.commons.logging.Log;
22 import org.xml.sax.Attributes JavaDoc;
23 import org.xml.sax.SAXException JavaDoc;
24
25 import javax.activation.DataHandler JavaDoc;
26 import java.io.IOException JavaDoc;
27
28 /**
29  * text/plain DataHandler Deserializer
30  * Modified by Russell Butek <butek@us.ibm.com>
31  */

32 public class PlainTextDataHandlerDeserializer extends JAFDataHandlerDeserializer {
33     protected static Log log =
34             LogFactory.getLog(PlainTextDataHandlerDeserializer.class.getName());
35
36     public void startElement(String JavaDoc namespace, String JavaDoc localName,
37                              String JavaDoc prefix, Attributes JavaDoc attributes,
38                              DeserializationContext context)
39         throws SAXException JavaDoc {
40
41         super.startElement(namespace, localName, prefix, attributes, context);
42
43         if (getValue() instanceof DataHandler JavaDoc) {
44             try {
45                 DataHandler JavaDoc dh = (DataHandler JavaDoc) getValue();
46                 setValue(dh.getContent());
47             }
48             catch (IOException JavaDoc ioe) {
49             }
50         }
51     } // startElement
52
} // class PlainTextDataHandlerDeserializer
53
Popular Tags