01: package net.sourceforge.squirrel_sql.fw.id;
02:
03: import java.io.Serializable;
04:
05: /*
06: * Copyright (C) 2001-2004 Colin Bell
07: * colbell@users.sourceforge.net
08: *
09: * This library is free software; you can redistribute it and/or
10: * modify it under the terms of the GNU Lesser General Public
11: * License as published by the Free Software Foundation; either
12: * version 2.1 of the License, or (at your option) any later version.
13: *
14: * This library is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: * Lesser General Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser General Public
20: * License along with this library; if not, write to the Free Software
21: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: */
23: public class IntegerIdentifier implements IIdentifier, Serializable {
24: public interface IPropertyNames {
25: String STRING = "string";
26: }
27:
28: private int _id;
29:
30: public IntegerIdentifier(int value) {
31: super ();
32: _id = value;
33: }
34:
35: public boolean equals(Object rhs) {
36: boolean rc = false;
37: if (rhs != null && rhs.getClass().equals(getClass())) {
38: rc = ((IntegerIdentifier) rhs).toString()
39: .equals(toString());
40: }
41: return rc;
42: }
43:
44: public synchronized int hashCode() {
45: return _id;
46: }
47:
48: public String toString() {
49: return Integer.toString(_id);
50: }
51:
52: // Only for restoring from XML etc.
53: public void setString(String value) {
54: _id = Integer.parseInt(value);
55: }
56: }
|