package infosapient.system;
/**
*
* Class FzySystemComponent is the utility superclass for the fuzzy logic portion of
* Black Mesa.
*
* @author: Copyright (c) 1996-2001, Workplace Performance Tools, All Rights Reserved.
* License to use this program is provided under the COMMON PUBLIC LICENSE 0.5
* THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE
* ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
* @version $Revision: 1.1.1.1 $
*
* @package infosapient.system
*/
import java.beans.*;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.FileOutputStream;
import java.util.Hashtable;
import java.util.Vector;
import java.rmi.server.ObjID;
public abstract class FzySystemComponent extends infosapient.system.ObservableImpl
implements java.io.Serializable,
FzySystemInterface {
static final long serialVersionUID = -6200511222693735198L;
static public boolean[] DEBUG_ = new boolean[4];
static public transient PrintWriter trace[] = new PrintWriter[4]; /* debug trace files */
protected ObjID myID;
protected String name = null;
private VetoableChangeSupport vcs = null;
private PropertyChangeSupport pcs = null;
protected FzySystemComponent() {
setID(new ObjID());
/* try {
trace[0] = new PrintWriter(new FileOutputStream("\\projects\\trace0.txt"));
trace[1] = new PrintWriter(new FileOutputStream("\\projects\\trace1.txt"));
trace[2] = new PrintWriter(new FileOutputStream("\\projects\\trace2.txt"));
trace[3] = new PrintWriter(new FileOutputStream("\\projects\\trace3.txt"));
DEBUG_[0] = true;
DEBUG_[1] = true;
DEBUG_[2] = true;
DEBUG_[3] = true;
} catch (java.io.IOException ioe) {
ioe.printStackTrace();
} */
}
public void addPropertyChangeListener(PropertyChangeListener pcl) {
pcs.addPropertyChangeListener(pcl);
}
public void addVetoableChangeListener(VetoableChangeListener vcl){
vcs.addVetoableChangeListener(vcl);
}
/**
* Used for object equality, to make sure no duplicates when adding sets
* to rules, attributes, etc. NOT the same as set equality.
* (I.e. Makes no comparisons to the domain, the membership, etc.)
* @param Object the object being compared.
* @return boolean this object is equal to the object being compared.
*
*/
public boolean equals(Object obj) {
if (obj != null){
if (obj instanceof ObjID) return(myID.equals(obj));
else
if (obj instanceof FzySystemComponent)
return(myID.equals(((FzySystemComponent)obj).getID()));
}
return false;
}
/**
* @return ObjID The unique id for this fuzzySystemComponent.
*/
public ObjID getID() {
return myID;
}
public String getName() {
if (name != null) return name;
else
return getClass().getName();
}
public PropertyChangeSupport getPropertyChangeSupport() {
if (pcs == null) pcs = new PropertyChangeSupport(this);
return pcs;
}
public VetoableChangeSupport getVetoableChangeSupport() {
if (vcs == null) vcs = new VetoableChangeSupport(this);
return vcs;
}
/**
* Used with equals(Object) method for object equality.
* @author Michael McConnell Creation date: (1/18/00 9:40:16 AM)
* @return int
*/
public int hashCode() {
return getID().hashCode();
}
public void printOn(java.io.Writer w, int ntabs) throws java.io.IOException {
StringBuffer sb = new StringBuffer();
for (int tabs = 0; tabs < ntabs; tabs++) sb.append("\t");
sb.append("null: Should have been overridden in: ").append(getClass().getName());
w.write(sb.toString());
}
public void removePropertyChangeListener(PropertyChangeListener pcl) {
pcs.removePropertyChangeListener(pcl);
}
public void removeVetoableChangeListener(VetoableChangeListener vcl){
vcs.removeVetoableChangeListener(vcl);
}
public void setID(ObjID id) { myID = id; }
public void setName(String s){
name = s;
}
}