KickJava   Java API By Example, From Geeks To Geeks.

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


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.encoding.DeserializationContext;
20 import org.xml.sax.Attributes JavaDoc;
21 import org.xml.sax.SAXException JavaDoc;
22
23 import javax.xml.namespace.QName JavaDoc;
24
25 /**
26  * The DateSerializer deserializes a Date. Much of the work is done in the
27  * base class.
28  *
29  * @author Sam Ruby (rubys@us.ibm.com)
30  * Modified for JAX-RPC @author Rich Scheuerle (scheu@us.ibm.com)
31  */

32 public class QNameDeserializer extends SimpleDeserializer {
33
34     private DeserializationContext context = null;
35
36     /**
37      * The Deserializer is constructed with the xmlType and
38      * javaType
39      */

40     public QNameDeserializer(Class JavaDoc javaType, QName JavaDoc xmlType) {
41         super(javaType, xmlType);
42     } // ctor
43

44     /**
45      * The simple deserializer provides most of the stuff.
46      * We just need to override makeValue().
47      */

48     public Object JavaDoc makeValue(String JavaDoc source) {
49         source = source.trim();
50         int colon = source.lastIndexOf(":");
51         String JavaDoc namespace = colon < 0 ? "" :
52                 context.getNamespaceURI(source.substring(0, colon));
53         String JavaDoc localPart = colon < 0 ? source : source.substring(colon + 1);
54         return new QName JavaDoc(namespace, localPart);
55     } // makeValue
56

57     public void onStartElement(String JavaDoc namespace, String JavaDoc localName,
58                                String JavaDoc prefix, Attributes JavaDoc attributes,
59                                DeserializationContext context)
60             throws SAXException JavaDoc
61     {
62         this.context = context;
63     } // onStartElement
64
}
65
Popular Tags