1 21 package com.db4o.foundation; 22 23 class HashtableByteArrayEntry extends HashtableObjectEntry { 24 25 public HashtableByteArrayEntry(byte[] bytes, Object value) { 26 super(hash(bytes), bytes, value); 27 } 28 29 private HashtableByteArrayEntry(){ 30 super(); 31 } 32 33 public Object deepClone(Object obj) { 34 return deepCloneInternal(new HashtableByteArrayEntry(), obj); 35 } 36 37 public boolean hasKey(Object key) { 38 if (key instanceof byte[]) { 39 return areEqual((byte[]) i_objectKey, (byte[]) key); 40 } 41 return false; 42 } 43 44 static int hash(byte[] bytes) { 45 int ret = 0; 46 for (int i = 0; i < bytes.length; i++) { 47 ret = ret * 31 + bytes[i]; 48 } 49 return ret; 50 } 51 52 static boolean areEqual(byte[] lhs, byte[] rhs) { 53 if (rhs.length != lhs.length) return false; 54 for (int i = 0; i < rhs.length; i++) { 55 if (rhs[i] != lhs[i]) return false; 56 } 57 return true; 58 } 59 } | Popular Tags |