01: /*
02: * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
03: * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
04: */
05:
06: package javax.xml.bind.annotation.adapters;
07:
08: import javax.xml.bind.DatatypeConverter;
09:
10: /**
11: * {@link XmlAdapter} for <tt>xs:hexBinary</tt>.
12: *
13: * <p>
14: * This {@link XmlAdapter} binds <tt>byte[]</tt> to the hexBinary representation in XML.
15: *
16: * @author Kohsuke Kawaguchi
17: * @since JAXB 2.0
18: */
19: public final class HexBinaryAdapter extends XmlAdapter<String, byte[]> {
20: public byte[] unmarshal(String s) {
21: if (s == null)
22: return null;
23: return DatatypeConverter.parseHexBinary(s);
24: }
25:
26: public String marshal(byte[] bytes) {
27: if (bytes == null)
28: return null;
29: return DatatypeConverter.printHexBinary(bytes);
30: }
31: }
|