KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jofti > store > StoreKey


1 package com.jofti.store;
2
3 import java.io.Serializable JavaDoc;
4
5 import com.jofti.core.IStoreKey;
6
7 public class StoreKey implements IStoreKey, Cloneable JavaDoc,Serializable JavaDoc {
8
9     /**
10      *
11      */

12     private static final long serialVersionUID = 6668445940104260505L;
13     
14     long id =0;
15     private volatile int hashCode =0;
16     FilePositionHolder[] filePositions =null;
17     int size=0;
18     int number =0;
19     
20     public boolean newKey =false;
21     
22     
23     public StoreKey(){
24         
25     }
26     
27     public StoreKey(long id){
28         this.id= id;
29     }
30     
31     
32
33
34
35     
36     public boolean equals(Object JavaDoc obj){
37         if (obj instanceof IStoreKey) {
38             IStoreKey temp = (IStoreKey) obj;
39             
40             return temp.getId() == id;
41     
42         }
43         return false;
44     }
45     
46     
47     
48     public int hashCode(){
49         if (hashCode ==0){
50             hashCode = (int) (id ^ id>>32) ;
51         }
52         return hashCode;
53     }
54
55     
56     
57     public String JavaDoc toString(){
58         return "ID:"+id + " size:"+size + " new:"+newKey;
59     }
60
61     /* (non-Javadoc)
62      * @see com.jofti.core.IStoreKey#getNextPositions()
63      */

64     public FilePositionHolder[] getFilePositions() {
65         return filePositions;
66     }
67     public void setFilePositions(FilePositionHolder[] filePositions) {
68         this.filePositions = filePositions;
69     }
70
71     public boolean isNewKey()
72     {
73         return newKey;
74     }
75
76     public void setNewKey(boolean newKey)
77     {
78         this.newKey = newKey;
79         
80     }
81
82     /**
83      * @return Returns the size.
84      */

85     public int getSize()
86     {
87         return size;
88     }
89
90     /**
91      * @param size The size to set.
92      */

93     public void setSize(int size)
94     {
95         this.size = size;
96     }
97     
98     public Object JavaDoc clone(){
99     StoreKey key = new StoreKey();
100         key.id = id;
101         if (filePositions != null){
102             key.filePositions = (FilePositionHolder[])filePositions.clone();
103         }
104         key.size =size;
105         key.newKey = newKey;
106         key.number =number;
107         return key;
108         
109     }
110
111     /* (non-Javadoc)
112      * @see com.jofti.core.IStoreKey#getId()
113      */

114     public long getId() {
115         return id;
116     }
117     public int getNumber() {
118         return number;
119     }
120     public void setNumber(int number) {
121         this.number = number;
122     }
123 }
124
Popular Tags