KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > jdo > ShortIdentity


1 // Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
2
// Jad home page: http://www.geocities.com/kpdus/jad.html
3
// Decompiler options: packimports(3) noctor space
4
// Source File Name: ShortIdentity.java
5

6 package javax.jdo;
7
8 import java.util.StringTokenizer JavaDoc;
9
10 // Referenced classes of package javax.jdo:
11
// SingleFieldIdentity
12

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