1 20 21 package org.apache.derby.impl.drda; 22 23 26 final class ConsistencyToken { 27 28 private final byte[] bytes; 29 30 private int hash = 0; 31 32 37 ConsistencyToken(byte[] bytes) { 38 this.bytes = bytes; 39 } 40 41 46 public byte[] getBytes() { 47 return bytes; 48 } 49 50 56 public boolean equals(Object o) { 57 if (!(o instanceof ConsistencyToken)) return false; 58 ConsistencyToken ct = (ConsistencyToken) o; 59 int len = bytes.length; 60 if (len != ct.bytes.length) return false; 61 for (int i = 0; i < len; ++i) { 62 if (bytes[i] != ct.bytes[i]) return false; 63 } 64 return true; 65 } 66 67 72 public int hashCode() { 73 int h = hash; 77 if (h == 0) { 78 int len = bytes.length; 84 for (int i = 0; i < len; ++i) { 85 h ^= bytes[i]; 86 } 87 hash = h; 88 } 89 return h; 90 } 91 92 99 public String toString() { 100 return new java.math.BigInteger (bytes).toString(); 101 } 102 } 103 | Popular Tags |