KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > jdo > SimpleIdentity


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

6 package javax.jdo;
7
8 import java.io.Serializable JavaDoc;
9
10 public class SimpleIdentity implements Serializable JavaDoc {
11
12     private SimpleIdentity(Class JavaDoc cls) {
13         targetClass = cls;
14         targetClassName = cls.getName();
15     }
16
17     public static SimpleIdentity newInstance(Class JavaDoc cls, byte key) {
18         SimpleIdentity si = new SimpleIdentity(cls);
19         si.byteKey = key;
20         return si;
21     }
22
23     public static SimpleIdentity newInstance(Class JavaDoc cls, short key) {
24         SimpleIdentity si = new SimpleIdentity(cls);
25         si.shortKey = key;
26         return si;
27     }
28
29     public static SimpleIdentity newInstance(Class JavaDoc cls, int key) {
30         SimpleIdentity si = new SimpleIdentity(cls);
31         si.intKey = key;
32         return si;
33     }
34
35     public static SimpleIdentity newInstance(Class JavaDoc cls, long key) {
36         SimpleIdentity si = new SimpleIdentity(cls);
37         si.longKey = key;
38         return si;
39     }
40
41     public static SimpleIdentity newInstance(Class JavaDoc cls, Object JavaDoc key) {
42         SimpleIdentity si = new SimpleIdentity(cls);
43         si.objectKey = key;
44         return si;
45     }
46
47     public static SimpleIdentity newInstance(Class JavaDoc cls, String JavaDoc key) {
48         SimpleIdentity si = new SimpleIdentity(cls);
49         si.stringKey = key;
50         return si;
51     }
52
53     public byte getByteKey() {
54         return byteKey;
55     }
56
57     public int getIntKey() {
58         return intKey;
59     }
60
61     public long getLongKey() {
62         return longKey;
63     }
64
65     public Object JavaDoc getObjectKey() {
66         return objectKey;
67     }
68
69     public short getShortKey() {
70         return shortKey;
71     }
72
73     public String JavaDoc getStringKey() {
74         return stringKey;
75     }
76
77     public Class JavaDoc getTargetClass() {
78         return targetClass;
79     }
80
81     public String JavaDoc getTargetClassName() {
82         return targetClassName;
83     }
84
85     public boolean equals(Object JavaDoc obj) {
86         return (obj instanceof SimpleIdentity)
87                 && toString().equals(obj.toString());
88     }
89
90     public String JavaDoc toString() {
91         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
92         sb.append(targetClassName);
93         sb.append("-");
94         sb.append(String.valueOf(byteKey));
95         sb.append("-");
96         sb.append(String.valueOf(shortKey));
97         sb.append("-");
98         sb.append(String.valueOf(intKey));
99         sb.append("-");
100         sb.append(String.valueOf(longKey));
101         sb.append("-");
102         sb.append(String.valueOf(objectKey));
103         sb.append("-");
104         sb.append(String.valueOf(targetClassName));
105         return sb.toString();
106     }
107
108     private byte byteKey;
109
110     private short shortKey;
111
112     private int intKey;
113
114     private long longKey;
115
116     private Object JavaDoc objectKey;
117
118     private String JavaDoc stringKey;
119
120     private transient Class JavaDoc targetClass;
121
122     private String JavaDoc targetClassName;
123 }
Popular Tags