KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jalisto > se > impl > server > PhysicalOid


1 /*
2  * Jalisto - JAva LIght STOrage
3  * Copyright (C) 2000-2005 Xcalia http://www.xcalia.com
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Xcalia
20  * 71, rue Desnouettes
21  * 75014 Paris - France
22  * http://www.xcalia.com
23  */

24 package org.objectweb.jalisto.se.impl.server;
25
26 import java.io.Serializable JavaDoc;
27 import java.util.StringTokenizer JavaDoc;
28
29 public class PhysicalOid implements Serializable JavaDoc {
30
31     public PhysicalOid() {
32     }
33
34     public PhysicalOid(Object JavaDoc clid, Object JavaDoc pid, Object JavaDoc iid) {
35         this.clid = ((Number JavaDoc) clid).shortValue();
36         this.pid = ((Number JavaDoc) pid).intValue();
37         this.iid = ((Number JavaDoc) iid).shortValue();
38     }
39
40     public PhysicalOid(String JavaDoc fpoidAsString) {
41         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(fpoidAsString, ":");
42         this.clid = Short.parseShort(st.nextToken());
43         this.pid = Integer.parseInt(st.nextToken());
44         this.iid = Short.parseShort(st.nextToken());
45     }
46
47     public Object JavaDoc getClid() {
48         return new Short JavaDoc(clid);
49     }
50
51     public Object JavaDoc getIid() {
52         return new Short JavaDoc(iid);
53     }
54
55     public Integer JavaDoc getIidAsInteger() {
56         return new Integer JavaDoc(iid);
57     }
58
59     public Object JavaDoc getPid() {
60         return new Integer JavaDoc(pid);
61     }
62
63     public boolean equals(Object JavaDoc obj) {
64         try {
65             PhysicalOid candidate = (PhysicalOid) obj;
66
67             return ((candidate.clid == this.clid) &&
68                     (candidate.pid == this.pid) && (candidate.iid == this.iid));
69         } catch (Exception JavaDoc e) {
70         }
71
72         return false;
73     }
74
75     public boolean hasClidEqualsWith(Object JavaDoc candidateClid) {
76         try {
77             return ((Short JavaDoc) candidateClid).shortValue() == this.clid;
78         } catch (Exception JavaDoc e) {
79         }
80
81         return false;
82     }
83
84     public int hashCode() {
85         int result = Integer.parseInt(String.valueOf(clid) +
86                                       String.valueOf(pid) +
87                                       String.valueOf(iid));
88
89         return result;
90     }
91
92     public PhysicalOid getClone() {
93         PhysicalOid clone = new PhysicalOid();
94         clone.clid = clid;
95         clone.iid = iid;
96         clone.pid = pid;
97         return clone;
98     }
99
100     public String JavaDoc toString() {
101         return String.valueOf(clid) + ":" + String.valueOf(pid) + ":" +
102                String.valueOf(iid);
103     }
104
105
106     private short clid; // classe identity
107
private short iid; // instance identity
108
private int pid; // page identity
109

110
111     static final long serialVersionUID = -7589366669041161459L;
112 }
Popular Tags