KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > jdo > CharIdentity


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: CharIdentity.java
5

6 package javax.jdo;
7
8 // Referenced classes of package javax.jdo:
9
// SingleFieldIdentity, ShortIdentity
10

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