org.openscience.cdk
Class ChemObject

java.lang.Object
  extended by org.openscience.cdk.ChemObject
All Implemented Interfaces:
Serializable, Cloneable, ICDKObject, IChemObject
Direct Known Subclasses:
AtomContainer, AtomContainerSet, ChemFile, ChemModel, ChemSequence, DebugChemObject, ElectronContainer, Element, Mapping, PDBStructure, Reaction, ReactionSet

public class ChemObject
extends Object
implements Serializable, IChemObject, Cloneable

The base class for all chemical objects in this cdk. It provides methods for adding listeners and for their notification of events, as well a a hash table for administration of physical or chemical properties

Author:
steinbeck
See Also:
Serialized Form
Belongs to CDK module:
data
Source code:
cdk-1.4.x

Constructor Summary
ChemObject()
          Constructs a new IChemObject.
ChemObject(IChemObject chemObject)
          Constructs a new IChemObject by copying the flags, and the identifier.
 
Method Summary
 void addListener(IChemObjectListener col)
          Use this to add yourself to this IChemObject as a listener.
 Object clone()
          Clones this IChemObject.
 boolean compare(Object object)
          Compares a IChemObject with this IChemObject.
 IChemObjectBuilder getBuilder()
          Returns a IChemObjectBuilder for the data classes that extend this class.
 boolean getFlag(int flag_type)
          Returns the value of some flag.
 boolean[] getFlags()
          Returns the whole set of flags.
 String getID()
          Returns the identifier (ID) of this object.
 int getListenerCount()
          Returns the number of ChemObjectListeners registered with this object.
 boolean getNotification()
          Returns the flag that indicates whether notification messages are sent around.
 Map<Object,Object> getProperties()
          Returns a Map with the IChemObject's properties.
 Object getProperty(Object description)
          Returns a property for the IChemObject.
 void notifyChanged()
          This should be triggered by an method that changes the content of an object to that the registered listeners can react to it.
 void notifyChanged(IChemObjectChangeEvent evt)
          This should be triggered by an method that changes the content of an object to that the registered listeners can react to it.
 void removeListener(IChemObjectListener col)
          Use this to remove a ChemObjectListener from the ListenerList of this IChemObject.
 void removeProperty(Object description)
          Removes a property for a IChemObject.
 void setFlag(int flag_type, boolean flag_value)
          Sets the value of some flag.
 void setFlags(boolean[] flagsNew)
          Sets the whole set of flags.
 void setID(String identifier)
          Sets the identifier (ID) of this object.
 void setNotification(boolean bool)
          Set a flag to use or not use notification.
 void setProperties(Map<Object,Object> properties)
          Sets the properties of this object.
 void setProperty(Object description, Object property)
          Sets a property for a IChemObject.
 Object shallowCopy()
          Clones this IChemObject, but preserves references to Objects.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openscience.cdk.interfaces.IChemObject
toString
 

Constructor Detail

ChemObject

public ChemObject()
Constructs a new IChemObject.


ChemObject

public ChemObject(IChemObject chemObject)
Constructs a new IChemObject by copying the flags, and the identifier. It does not copy the listeners and properties.

Parameters:
chemObject - the object to copy
Method Detail

addListener

public void addListener(IChemObjectListener col)
Use this to add yourself to this IChemObject as a listener. In order to do so, you must implement the ChemObjectListener Interface.

Specified by:
addListener in interface IChemObject
Parameters:
col - the ChemObjectListener
See Also:
removeListener(org.openscience.cdk.interfaces.IChemObjectListener)

getListenerCount

public int getListenerCount()
Returns the number of ChemObjectListeners registered with this object.

Specified by:
getListenerCount in interface IChemObject
Returns:
the number of registered listeners.

removeListener

public void removeListener(IChemObjectListener col)
Use this to remove a ChemObjectListener from the ListenerList of this IChemObject. It will then not be notified of change in this object anymore.

Specified by:
removeListener in interface IChemObject
Parameters:
col - The ChemObjectListener to be removed
See Also:
addListener(org.openscience.cdk.interfaces.IChemObjectListener)

notifyChanged

public void notifyChanged()
This should be triggered by an method that changes the content of an object to that the registered listeners can react to it.

Specified by:
notifyChanged in interface IChemObject

notifyChanged

public void notifyChanged(IChemObjectChangeEvent evt)
This should be triggered by an method that changes the content of an object to that the registered listeners can react to it. This is a version of notifyChanged() which allows to propagate a change event while preserving the original origin.

