1 package com.thaiopensource.datatype.xsd; 2 3 abstract class BinaryDatatype extends DatatypeBase implements Measure { 4 BinaryDatatype() { 5 super(WHITE_SPACE_PRESERVE); 7 } 8 9 public int valueHashCode(Object value) { 10 byte[] v = (byte[])value; 11 int hc = 0; 12 for (int i = 0, len = v.length; i < len; i++) 13 hc = (hc * 33) ^ (v[i] & 0xFF); 14 return hc; 15 } 16 17 public boolean sameValue(Object value1, Object value2) { 18 byte[] v1 = (byte[])value1; 19 byte[] v2 = (byte[])value2; 20 if (v1.length != v2.length) 21 return false; 22 for (int i = 0, len = v1.length; i < len; i++) 23 if (v1[i] != v2[i]) 24 return false; 25 return true; 26 } 27 28 public int getLength(Object obj) { 29 return ((byte[])obj).length; 30 } 31 32 Measure getMeasure() { 33 return this; 34 } 35 } 36 | Popular Tags |