KickJava   Java API By Example, From Geeks To Geeks.

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


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.AttachmentUtils;
20 import org.apache.axis.components.logger.LogFactory;
21 import org.apache.axis.encoding.DeserializationContext;
22 import org.apache.axis.encoding.DeserializerImpl;
23 import org.apache.axis.message.SOAPHandler;
24 import org.apache.axis.utils.Messages;
25 import org.apache.axis.soap.SOAPConstants;
26 import org.apache.axis.AxisFault;
27 import org.apache.commons.logging.Log;
28 import org.xml.sax.Attributes JavaDoc;
29 import org.xml.sax.SAXException JavaDoc;
30
31 import javax.xml.namespace.QName JavaDoc;
32
33 /**
34  * JAFDataHandler Serializer
35  * @author Rick Rineholt
36  * Modified by Rich Scheuerle <scheu@us.ibm.com>
37  */

38 public class JAFDataHandlerDeserializer extends DeserializerImpl {
39     protected static Log log =
40             LogFactory.getLog(JAFDataHandlerDeserializer.class.getName());
41
42     public void startElement(String JavaDoc namespace, String JavaDoc localName,
43                              String JavaDoc prefix, Attributes JavaDoc attributes,
44                              DeserializationContext context)
45         throws SAXException JavaDoc {
46
47         if (!context.isDoneParsing()) {
48             if (myElement == null) {
49                 try {
50                     myElement = makeNewElement(namespace, localName, prefix, attributes, context);
51                 } catch (AxisFault axisFault) {
52                     throw new SAXException JavaDoc(axisFault);
53                 }
54                 context.pushNewElement(myElement);
55             }
56         }
57 // super.startElement(namespace, localName, qName, attributes, context);
58

59         SOAPConstants soapConstants = context.getSOAPConstants();
60
61         QName JavaDoc type = context.getTypeFromAttributes(namespace,
62                                                    localName,
63                                                    attributes);
64         if (log.isDebugEnabled()) {
65             log.debug(Messages.getMessage("gotType00", "Deser", "" + type));
66         }
67         
68         String JavaDoc href = attributes.getValue(soapConstants.getAttrHref());
69         if (href != null) {
70             Object JavaDoc ref = context.getObjectByRef(href);
71             try{
72                 ref = AttachmentUtils.getActivationDataHandler((org.apache.axis.Part)ref);
73             }catch(org.apache.axis.AxisFault e){;}
74             
75             setValue(ref);
76         }
77     }
78
79     /**
80      * Deserializer interface called on each child element encountered in
81      * the XML stream.
82      */

83     public SOAPHandler onStartChild(String JavaDoc namespace,
84                                     String JavaDoc localName,
85                                     String JavaDoc prefix,
86                                     Attributes JavaDoc attributes,
87                                     DeserializationContext context)
88         throws SAXException JavaDoc {
89         throw new SAXException JavaDoc(Messages.getMessage(
90                 "noSubElements", namespace + ":" + localName));
91     }
92 }
93
Popular Tags