01: package murlen.util.fscript;
02:
03: /**
04: * <p>FSObject - representation of a general object type</p>
05: * <p>
06: * <I>Copyright (C) 2002-2003 </I></p>
07: * <p>
08: * This library is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU Library General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.</p>
12: * <p>
13: * This library is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * Library General Public License for more details.</p>
17: *
18: * <p>You should have received a copy of the GNU Library General Public
19: * License along with this library; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA </p>
21: *
22: * @author Joachim Van der Auwera
23: *
24: * modifications
25: * 08/09/2002 Added "FSObject Containing..." to toString to ease debugging.
26: * 21.10.2002 added equals() for comparisons
27: * 25.02.2004 equals() allow compare of object with embedded type X directly with another object of type X
28: * 28.02.2004 make null typed
29: */
30:
31: public class FSObject extends Object {
32: private Object value;
33: private Class nullClass;
34:
35: public FSObject() {
36: }
37:
38: public FSObject(Object value) {
39: this .value = value;
40: }
41:
42: public FSObject(Object value, Class nClass) {
43: this .value = value;
44: nullClass = nClass;
45: }
46:
47: public Object getObject() {
48: return value;
49: }
50:
51: public void setObject(Object value) {
52: this .value = value;
53: nullClass = null;
54: }
55:
56: public void setObject(Object value, Class nClass) {
57: this .value = value;
58: nullClass = nClass;
59: }
60:
61: public Class getNullClass() {
62: return value == null ? nullClass : value.getClass();
63: }
64:
65: public boolean equals(Object obj) {
66: if (this == obj)
67: return true;
68: if (obj instanceof FSObject) {
69: obj = ((FSObject) obj).getObject();
70: }
71: if (value == obj)
72: return true;
73: if (value != null)
74: return value.equals(obj);
75: return false;
76: }
77:
78: public String toString() {
79: if (value == null)
80: return "<null>";
81: return "FSObject Containing - " + value.toString();
82: }
83:
84: }
|