Specified by:
notifyChanged in interface IChemObject
Parameters:
evt - A ChemObjectChangeEvent pointing to the source of where the change happend

setProperty

public void setProperty(Object description,
                        Object property)
Sets a property for a IChemObject.

Specified by:
setProperty in interface IChemObject
Parameters:
description - An object description of the property (most likely a unique string)
property - An object with the property itself
See Also:
getProperty(java.lang.Object), removeProperty(java.lang.Object)

removeProperty

public void removeProperty(Object description)
Removes a property for a IChemObject.

Specified by:
removeProperty in interface IChemObject
Parameters:
description - The object description of the property (most likely a unique string)
See Also:
setProperty(java.lang.Object, java.lang.Object), getProperty(java.lang.Object)

getProperty

public Object getProperty(Object description)
Returns a property for the IChemObject.

Specified by:
getProperty in interface IChemObject
Parameters:
description - An object description of the property (most likely a unique string)
Returns:
The object containing the property. Returns null if propert is not set.
See Also:
setProperty(java.lang.Object, java.lang.Object), removeProperty(java.lang.Object)

getProperties

public Map<Object,Object> getProperties()
Returns a Map with the IChemObject's properties.

Specified by:
getProperties in interface IChemObject
Returns:
The object's properties as an Hashtable
See Also:
setProperties(java.util.Map)

clone

public Object clone()
             throws CloneNotSupportedException
Clones this IChemObject. It clones the identifier, flags, properties and pointer vectors. The ChemObjectListeners are not cloned, and neither is the content of the pointer vectors.

Specified by:
clone in interface IChemObject
Overrides:
clone in class Object
Returns:
The cloned object
Throws:
CloneNotSupportedException - if the IChemObject cannot be cloned

compare

public boolean compare(Object object)
Compares a IChemObject with this IChemObject.

Parameters:
object - Object of type AtomType
Returns:
true if the atom types are equal

getID

public String getID()
Returns the identifier (ID) of this object.

Specified by:
getID in interface IChemObject
Returns:
a String representing the ID value
See Also:
setID(java.lang.String)

setID

public void setID(String identifier)
Sets the identifier (ID) of this object.

Specified by:
setID in interface IChemObject
Parameters:
identifier - a String representing the ID value
See Also:
getID()

setFlag

public void setFlag(int flag_type,
                    boolean flag_value)
Sets the value of some flag.

Specified by:
setFlag in interface IChemObject
Parameters:
flag_type - Flag to set
flag_value - Value to assign to flag
See Also:
getFlag(int)

getFlag

public boolean getFlag(int flag_type)
Returns the value of some flag.

Specified by:
getFlag in interface IChemObject
Parameters:
flag_type - Flag to retrieve the value of
Returns:
true if the flag flag_type is set
See Also:
setFlag(int, boolean)

setProperties

public void setProperties(Map<Object,Object> properties)
Sets the properties of this object.

Specified by:
setProperties in interface IChemObject
Parameters:
properties - a Hashtable specifying the property values
See Also:
getProperties()

setFlags

public void setFlags(boolean[] flagsNew)
Sets the whole set of flags.

Specified by:
setFlags in interface IChemObject
Parameters:
flagsNew - the new flags.
See Also:
getFlags()

getFlags

public boolean[] getFlags()
Returns the whole set of flags.

Specified by:
getFlags in interface IChemObject
Returns:
the flags.
See Also:
setFlags(boolean[])

shallowCopy

public Object shallowCopy()
Clones this IChemObject, but preserves references to Objects.

Returns:
Shallow copy of this IChemObject
See Also:
clone()

getBuilder

public IChemObjectBuilder getBuilder()
Description copied from interface: ICDKObject
Returns a IChemObjectBuilder for the data classes that extend this class.

Specified by:
getBuilder in interface ICDKObject
Returns:
The IChemObjectBuilder matching this ICDKObject

setNotification

public void setNotification(boolean bool)
Description copied from interface: IChemObject
Set a flag to use or not use notification. By default it should be set to true.

Specified by:
setNotification in interface IChemObject
Parameters:
bool - if true, then notification messages are sent.
See Also:
IChemObject.getNotification()

getNotification

public boolean getNotification()
Description copied from interface: IChemObject
Returns the flag that indicates whether notification messages are sent around.

Specified by:
getNotification in interface IChemObject
Returns:
true if messages are sent.
See Also:
IChemObject.setNotification(boolean)