KickJava   Java API By Example, From Geeks To Geeks.

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


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.types.HexBinary;
20
21 import javax.xml.namespace.QName JavaDoc;
22
23 /**
24  * Deserializer for hexBinary.
25  *
26  * @author Davanum Srinivas <dims@yahoo.com>
27  * Modified by @author Rich scheuerle <scheu@us.ibm.com>
28  * @see <a HREF="http://www.w3.org/TR/xmlschema-2/#hexBinary">XML Schema 3.2.16</a>
29  */

30 public class HexDeserializer extends SimpleDeserializer {
31
32     public HexDeserializer(Class JavaDoc javaType, QName JavaDoc xmlType) {
33         super(javaType, xmlType);
34     }
35
36     /**
37      * Convert the string that has been accumulated into an Object. Subclasses
38      * may override this. Note that if the javaType is a primitive, the returned
39      * object is a wrapper class.
40      * @param source the serialized value to be deserialized
41      * @throws Exception any exception thrown by this method will be wrapped
42      */

43     public Object JavaDoc makeValue(String JavaDoc source) throws Exception JavaDoc {
44         Object JavaDoc result;
45         if (javaType == byte[].class) {
46             result = HexBinary.decode(source);
47         } else {
48             result = new HexBinary(source);
49         }
50         if (result == null) result = new HexBinary("");
51         return result;
52     }
53 }
54
Popular Tags