public class ChemObject extends Object implements Serializable, IChemObject, Cloneable
Constructor and Description |
---|
ChemObject()
Constructs a new IChemObject.
|
ChemObject(IChemObject chemObject)
Constructs a new IChemObject by copying the flags, and the
identifier.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(IChemObjectListener col)
Use this to add yourself to this IChemObject as a listener.
|
void |
addProperties(Map<Object,Object> properties)
Sets the properties of this object.
|
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 mask)
Returns the value of a given flag.
|
boolean[] |
getFlags()
Returns the whole set of flags.
|
Short |
getFlagValue()
Access the internal value used to store the 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.
|
<T> T |
getProperty(Object description)
Returns a property for the IChemObject.
|
<T> T |
getProperty(Object description,
Class<T> c)
Access a property of the given description and cast the specified class.
|
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 mask,
boolean 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)
Set the properties of this object to the provided map (shallow copy).
|
void |
setProperty(Object description,
Object property)
Sets a property for a IChemObject.
|
Object |
shallowCopy()
Clones this
IChemObject , but preserves references to Object s. |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toString
public ChemObject()
public ChemObject(IChemObject chemObject)
chemObject
- the object to copypublic void addListener(IChemObjectListener col)
addListener
in interface IChemObject
col
- the ChemObjectListenerremoveListener(org.openscience.cdk.interfaces.IChemObjectListener)
public int getListenerCount()
getListenerCount
in interface IChemObject
public void removeListener(IChemObjectListener col)
removeListener
in interface IChemObject
col
- The ChemObjectListener to be removedaddListener(org.openscience.cdk.interfaces.IChemObjectListener)
public void notifyChanged()
notifyChanged
in interface IChemObject
public void notifyChanged(IChemObjectChangeEvent evt)
notifyChanged
in interface IChemObject
evt
- A ChemObjectChangeEvent pointing to the source of where
the change happendpublic void setProperty(Object description, Object property)
setProperty
in interface IChemObject
description
- An object description of the property (most likely a
unique string)property
- An object with the property itselfgetProperty(java.lang.Object)
,
removeProperty(java.lang.Object)
public void removeProperty(Object description)
removeProperty
in interface IChemObject
description
- The object description of the property (most likely a
unique string)setProperty(java.lang.Object, java.lang.Object)
,
getProperty(java.lang.Object)
public <T> T getProperty(Object description)
getProperty
in interface IChemObject
T
- generic return typedescription
- An object description of the property (most likely a
unique string)setProperty(java.lang.Object, java.lang.Object)
,
removeProperty(java.lang.Object)
public <T> T getProperty(Object description, Class<T> c)
IAtom atom = new Atom("C");
atom.setProperty("number", 1); // set an integer property
// access the property and automatically cast to an int
Integer number = atom.getProperty("number");
// if the method is in a chain or needs to be nested the type
// can be provided
methodAcceptingInt(atom.getProperty("number", Integer.class));
// the type cannot be checked and so...
String number = atom.getProperty("number"); // ClassCastException
// if the type is provided a more meaningful error is thrown
atom.getProperty("number", String.class); // IllegalArgumentException
getProperty
in interface IChemObject
T
- generic type (of provided class)description
- description of a property (normally a string)c
- type of the value to be returnedIChemObject.getProperty(Object)
,
IChemObject.addProperties(java.util.Map)
public Map<Object,Object> getProperties()
getProperties
in interface IChemObject
addProperties(java.util.Map<java.lang.Object, java.lang.Object>)
public Object clone() throws CloneNotSupportedException
IChemObject
. It clones the identifier, flags,
properties and pointer vectors. The ChemObjectListeners are not cloned, and
neither is the content of the pointer vectors.clone
in interface IChemObject
clone
in class Object
CloneNotSupportedException
- if the IChemObject cannot be clonedpublic boolean compare(Object object)
object
- Object of type AtomTypepublic String getID()
getID
in interface IChemObject
setID(java.lang.String)
public void setID(String identifier)
setID
in interface IChemObject
identifier
- a String representing the ID valuegetID()
public void setFlag(int mask, boolean value)
CDKConstants.ISAROMATIC
or CDKConstants.VISITED
). The flags are
intrinsic internal properties and should not be used to store custom
values, please use IChemObject.setProperty(Object, Object)
.
// set this chem object to be aromatic
chemObject.setFlag(CDKConstants.ISAROMATIC, Boolean.TRUE);
// ...
// indicate we have visited this chem object
chemObject.setFlag(CDKConstants.VISITED, Boolean.TRUE);
setFlag
in interface IChemObject
mask
- flag to set the value forvalue
- value to assign to flagIChemObject.getFlag(int)
,
CDKConstants
public boolean getFlag(int mask)
CDKConstants.ISAROMATIC
).
if(chemObject.getFlag(CDKConstants.ISAROMATIC)){
// handle aromatic flag on this chem object
}
getFlag
in interface IChemObject
mask
- flag to retrieve the value offlag_type
is setIChemObject.setFlag(int, boolean)
,
CDKConstants
public Short getFlagValue()
getFlagValue
in interface IChemObject
public void setProperties(Map<Object,Object> properties)
setProperties
in interface IChemObject
properties
- map key-value pairspublic void addProperties(Map<Object,Object> properties)
addProperties
in interface IChemObject
properties
- a Hashtable specifying the property valuesgetProperties()
public void setFlags(boolean[] flagsNew)
IChemObject.setFlag(int, boolean)
for each value in the array and
use CDKConstants.FLAG_MASKS
to look
up the correct mask. If only a single flag is being set it is a lot
faster to use IChemObject.setFlag(int, boolean)
.setFlags
in interface IChemObject
flagsNew
- the new flags to set.IChemObject.setFlag(int, boolean)
,
IChemObject.getFlags()
public boolean[] getFlags()
IChemObject.getFlagValue()
if you need all the flags. For individual flags please use IChemObject.getFlag(int)
getFlags
in interface IChemObject
IChemObject.setFlags(boolean[])
,
IChemObject.getFlag(int)
,
IChemObject.getFlagValue()
public Object shallowCopy()
IChemObject
, but preserves references to Object
s.clone()
public IChemObjectBuilder getBuilder()
ICDKObject
IChemObjectBuilder
for the data classes that extend
this class.getBuilder
in interface ICDKObject
IChemObjectBuilder
matching this ICDKObject
public void setNotification(boolean bool)
IChemObject
setNotification
in interface IChemObject
bool
- if true, then notification messages are sent.IChemObject.getNotification()
public boolean getNotification()
IChemObject
getNotification
in interface IChemObject
IChemObject.setNotification(boolean)
Copyright © 2018. All Rights Reserved.