package com.jat.business;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
import java.io.Serializable;
/**
* <p>Title: JAT</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
* <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
* @author stf
* @version 1.2
* @since 1.0
*/
public class BusinessObjectProperties implements Serializable {
public BusinessObjectProperties() {
this.properties = new Properties();
}
public Object get(String field) {
return this.properties.get(field.toUpperCase());
}
public Object put(String field, Object obj) {
return this.properties.put(field.toUpperCase(), obj);
}
public Object remove(String field) {
return this.properties.remove(field);
}
public Enumeration keys() {
return this.properties.keys();
}
public boolean equals(Object other) {
if (other == this) return true;
if (other == null) return false;
if (getClass() != other.getClass()) return false;
BusinessObjectProperties bop = (BusinessObjectProperties)other;
if (bop.properties.size() != this.properties.size()) return false;
for (Enumeration e = bop.keys(); e.hasMoreElements();) {
String key = (String)e.nextElement();
Object obj = bop.get(key);
if (obj==null && this.get(key)!=null) return false;
else if (obj!=null && !obj.equals(this.get(key))) return false;
}
return true;
}
public String toString() {
String ret = getClass().getName()+": {";
for(Enumeration e = this.keys(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
ret += "["+key+"="+this.properties.get(key)+"]";
}
return ret+="}";
}
private Hashtable properties = null;
}
|