KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > jdo > StringIdentity


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: StringIdentity.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 StringIdentity extends SingleFieldIdentity {
14
15     public StringIdentity(Class JavaDoc pcClass, String JavaDoc key) {
16         super(pcClass);
17         if (key == null) {
18             throw new NullPointerException JavaDoc(
19                     "key value passed to StringIdentity is null");
20         } else {
21             StringTokenizer JavaDoc token = new StringTokenizer JavaDoc(key, "::");
22             this.key = token.nextToken();
23             return;
24         }
25     }
26
27     public String JavaDoc getKey() {
28         return key;
29     }
30
31     public int hashCode() {
32         return key.hashCode() ^ targetClassName.hashCode();
33     }
34
35     public boolean equals(Object JavaDoc obj) {
36         if (obj == this)
37             return true;
38         if (!(obj instanceof StringIdentity)) {
39             return false;
40         } else {
41             StringIdentity other = (StringIdentity) obj;
42             return key.equals(other.key)
43                     && targetClassName.equals(other.targetClassName);
44         }
45     }
46
47     public String JavaDoc toString() {
48         return "" + key + "::" + targetClassName;
49     }
50
51     private final String JavaDoc key;
52 }
Popular Tags