1 6 package javax.jdo; 7 8 import java.util.StringTokenizer ; 9 10 13 public class ByteIdentity extends SingleFieldIdentity { 14 15 public ByteIdentity(Class pcClass, Byte key) { 16 super(pcClass); 17 if (key == null) { 18 throw new NullPointerException ( 19 "key value passed to ByteIdentity is null"); 20 } else { 21 this.key = key.byteValue(); 22 return; 23 } 24 } 25 26 public ByteIdentity(Class pcClass, byte key) { 27 super(pcClass); 28 this.key = key; 29 } 30 31 public ByteIdentity(Class pcClass, String key) { 32 super(pcClass); 33 if (key == null) { 34 throw new NullPointerException ( 35 "key value passed to ByteIdentity is null"); 36 } else { 37 StringTokenizer token = new StringTokenizer (key, "::"); 38 this.key = (new Byte (token.nextToken())).byteValue(); 39 return; 40 } 41 } 42 43 public byte getKey() { 44 return key; 45 } 46 47 public int hashCode() { 48 return (new Byte (key)).hashCode() ^ targetClassName.hashCode(); 49 } 50 51 public boolean equals(Object obj) { 52 if (obj == this) 53 return true; 54 if (!(obj instanceof ShortIdentity)) { 55 return false; 56 } else { 57 ByteIdentity other = (ByteIdentity) obj; 58 return key == other.key 59 && targetClassName.equals(other.targetClassName); 60 } 61 } 62 63 public String toString() { 64 return "" + key + "::" + targetClassName; 65 } 66 67 private final byte key; 68 } | Popular Tags |