Package org.openscience.cdk
Class AtomRef
- java.lang.Object
-
- org.openscience.cdk.AtomRef
-
- All Implemented Interfaces:
Cloneable
,IAtom
,IAtomType
,ICDKObject
,IChemObject
,IElement
,IIsotope
public class AtomRef extends Object implements IAtom
An atom ref, references a CDKIAtom
indirectly. All methods are passed through to the referenced atom. The reference can be used to override the behaviour of the base atom.- Author:
- John Mayfield
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openscience.cdk.interfaces.IAtomType
IAtomType.Hybridization
-
-
Field Summary
-
Fields inherited from interface org.openscience.cdk.interfaces.IElement
Ac, Ag, Al, Am, Ar, As, At, Au, B, Ba, Be, Bh, Bi, Bk, Br, C, Ca, Cd, Ce, Cf, Cl, Cm, Cn, Co, Cr, Cs, Cu, Db, Ds, Dy, Er, Es, Eu, F, Fe, Fl, Fm, Fr, Ga, Gd, Ge, H, He, Hf, Hg, Ho, Hs, I, In, Ir, K, Kr, La, Li, Lr, Lu, Lv, Mc, Md, Mg, Mn, Mo, Mt, N, Na, Nb, Nd, Ne, Nh, Ni, No, Np, O, Og, Os, P, Pa, Pb, Pd, Pm, Po, Pr, Pt, Pu, Ra, Rb, Re, Rf, Rg, Rh, Rn, Ru, S, Sb, Sc, Se, Sg, Si, Sm, Sn, Sr, Ta, Tb, Tc, Te, Th, Ti, Tl, Tm, Ts, U, V, W, Wildcard, Xe, Y, Yb, Zn, Zr
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(IChemObjectListener col)
Use this to add yourself to this IChemObject as a listener.void
addProperties(Map<Object,Object> properties)
Add properties to this object, duplicate keys will replace any existing value.Iterable<IBond>
bonds()
Returns the bonds connected to this atom.IAtom
clone()
Returns a deep clone of this IChemObject.IAtom
deref()
Dereference the atom pointer once providing access to the base atom.static IAtom
deref(IAtom atom)
Utility method to dereference an atom.boolean
equals(Object obj)
Integer
getAtomicNumber()
Returns the atomic number of this element.String
getAtomTypeName()
Gets the id attribute of the AtomType object.IBond
getBond(IAtom atom)
Returns the bond connecting 'this' atom to the provided atom.int
getBondCount()
Get the number of explicit bonds connected to this atom.Double
getBondOrderSum()
Gets the bondOrderSum attribute of the AtomType object.IChemObjectBuilder
getBuilder()
Returns aIChemObjectBuilder
for the data classes that extend this class.Double
getCharge()
Returns the partial charge of this atom.IAtomContainer
getContainer()
Access theIAtomContainer
of which this atom is a member of.Double
getCovalentRadius()
Returns the covalent radius for this AtomType.Double
getExactMass()
Gets the ExactMass attribute of the Isotope object.boolean
getFlag(int mask)
Returns the value of a given flag.boolean[]
getFlags()
Returns the whole set of flags.Number
getFlagValue()
Access the internal value used to store the flags.Integer
getFormalCharge()
Returns the formal charge of this atom.Integer
getFormalNeighbourCount()
Returns the formal neighbour count of this atom.javax.vecmath.Point3d
getFractionalPoint3d()
Returns a point specifying the location of this atom in a Crystal unit cell.IAtomType.Hybridization
getHybridization()
Returns the hybridization of this atom.String
getID()
Returns the identifier (ID) of this object.Integer
getImplicitHydrogenCount()
Returns the implicit hydrogen count of this atom.int
getIndex()
Acces the index of an atom in the context of anIAtomContainer
.int
getListenerCount()
Returns the number of ChemObjectListeners registered with this object.int
getMapIdx()
Access the map index for this atom.Integer
getMassNumber()
Returns the atomic mass of this element.IBond.Order
getMaxBondOrder()
Gets the MaxBondOrder attribute of the AtomType object.Double
getNaturalAbundance()
Gets the NaturalAbundance attribute of the Isotope object.boolean
getNotification()
Returns the flag that indicates whether notification messages are sent around.javax.vecmath.Point2d
getPoint2d()
Returns a point specifying the location of this atom in a 2D space.javax.vecmath.Point3d
getPoint3d()
Returns a point specifying the location of this atom in a 3D space.Map<Object,Object>
getProperties()
Returns a Map with the IChemObject's properties.<T> T
getProperty(Object description)
Returns a property for the IChemObject - the object is automatically cast to the required type.<T> T
getProperty(Object description, Class<T> c)
Access a property of the given description and cast the specified class.Integer
getStereoParity()
Returns the stereo parity of this atom.String
getSymbol()
Returns the element symbol of this element.Integer
getValency()
Gets the the exact electron valency of the AtomType object.int
hashCode()
boolean
isAromatic()
Access whether this atom has been marked as aromatic.boolean
isInRing()
Access whether this atom has been flagged as in a ring.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
setAtomicNumber(Integer atomicNumber)
Sets the atomic number of this element.void
setAtomTypeName(String identifier)
Sets the if attribute of the AtomType object.void
setBondOrderSum(Double bondOrderSum)
Sets the the exact bond order sum attribute of the AtomType object.void
setCharge(Double charge)
Sets the partial charge of this atom.void
setCovalentRadius(Double radius)
Sets the covalent radius for this AtomType.void
setExactMass(Double exactMass)
Sets the ExactMass attribute of the Isotope object.void
setFlag(int mask, boolean value)
Sets the value of some flag.void
setFlags(boolean[] newFlags)
Sets the whole set of flags.void
setFormalCharge(Integer charge)
Sets the formal charge of this atom.void
setFormalNeighbourCount(Integer count)
Sets the formal neighbour count of this atom.void
setFractionalPoint3d(javax.vecmath.Point3d point3d)
Sets a point specifying the location of this atom in a Crystal unit cell.void
setHybridization(IAtomType.Hybridization hybridization)
Sets the hybridization of this atom.void
setID(String identifier)
Sets the identifier (ID) of this object.void
setImplicitHydrogenCount(Integer hydrogenCount)
Sets the implicit hydrogen count of this atom.void
setIsAromatic(boolean arom)
Mark this atom as being aromatic.void
setIsInRing(boolean ring)
Mark this atom as being in a ring.void
setMapIdx(int mapidx)
Set the map index for this atom.void
setMassNumber(Integer massNumber)
Sets the atomic mass of this element.void
setMaxBondOrder(IBond.Order maxBondOrder)
Sets the MaxBondOrder attribute of the AtomType object.void
setNaturalAbundance(Double naturalAbundance)
Sets the NaturalAbundance attribute of the Isotope object.void
setNotification(boolean bool)
Set a flag to use or not use notification.void
setPoint2d(javax.vecmath.Point2d point2d)
Sets a point specifying the location of this atom in a 2D space.void
setPoint3d(javax.vecmath.Point3d point3d)
Sets a point specifying the location of this atom in 3D space.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.void
setStereoParity(Integer stereoParity)
Sets the stereo parity for this atom.void
setSymbol(String symbol)
Sets the element symbol of this element.void
setValency(Integer valency)
Sets the the exact electron valency of the AtomType object.String
toString()
Returns a one line description of this IChemObject.-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openscience.cdk.interfaces.ICDKObject
getBuilder
-
Methods inherited from interface org.openscience.cdk.interfaces.IChemObject
addListener, addProperties, getFlag, getFlags, getFlagValue, getID, getListenerCount, getNotification, getProperties, getProperty, getProperty, notifyChanged, notifyChanged, removeListener, removeProperty, setFlag, setFlags, setID, setNotification, setProperties, setProperty
-
-
-
-
Constructor Detail
-
AtomRef
public AtomRef(IAtom atom)
Create a pointer for the provided atom.- Parameters:
atom
- the atom to reference
-
-
Method Detail
-
deref
public static IAtom deref(IAtom atom)
Utility method to dereference an atom. If the atom is not anAtomRef
it simply returns the input.- Parameters:
atom
- the atom- Returns:
- non-pointer atom
-
deref
public IAtom deref()
Dereference the atom pointer once providing access to the base atom.- Returns:
- the atom pointed to
-
getCharge
public Double getCharge()
Returns the partial charge of this atom.- Specified by:
getCharge
in interfaceIAtom
- Returns:
- the charge of this atom
- See Also:
IAtom.setCharge(java.lang.Double)
-
setCharge
public void setCharge(Double charge)
Sets the partial charge of this atom.- Specified by:
setCharge
in interfaceIAtom
- Parameters:
charge
- The partial charge- See Also:
IAtom.getCharge()
-
getAtomicNumber
public Integer getAtomicNumber()
Returns the atomic number of this element.Once instantiated all field not filled by passing parameters to the constructor are null. Elements can be configured by using the IsotopeFactory.configure() method:
Element element = new Element("C"); IsotopeFactory if = IsotopeFactory.getInstance(element.getNewBuilder()); if.configure(element);
- Specified by:
getAtomicNumber
in interfaceIElement
- Returns:
- The atomic number of this element
- See Also:
IElement.setAtomicNumber(java.lang.Integer)
-
setAtomicNumber
public void setAtomicNumber(Integer atomicNumber)
Sets the atomic number of this element.- Specified by:
setAtomicNumber
in interfaceIElement
- Parameters:
atomicNumber
- The atomic mass to be assigned to this element- See Also:
IElement.getAtomicNumber()
-
getNaturalAbundance
public Double getNaturalAbundance()
Gets the NaturalAbundance attribute of the Isotope object. Returns null when unconfigured.- Specified by:
getNaturalAbundance
in interfaceIIsotope
- Returns:
- The NaturalAbundance value
- See Also:
IIsotope.setNaturalAbundance(java.lang.Double)
-
setNaturalAbundance
public void setNaturalAbundance(Double naturalAbundance)
Sets the NaturalAbundance attribute of the Isotope object.- Specified by:
setNaturalAbundance
in interfaceIIsotope
- Parameters:
naturalAbundance
- The new NaturalAbundance value- See Also:
IIsotope.getNaturalAbundance()
-
getImplicitHydrogenCount
public Integer getImplicitHydrogenCount()
Returns the implicit hydrogen count of this atom.- Specified by:
getImplicitHydrogenCount
in interfaceIAtom
- Returns:
- The hydrogen count of this atom.
- See Also:
IAtom.setImplicitHydrogenCount(java.lang.Integer)
-
setImplicitHydrogenCount
public void setImplicitHydrogenCount(Integer hydrogenCount)
Sets the implicit hydrogen count of this atom.- Specified by:
setImplicitHydrogenCount
in interfaceIAtom
- Parameters:
hydrogenCount
- The number of hydrogen atoms bonded to this atom.- See Also:
IAtom.getImplicitHydrogenCount()
-
getExactMass
public Double getExactMass()
Gets the ExactMass attribute of the Isotope object. Returns null when unconfigured.- Specified by:
getExactMass
in interfaceIIsotope
- Returns:
- The ExactMass value
- See Also:
IIsotope.setExactMass(java.lang.Double)
-
setExactMass
public void setExactMass(Double exactMass)
Sets the ExactMass attribute of the Isotope object.- Specified by:
setExactMass
in interfaceIIsotope
- Parameters:
exactMass
- The new ExactMass value- See Also:
IIsotope.getExactMass()
-
getSymbol
public String getSymbol()
Returns the element symbol of this element.- Specified by:
getSymbol
in interfaceIElement
- Returns:
- The element symbol of this element. Null if unset.
- See Also:
IElement.setSymbol(java.lang.String)
-
setSymbol
public void setSymbol(String symbol)
Sets the element symbol of this element.- Specified by:
setSymbol
in interfaceIElement
- Parameters:
symbol
- The element symbol to be assigned to this atom- See Also:
IElement.getSymbol()
-
getMassNumber
public Integer getMassNumber()
Returns the atomic mass of this element. Returns null when unconfigured.- Specified by:
getMassNumber
in interfaceIIsotope
- Returns:
- The atomic mass of this element
- See Also:
IIsotope.setMassNumber(Integer)
-
setMassNumber
public void setMassNumber(Integer massNumber)
Sets the atomic mass of this element.- Specified by:
setMassNumber
in interfaceIIsotope
- Parameters:
massNumber
- The atomic mass to be assigned to this element- See Also:
IIsotope.getMassNumber()
-
getAtomTypeName
public String getAtomTypeName()
Gets the id attribute of the AtomType object.- Specified by:
getAtomTypeName
in interfaceIAtomType
- Returns:
- The id value
- See Also:
IAtomType.setAtomTypeName(java.lang.String)
-
setAtomTypeName
public void setAtomTypeName(String identifier)
Sets the if attribute of the AtomType object.- Specified by:
setAtomTypeName
in interfaceIAtomType
- Parameters:
identifier
- The new AtomTypeID value. Null if unset.- See Also:
IAtomType.getAtomTypeName()
-
getMaxBondOrder
public IBond.Order getMaxBondOrder()
Gets the MaxBondOrder attribute of the AtomType object.- Specified by:
getMaxBondOrder
in interfaceIAtomType
- Returns:
- The MaxBondOrder value
- See Also:
IAtomType.setMaxBondOrder(org.openscience.cdk.interfaces.IBond.Order)
-
setMaxBondOrder
public void setMaxBondOrder(IBond.Order maxBondOrder)
Sets the MaxBondOrder attribute of the AtomType object.- Specified by:
setMaxBondOrder
in interfaceIAtomType
- Parameters:
maxBondOrder
- The new MaxBondOrder value- See Also:
IAtomType.getMaxBondOrder()
-
getBondOrderSum
public Double getBondOrderSum()
Gets the bondOrderSum attribute of the AtomType object.- Specified by:
getBondOrderSum
in interfaceIAtomType
- Returns:
- The bondOrderSum value
- See Also:
IAtomType.setBondOrderSum(java.lang.Double)
-
setBondOrderSum
public void setBondOrderSum(Double bondOrderSum)
Sets the the exact bond order sum attribute of the AtomType object.- Specified by:
setBondOrderSum
in interfaceIAtomType
- Parameters:
bondOrderSum
- The new bondOrderSum value- See Also:
IAtomType.getBondOrderSum()
-
getPoint2d
public javax.vecmath.Point2d getPoint2d()
Returns a point specifying the location of this atom in a 2D space.- Specified by:
getPoint2d
in interfaceIAtom
- Returns:
- A point in a 2D plane. Null if unset.
- See Also:
IAtom.setPoint2d(javax.vecmath.Point2d)
-
setPoint2d
public void setPoint2d(javax.vecmath.Point2d point2d)
Sets a point specifying the location of this atom in a 2D space.- Specified by:
setPoint2d
in interfaceIAtom
- Parameters:
point2d
- A point in a 2D plane- See Also:
IAtom.getPoint2d()
-
getPoint3d
public javax.vecmath.Point3d getPoint3d()
Returns a point specifying the location of this atom in a 3D space.- Specified by:
getPoint3d
in interfaceIAtom
- Returns:
- A point in 3-dimensional space. Null if unset.
- See Also:
IAtom.setPoint3d(javax.vecmath.Point3d)
-
setPoint3d
public void setPoint3d(javax.vecmath.Point3d point3d)
Sets a point specifying the location of this atom in 3D space.- Specified by:
setPoint3d
in interfaceIAtom
- Parameters:
point3d
- A point in a 3-dimensional space- See Also:
IAtom.getPoint3d()
-
getFormalCharge
public Integer getFormalCharge()
Returns the formal charge of this atom.- Specified by:
getFormalCharge
in interfaceIAtomType
- Returns:
- the formal charge of this atom
- See Also:
IAtomType.setFormalCharge(java.lang.Integer)
-
setFormalCharge
public void setFormalCharge(Integer charge)
Sets the formal charge of this atom.- Specified by:
setFormalCharge
in interfaceIAtomType
- Parameters:
charge
- The formal charge- See Also:
IAtomType.getFormalCharge()
-
getFractionalPoint3d
public javax.vecmath.Point3d getFractionalPoint3d()
Returns a point specifying the location of this atom in a Crystal unit cell.- Specified by:
getFractionalPoint3d
in interfaceIAtom
- Returns:
- A point in 3d fractional unit cell space. Null if unset.
- See Also:
IAtom.setFractionalPoint3d(javax.vecmath.Point3d)
,for predefined values.
-
setFractionalPoint3d
public void setFractionalPoint3d(javax.vecmath.Point3d point3d)
Sets a point specifying the location of this atom in a Crystal unit cell.- Specified by:
setFractionalPoint3d
in interfaceIAtom
- Parameters:
point3d
- A point in a 3d fractional unit cell space- See Also:
IAtom.getFractionalPoint3d()
,Crystal
-
getFormalNeighbourCount
public Integer getFormalNeighbourCount()
Returns the formal neighbour count of this atom.- Specified by:
getFormalNeighbourCount
in interfaceIAtomType
- Returns:
- the formal neighbour count of this atom
- See Also:
IAtomType.setFormalNeighbourCount(java.lang.Integer)
-
setFormalNeighbourCount
public void setFormalNeighbourCount(Integer count)
Sets the formal neighbour count of this atom.- Specified by:
setFormalNeighbourCount
in interfaceIAtomType
- Parameters:
count
- The neighbour count- See Also:
IAtomType.getFormalNeighbourCount()
-
getStereoParity
public Integer getStereoParity()
Returns the stereo parity of this atom. It uses the predefined values found in CDKConstants.- Specified by:
getStereoParity
in interfaceIAtom
- Returns:
- The stereo parity for this atom
- See Also:
CDKConstants
,IAtom.setStereoParity(java.lang.Integer)
-
setStereoParity
public void setStereoParity(Integer stereoParity)
Sets the stereo parity for this atom.- Specified by:
setStereoParity
in interfaceIAtom
- Parameters:
stereoParity
- The stereo parity for this atom- See Also:
for predefined values.
,IAtom.getStereoParity()
-
getHybridization
public IAtomType.Hybridization getHybridization()
Returns the hybridization of this atom.- Specified by:
getHybridization
in interfaceIAtomType
- Returns:
- the hybridization of this atom
- See Also:
IAtomType.setHybridization(org.openscience.cdk.interfaces.IAtomType.Hybridization)
-
setHybridization
public void setHybridization(IAtomType.Hybridization hybridization)
Sets the hybridization of this atom.- Specified by:
setHybridization
in interfaceIAtomType
- Parameters:
hybridization
- The hybridization- See Also:
IAtomType.getHybridization()
-
getCovalentRadius
public Double getCovalentRadius()
Returns the covalent radius for this AtomType.- Specified by:
getCovalentRadius
in interfaceIAtomType
- Returns:
- The covalent radius for this AtomType
- See Also:
IAtomType.setCovalentRadius(java.lang.Double)
-
setCovalentRadius
public void setCovalentRadius(Double radius)
Sets the covalent radius for this AtomType.- Specified by:
setCovalentRadius
in interfaceIAtomType
- Parameters:
radius
- The covalent radius for this AtomType- See Also:
IAtomType.getCovalentRadius()
-
getContainer
public IAtomContainer getContainer()
Access theIAtomContainer
of which this atom is a member of. Because atoms can be in multiple molecules this method will only work if the atom has been accessed in the context of anIAtomContainer
, for example:IAtomContainer mol = new AtomContainer(); IAtom atom = new Atom(6); atom.getContainer(); // null mol.add(atom); atom.getContainer(); // still null mol.getAtom(0).getContainer(); // not-null, returns 'mol'
- Specified by:
getContainer
in interfaceIAtom
- Returns:
- the atom container or null if not accessed in the context of a container
-
getIndex
public int getIndex()
Acces the index of an atom in the context of anIAtomContainer
. If the index is not known, < 0 is returned.
-
getValency
public Integer getValency()
Gets the the exact electron valency of the AtomType object.- Specified by:
getValency
in interfaceIAtomType
- Returns:
- The valency value
- See Also:
IAtomType.setValency(Integer)
-
setValency
public void setValency(Integer valency)
Sets the the exact electron valency of the AtomType object.- Specified by:
setValency
in interfaceIAtomType
- Parameters:
valency
- The new valency value- See Also:
IAtomType.getValency()
-
bonds
public Iterable<IBond> bonds()
Description copied from interface:IAtom
Returns the bonds connected to this atom. If the bonds are not known an exception is thrown. This method will only throw an exception ifIAtom.getIndex()
returns < 0 orIAtom.getContainer()
returns null.IAtom atom = ...; if (atom.getIndex() >= 0) { for (IBond bond : atom.bonds()) { } } if (atom.getContainer() != null) { for (IBond bond : atom.bonds()) { } } IAtomContainer mol = ...; // guaranteed not throw an exception for (IBond bond : mol.getAtom(i).bonds()) { }
-
getBondCount
public int getBondCount()
Description copied from interface:IAtom
Get the number of explicit bonds connected to this atom.- Specified by:
getBondCount
in interfaceIAtom
- Returns:
- the total bond count
-
getBond
public IBond getBond(IAtom atom)
Returns the bond connecting 'this' atom to the provided atom. If the atoms are not bonded, null is returned.
-
isAromatic
public boolean isAromatic()
Access whether this atom has been marked as aromatic. The default value is false and you must explicitly perceive aromaticity with one of the available models.- Specified by:
isAromatic
in interfaceIAtom
- Returns:
- aromatic status
- See Also:
IChemObject.getFlag(int)
,Aromaticity
-
setIsAromatic
public void setIsAromatic(boolean arom)
Mark this atom as being aromatic.- Specified by:
setIsAromatic
in interfaceIAtom
- Parameters:
arom
- aromatic status- See Also:
IChemObject.setFlag(int, boolean)
-
isInRing
public boolean isInRing()
Access whether this atom has been flagged as in a ring. The default value is false and you must explicitly find rings first.- Specified by:
isInRing
in interfaceIAtom
- Returns:
- ring status
- See Also:
IChemObject.getFlag(int)
,RingSearch
-
setIsInRing
public void setIsInRing(boolean ring)
Mark this atom as being in a ring.- Specified by:
setIsInRing
in interfaceIAtom
- Parameters:
ring
- ring status- See Also:
IChemObject.setFlag(int, boolean)
-
getMapIdx
public int getMapIdx()
Description copied from interface:IAtom
Access the map index for this atom.
-
setMapIdx
public void setMapIdx(int mapidx)
Description copied from interface:IAtom
Set the map index for this atom.
-
clone
public IAtom clone() throws CloneNotSupportedException
Returns a deep clone of this IChemObject.- Specified by:
clone
in interfaceIAtom
- Specified by:
clone
in interfaceIChemObject
- Returns:
- Object the clone of this IChemObject.
- Throws:
CloneNotSupportedException
- if the IChemObject cannot be cloned
-
toString
public String toString()
Description copied from interface:IChemObject
Returns a one line description of this IChemObject.- Specified by:
toString
in interfaceIChemObject
- Overrides:
toString
in classObject
- Returns:
- a String representation of this object
-
getBuilder
public IChemObjectBuilder getBuilder()
Returns aIChemObjectBuilder
for the data classes that extend this class.- Specified by:
getBuilder
in interfaceICDKObject
- Returns:
- The
IChemObjectBuilder
matching thisICDKObject
-
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 interfaceIChemObject
- Parameters:
col
- the ChemObjectListener- See Also:
IChemObject.removeListener(org.openscience.cdk.interfaces.IChemObjectListener)
-
getListenerCount
public int getListenerCount()
Returns the number of ChemObjectListeners registered with this object.- Specified by:
getListenerCount
in interfaceIChemObject
- 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 interfaceIChemObject
- Parameters:
col
- The ChemObjectListener to be removed- See Also:
IChemObject.addListener(org.openscience.cdk.interfaces.IChemObjectListener)
-
setNotification
public void setNotification(boolean bool)
Set a flag to use or not use notification. By default it should be set to true.- Specified by:
setNotification
in interfaceIChemObject
- Parameters:
bool
- if true, then notification messages are sent.- See Also:
IChemObject.getNotification()
-
getNotification
public boolean getNotification()
Returns the flag that indicates whether notification messages are sent around.- Specified by:
getNotification
in interfaceIChemObject
- Returns:
- true if messages are sent.
- See Also:
IChemObject.setNotification(boolean)
-
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 interfaceIChemObject
-
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 interfaceIChemObject
- 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 interfaceIChemObject
- Parameters:
description
- An object description of the property (most likely a unique string)property
- An object with the property itself- See Also:
IChemObject.getProperty(java.lang.Object)
,IChemObject.removeProperty(java.lang.Object)
-
removeProperty
public void removeProperty(Object description)
Removes a property for a IChemObject.- Specified by:
removeProperty
in interfaceIChemObject
- Parameters:
description
- The object description of the property (most likely a unique string)- See Also:
IChemObject.setProperty(java.lang.Object, java.lang.Object)
,IChemObject.getProperty(java.lang.Object)
-
getProperty
public <T> T getProperty(Object description)
Returns a property for the IChemObject - the object is automatically cast to the required type. This does however mean if the wrong type is provided then a runtime ClassCastException will be thrown.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
- Specified by:
getProperty
in interfaceIChemObject
- Type Parameters:
T
- generic return type- Parameters:
description
- An object description of the property (most likely a unique string)- Returns:
- The object containing the property. Returns null if property is not set.
- See Also:
IChemObject.setProperty(java.lang.Object, java.lang.Object)
,IChemObject.getProperty(Object, Class)
,IChemObject.removeProperty(java.lang.Object)
-
getProperty
public <T> T getProperty(Object description, Class<T> c)
Access a property of the given description and cast the specified class.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
- Specified by:
getProperty
in interfaceIChemObject
- Type Parameters:
T
- generic type (of provided class)- Parameters:
description
- description of a property (normally a string)c
- type of the value to be returned- Returns:
- the value stored for the specified description.
- See Also:
IChemObject.getProperty(Object)
,IChemObject.addProperties(java.util.Map)
-
getProperties
public Map<Object,Object> getProperties()
Returns a Map with the IChemObject's properties.- Specified by:
getProperties
in interfaceIChemObject
- Returns:
- The object's properties as an Map
- See Also:
IChemObject.addProperties(java.util.Map<java.lang.Object, java.lang.Object>)
-
getID
public String getID()
Returns the identifier (ID) of this object.- Specified by:
getID
in interfaceIChemObject
- Returns:
- a String representing the ID value
- See Also:
IChemObject.setID(java.lang.String)
-
setID
public void setID(String identifier)
Sets the identifier (ID) of this object.- Specified by:
setID
in interfaceIChemObject
- Parameters:
identifier
- a String representing the ID value- See Also:
IChemObject.getID()
-
setFlag
public void setFlag(int mask, boolean value)
Sets the value of some flag. The flag is a mask from a given CDKConstant (e.g.CDKConstants.ISAROMATIC
orCDKConstants.VISITED
). The flags are intrinsic internal properties and should not be used to store custom values, please useIChemObject.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);
- Specified by:
setFlag
in interfaceIChemObject
- Parameters:
mask
- flag to set the value forvalue
- value to assign to flag- See Also:
IChemObject.getFlag(int)
,CDKConstants
-
getFlag
public boolean getFlag(int mask)
Returns the value of a given flag. The flag is a mask from a given CDKConstant (e.g.CDKConstants.ISAROMATIC
).if(chemObject.getFlag(CDKConstants.ISAROMATIC)){ // handle aromatic flag on this chem object }
- Specified by:
getFlag
in interfaceIChemObject
- Parameters:
mask
- flag to retrieve the value of- Returns:
- true if the flag
flag_type
is set - See Also:
IChemObject.setFlag(int, boolean)
,CDKConstants
-
setProperties
public void setProperties(Map<Object,Object> properties)
Set the properties of this object to the provided map (shallow copy). Any existing properties are removed.- Specified by:
setProperties
in interfaceIChemObject
- Parameters:
properties
- map key-value pairs
-
addProperties
public void addProperties(Map<Object,Object> properties)
Add properties to this object, duplicate keys will replace any existing value.- Specified by:
addProperties
in interfaceIChemObject
- Parameters:
properties
- a Map specifying the property values- See Also:
IChemObject.getProperties()
-
setFlags
public void setFlags(boolean[] newFlags)
Sets the whole set of flags. This set will iteratively invokeIChemObject.setFlag(int, boolean)
for each value in the array and useCDKConstants.FLAG_MASKS
to look up the correct mask. If only a single flag is being set it is a lot faster to useIChemObject.setFlag(int, boolean)
.- Specified by:
setFlags
in interfaceIChemObject
- Parameters:
newFlags
- the new flags to set.- See Also:
IChemObject.setFlag(int, boolean)
,IChemObject.getFlags()
-
getFlags
public boolean[] getFlags()
Returns the whole set of flags. This method will create a new array on each invocation and it is recommend you useIChemObject.getFlagValue()
if you need all the flags. For individual flags please useIChemObject.getFlag(int)
- Specified by:
getFlags
in interfaceIChemObject
- Returns:
- the flags.
- See Also:
IChemObject.setFlags(boolean[])
,IChemObject.getFlag(int)
,IChemObject.getFlagValue()
-
getFlagValue
public Number getFlagValue()
Access the internal value used to store the flags. The flags are stored on a single numeric value and are set/cleared.- Specified by:
getFlagValue
in interfaceIChemObject
- Returns:
- numeric representation of the flags
-
-