01: package com.jat.business;
02:
03: import java.util.Enumeration;
04: import java.util.Hashtable;
05: import java.util.Properties;
06: import java.io.Serializable;
07:
08: /**
09: * <p>Title: JAT</p>
10: * <p>Description: </p>
11: * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
12: * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
13: * @author stf
14: * @version 1.2
15: * @since 1.0
16: */
17:
18: public class BusinessObjectProperties implements Serializable {
19:
20: public BusinessObjectProperties() {
21: this .properties = new Properties();
22: }
23:
24: public Object get(String field) {
25: return this .properties.get(field.toUpperCase());
26: }
27:
28: public Object put(String field, Object obj) {
29: return this .properties.put(field.toUpperCase(), obj);
30: }
31:
32: public Object remove(String field) {
33: return this .properties.remove(field);
34: }
35:
36: public Enumeration keys() {
37: return this .properties.keys();
38: }
39:
40: public boolean equals(Object other) {
41: if (other == this )
42: return true;
43: if (other == null)
44: return false;
45: if (getClass() != other.getClass())
46: return false;
47: BusinessObjectProperties bop = (BusinessObjectProperties) other;
48: if (bop.properties.size() != this .properties.size())
49: return false;
50: for (Enumeration e = bop.keys(); e.hasMoreElements();) {
51: String key = (String) e.nextElement();
52: Object obj = bop.get(key);
53: if (obj == null && this .get(key) != null)
54: return false;
55: else if (obj != null && !obj.equals(this .get(key)))
56: return false;
57: }
58: return true;
59: }
60:
61: public String toString() {
62: String ret = getClass().getName() + ": {";
63: for (Enumeration e = this .keys(); e.hasMoreElements();) {
64: String key = (String) e.nextElement();
65: ret += "[" + key + "=" + this .properties.get(key) + "]";
66: }
67: return ret += "}";
68: }
69:
70: private Hashtable properties = null;
71: }
|