1 10 package com.hp.hpl.jena.datatypes.xsd; 11 12 import java.util.Arrays ; 13 14 import org.apache.xerces.impl.dv.util.HexBin; 15 import com.hp.hpl.jena.datatypes.DatatypeFormatException; 16 import com.hp.hpl.jena.graph.impl.LiteralLabel; 17 18 25 public class XSDhexBinary extends XSDDatatype { 26 27 32 public XSDhexBinary(String typeName) { 33 super(typeName, null); 34 } 35 36 40 public boolean isValidValue(Object valueForm) { 41 return (valueForm instanceof byte[]); 42 } 43 44 48 public String unparse(Object value) { 49 if (value instanceof byte[]) { 50 return HexBin.encode((byte[])value); 51 } else { 52 throw new DatatypeFormatException("base64 asked encode a non-byte arrary"); 53 } 54 } 55 56 61 public boolean isEqual(LiteralLabel value1, LiteralLabel value2) { 62 return value1.getDatatype() == value2.getDatatype() 63 && Arrays.equals((byte[])value1.getValue(), (byte[])value2.getValue()); 64 } 66 67 68 } 69 70 71 72 101 | Popular Tags |