KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > ArticlePrimaryKey


1 package org.apache.ojb.broker;
2
3 import org.apache.ojb.broker.Identity;
4
5 /**
6  * This is a Primary Key Class for Article class
7  **/

8 public class ArticlePrimaryKey implements java.io.Serializable JavaDoc
9 {
10
11
12     int id;
13
14     /**
15      * PlzEntryBmpKey(String key) constructor
16      */

17     public ArticlePrimaryKey(int key)
18     {
19         //oid = new PlzEntryIdentity(key);
20
id = key;
21
22     }
23
24
25     /**
26      * equals method
27      * - user must provide a proper implementation for the equal method. The generated
28      * method assumes the key is a String object.
29      */

30     public boolean equals(Object JavaDoc o)
31     {
32         if (o instanceof ArticlePrimaryKey)
33             return (id == ((ArticlePrimaryKey) o).id);
34         else
35             return false;
36     }
37
38     /**
39      * hashcode method
40      * - user must provide a proper implementation for the hashCode method. The generated
41      * method assumes the key is a String object.
42      */

43     public int hashCode()
44     {
45         return id;
46     }
47
48     /**
49      * PlzEntryBmpKey(String key) constructor
50      */

51     public ArticlePrimaryKey(Identity oid)
52     {
53
54         id = ((Integer JavaDoc) oid.getPrimaryKeyValues()[0]).intValue();
55
56     }
57 }
58
Popular Tags