1 55 56 package org.jboss.axis.encoding.ser; 57 58 import org.jboss.axis.encoding.DeserializationContext; 59 import org.jboss.axis.encoding.DeserializerImpl; 60 import org.jboss.axis.types.HexBinary; 61 import org.xml.sax.SAXException ; 62 63 import javax.xml.namespace.QName ; 64 65 72 public class HexDeserializer extends DeserializerImpl 73 { 74 75 public QName xmlType; 76 public Class javaType; 77 78 StringBuffer buf = null; 79 80 public HexDeserializer(Class javaType, QName xmlType) 81 { 82 this.xmlType = xmlType; 83 this.javaType = javaType; 84 } 85 86 89 public void characters(char[] chars, int start, int end) 90 throws SAXException 91 { 92 if (buf == null) 95 { 96 buf = new StringBuffer (); 97 } 98 buf.append(chars, start, end); 99 } 100 101 104 public void onEndElement(String namespace, String localName, 105 DeserializationContext context) 106 throws SAXException 107 { 108 if (buf != null) 109 { 110 if (javaType == byte[].class) 111 { 112 value = HexBinary.decode(buf.toString()); 113 } 114 else 115 { 116 value = new HexBinary(buf.toString()); 117 } 118 } 119 super.onEndElement(namespace, localName, context); 120 if (value == null) value = new HexBinary(""); 121 } 122 } 123 | Popular Tags |