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 CDK IAtom 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 IAtomType

    IAtomType.Hybridization
    Modifier and Type
    Interface
    Description
    static enum 
    An enum for the different hybridization states.
  • Field Summary

    Fields inherited from interface IChemObject

    ALIPHATIC, AROMATIC, CONJUGATED, HIDDEN, HYDROGEN_BOND_ACCEPTOR, HYDROGEN_BOND_DONOR, IN_RING, MAPPED, MARKUSH, NOT_IN_RING, PLACED, REACTIVE_CENTER, SINGLE_OR_DOUBLE, TYPEABLE, VISITED
    Modifier and Type
    Field
    Description
    static final int
    Flag that is set if a ChemObject is part of an aliphatic chain.
    static final int
    Flag is set if ChemObject is part of an aromatic system.
    static final int
    Flag is set if ChemObject is part of a conjugated system.
    static final int
    This flag can be used when depicted structures to hide certain parts, for example the things are abbreviated (display shortcuts).
    static final int
    Sets to true if the atom is a hydrogen bond acceptor.
    static final int
    Sets to true if the atom is a hydrogen bond donor.
    static final int
    Flag that is set when the ChemObject is part of a ring.
    static final int
    Flag is set if a ChemObject is mapped to another ChemObject.
    static final int
    Flag to indicate a flattened molecule holds a Markush structure, you can work on it as is or it might make more sense to repack into something sensible like a RGroupQuery.
    static final int
    Flag that is set when the ChemObject is part of a ring.
    static final int
    Flag that is set if the ChemObject is placed when calculating 2D/3D layouts.
    static final int
    Flag is set if a ChemObject has reactive center.
    static final int
    Flag used for marking uncertainty of the bond order.
    static final int
    Flag is set if an atom could be typed.
    static final int
    Flag is set if ChemObject has been visited.

    Fields inherited from interface 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
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
    Carbon atomic number
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
    Hydrogen atomic number
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
    Nitrogen atomic number
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
    Oxygen atomic number
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
    Wildcard atom is atomic number 0
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    AtomRef(IAtom atom)
    Create a pointer for the provided atom.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Use this to add yourself to this IChemObject as a listener.
    void
    Add properties to this object, duplicate keys will replace any existing value.
    Returns the bonds connected to this atom.
    void
    clear(int flags)
    Clear the provided flags.
    Returns a deep clone of this IChemObject.
    Dereference the atom pointer once providing access to the base atom.
    static IAtom
    deref(IAtom atom)
    Utility method to dereference an atom.
    boolean
     
    int
    Access the current value of the flags for this ChemObject.
    Returns the atomic number of this element.
    Gets the id attribute of the AtomType object.
    getBond(IAtom atom)
    Returns the bond connecting 'this' atom to the provided atom.
    int
    Get the number of explicit bonds connected to this atom.
    Gets the bondOrderSum attribute of the AtomType object.
    Returns a IChemObjectBuilder for the data classes that extend this class.
    Returns the partial charge of this atom.
    Access the IAtomContainer of which this atom is a member of.
    Returns the covalent radius for this AtomType.
    Gets the ExactMass attribute of the Isotope object.
    boolean
    getFlag(int mask)
    Returns the value of a given flag.
    boolean[]
    Returns the whole set of flags.
    Access the internal value used to store the flags.
    Returns the formal charge of this atom.
    Returns the formal neighbour count of this atom.
    javax.vecmath.Point3d
    Returns a point specifying the location of this atom in a Crystal unit cell.
    Returns the hybridization of this atom.
    Returns the identifier (ID) of this object.
    Returns the implicit hydrogen count of this atom.
    int
    Acces the index of an atom in the context of an IAtomContainer.
    int
    Returns the number of ChemObjectListeners registered with this object.
    int
    Access the map index for this atom.
    Returns the atomic mass of this element.
    Gets the MaxBondOrder attribute of the AtomType object.
    Gets the NaturalAbundance attribute of the Isotope object.
    boolean
    Returns the flag that indicates whether notification messages are sent around.
    javax.vecmath.Point2d
    Returns a point specifying the location of this atom in a 2D space.
    javax.vecmath.Point3d
    Returns a point specifying the location of this atom in a 3D space.
    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.
    Returns the stereo parity of this atom.
    Returns the element symbol of this element.
    Gets the the exact electron valency of the AtomType object.
    int
     
    boolean
    is(int flags)
    Test if a flag(s) are set on this ChemObject.
    boolean
    Access whether this atom has been marked as aromatic.
    boolean
    Access whether this atom has been flagged as in a ring.
    void
    This should be triggered by an method that changes the content of an object to that the registered listeners can react to it.
    void
    This should be triggered by an method that changes the content of an object to that the registered listeners can react to it.
    void
    Use this to remove a ChemObjectListener from the ListenerList of this IChemObject.
    void
    removeProperty(Object description)
    Removes a property for a IChemObject.
    void
    set(int flags)
    Set the provided flags.
    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
    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
    Sets the formal charge of this atom.
    void
    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
    Sets the hybridization of this atom.
    void
    setID(String identifier)
    Sets the identifier (ID) of this object.
    void
    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
    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
    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
    Sets the the exact electron valency of the AtomType object.
    Returns a one line description of this IChemObject.

    Methods inherited from class Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface IAtom

    getTotalHydrogenCount, neighbors
    Modifier and Type
    Method
    Description
    default Integer
    Calculates the total number of hydrogens connected to this atom.
    default Iterable<IAtom>
    Iterable over the atoms connected to this atom (the neighbors).
  • Constructor Details

    • AtomRef

      public AtomRef(IAtom atom)
      Create a pointer for the provided atom.
      Parameters:
      atom - the atom to reference
  • Method Details

    • deref

      public static IAtom deref(IAtom atom)
      Utility method to dereference an atom. If the atom is not an AtomRef 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 interface IAtom
      Returns:
      the charge of this atom
      See Also:
    • setCharge

      public void setCharge(Double charge)
      Sets the partial charge of this atom.
      Specified by:
      setCharge in interface IAtom
      Parameters:
      charge - The partial charge
      See Also:
    • 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 interface IElement
      Returns:
      The atomic number of this element
      See Also:
    • setAtomicNumber

      public void setAtomicNumber(Integer atomicNumber)
      Sets the atomic number of this element.
      Specified by:
      setAtomicNumber in interface IElement
      Parameters:
      atomicNumber - The atomic mass to be assigned to this element
      See Also:
    • getNaturalAbundance

      public Double getNaturalAbundance()
      Gets the NaturalAbundance attribute of the Isotope object. Returns null when unconfigured.
      Specified by:
      getNaturalAbundance in interface IIsotope
      Returns:
      The NaturalAbundance value
      See Also:
    • setNaturalAbundance

      public void setNaturalAbundance(Double naturalAbundance)
      Sets the NaturalAbundance attribute of the Isotope object.
      Specified by:
      setNaturalAbundance in interface IIsotope
      Parameters:
      naturalAbundance - The new NaturalAbundance value
      See Also:
    • getImplicitHydrogenCount

      public Integer getImplicitHydrogenCount()
      Returns the implicit hydrogen count of this atom.
      Specified by:
      getImplicitHydrogenCount in interface IAtom
      Returns:
      The hydrogen count of this atom.
      See Also:
    • setImplicitHydrogenCount

      public void setImplicitHydrogenCount(Integer hydrogenCount)
      Sets the implicit hydrogen count of this atom.
      Specified by:
      setImplicitHydrogenCount in interface IAtom
      Parameters:
      hydrogenCount - The number of hydrogen atoms bonded to this atom.
      See Also:
    • getExactMass

      public Double getExactMass()
      Gets the ExactMass attribute of the Isotope object. Returns null when unconfigured.
      Specified by:
      getExactMass in interface IIsotope
      Returns:
      The ExactMass value
      See Also:
    • setExactMass

      public void setExactMass(Double exactMass)
      Sets the ExactMass attribute of the Isotope object.
      Specified by:
      setExactMass in interface IIsotope
      Parameters:
      exactMass - The new ExactMass value
      See Also:
    • getSymbol

      public String getSymbol()
      Returns the element symbol of this element.
      Specified by:
      getSymbol in interface IElement
      Returns:
      The element symbol of this element. Null if unset.
      See Also:
    • setSymbol

      public void setSymbol(String symbol)
      Sets the element symbol of this element.
      Specified by:
      setSymbol in interface IElement
      Parameters:
      symbol - The element symbol to be assigned to this atom
      See Also:
    • getMassNumber

      public Integer getMassNumber()
      Returns the atomic mass of this element. Returns null when unconfigured.
      Specified by:
      getMassNumber in interface IIsotope
      Returns:
      The atomic mass of this element
      See Also:
    • setMassNumber

      public void setMassNumber(Integer massNumber)
      Sets the atomic mass of this element.
      Specified by:
      setMassNumber in interface IIsotope
      Parameters:
      massNumber - The atomic mass to be assigned to this element
      See Also:
    • getAtomTypeName

      public String getAtomTypeName()
      Gets the id attribute of the AtomType object.
      Specified by:
      getAtomTypeName in interface IAtomType
      Returns:
      The id value
      See Also:
    • setAtomTypeName

      public void setAtomTypeName(String identifier)
      Sets the if attribute of the AtomType object.
      Specified by:
      setAtomTypeName in interface IAtomType
      Parameters:
      identifier - The new AtomTypeID value. Null if unset.
      See Also:
    • getMaxBondOrder

      public IBond.Order getMaxBondOrder()
      Gets the MaxBondOrder attribute of the AtomType object.
      Specified by:
      getMaxBondOrder in interface IAtomType
      Returns:
      The MaxBondOrder value
      See Also:
    • setMaxBondOrder

      public void setMaxBondOrder(IBond.Order maxBondOrder)
      Sets the MaxBondOrder attribute of the AtomType object.
      Specified by:
      setMaxBondOrder in interface IAtomType
      Parameters:
      maxBondOrder - The new MaxBondOrder value
      See Also:
    • getBondOrderSum

      public Double getBondOrderSum()
      Gets the bondOrderSum attribute of the AtomType object.
      Specified by:
      getBondOrderSum in interface IAtomType
      Returns:
      The bondOrderSum value
      See Also:
    • setBondOrderSum

      public void setBondOrderSum(Double bondOrderSum)
      Sets the the exact bond order sum attribute of the AtomType object.
      Specified by:
      setBondOrderSum in interface IAtomType
      Parameters:
      bondOrderSum - The new bondOrderSum value
      See Also:
    • getPoint2d

      public javax.vecmath.Point2d getPoint2d()
      Returns a point specifying the location of this atom in a 2D space.
      Specified by:
      getPoint2d in interface IAtom
      Returns:
      A point in a 2D plane. Null if unset.
      See Also:
    • 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 interface IAtom
      Parameters:
      point2d - A point in a 2D plane
      See Also:
    • getPoint3d

      public javax.vecmath.Point3d getPoint3d()
      Returns a point specifying the location of this atom in a 3D space.
      Specified by:
      getPoint3d in interface IAtom
      Returns:
      A point in 3-dimensional space. Null if unset.
      See Also:
    • setPoint3d

      public void setPoint3d(javax.vecmath.Point3d point3d)
      Sets a point specifying the location of this atom in 3D space.
      Specified by:
      setPoint3d in interface IAtom
      Parameters:
      point3d - A point in a 3-dimensional space
      See Also:
    • getFormalCharge

      public Integer getFormalCharge()
      Returns the formal charge of this atom.
      Specified by:
      getFormalCharge in interface IAtomType
      Returns:
      the formal charge of this atom
      See Also:
    • setFormalCharge

      public void setFormalCharge(Integer charge)
      Sets the formal charge of this atom.
      Specified by:
      setFormalCharge in interface IAtomType
      Parameters:
      charge - The formal charge
      See Also:
    • getFractionalPoint3d

      public javax.vecmath.Point3d getFractionalPoint3d()
      Returns a point specifying the location of this atom in a Crystal unit cell.
      Specified by:
      getFractionalPoint3d in interface IAtom
      Returns:
      A point in 3d fractional unit cell space. Null if unset.
      See Also:
    • 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 interface IAtom
      Parameters:
      point3d - A point in a 3d fractional unit cell space
      See Also:
    • getFormalNeighbourCount

      public Integer getFormalNeighbourCount()
      Returns the formal neighbour count of this atom.
      Specified by:
      getFormalNeighbourCount in interface IAtomType
      Returns:
      the formal neighbour count of this atom
      See Also:
    • setFormalNeighbourCount

      public void setFormalNeighbourCount(Integer count)
      Sets the formal neighbour count of this atom.
      Specified by:
      setFormalNeighbourCount in interface IAtomType
      Parameters:
      count - The neighbour count
      See Also:
    • getStereoParity

      public Integer getStereoParity()
      Returns the stereo parity of this atom. It uses the predefined values found in CDKConstants.
      Specified by:
      getStereoParity in interface IAtom
      Returns:
      The stereo parity for this atom
      See Also:
    • setStereoParity

      public void setStereoParity(Integer stereoParity)
      Sets the stereo parity for this atom.
      Specified by:
      setStereoParity in interface IAtom
      Parameters:
      stereoParity - The stereo parity for this atom
      See Also:
    • getHybridization

      public IAtomType.Hybridization getHybridization()
      Returns the hybridization of this atom.
      Specified by:
      getHybridization in interface IAtomType
      Returns:
      the hybridization of this atom
      See Also:
    • setHybridization

      public void setHybridization(IAtomType.Hybridization hybridization)
      Sets the hybridization of this atom.
      Specified by:
      setHybridization in interface IAtomType
      Parameters:
      hybridization - The hybridization
      See Also:
    • getCovalentRadius

      public Double getCovalentRadius()
      Returns the covalent radius for this AtomType.
      Specified by:
      getCovalentRadius in interface IAtomType
      Returns:
      The covalent radius for this AtomType
      See Also:
    • setCovalentRadius

      public void setCovalentRadius(Double radius)
      Sets the covalent radius for this AtomType.
      Specified by:
      setCovalentRadius in interface IAtomType
      Parameters:
      radius - The covalent radius for this AtomType
      See Also:
    • getContainer

      public IAtomContainer getContainer()
      Access the IAtomContainer 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 an IAtomContainer, 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 interface IAtom
      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 an IAtomContainer. If the index is not known, < 0 is returned.
      Specified by:
      getIndex in interface IAtom
      Returns:
      atom index or < 0 if the index is not known
    • getValency

      public Integer getValency()
      Gets the the exact electron valency of the AtomType object.
      Specified by:
      getValency in interface IAtomType
      Returns:
      The valency value
      See Also:
    • setValency

      public void setValency(Integer valency)
      Sets the the exact electron valency of the AtomType object.
      Specified by:
      setValency in interface IAtomType
      Parameters:
      valency - The new valency value
      See Also:
    • 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 if IAtom.getIndex() returns < 0 or IAtom.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()) {
      
      }
      
      Specified by:
      bonds in interface IAtom
      Returns:
      iterable of bonds
    • getBondCount

      public int getBondCount()
      Description copied from interface: IAtom
      Get the number of explicit bonds connected to this atom.
      Specified by:
      getBondCount in interface IAtom
      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.
      Specified by:
      getBond in interface IAtom
      Parameters:
      atom - the other atom
      Returns:
      the bond connecting the atoms
    • 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 interface IAtom
      Returns:
      aromatic status
      See Also:
    • setIsAromatic

      public void setIsAromatic(boolean arom)
      Mark this atom as being aromatic.
      Specified by:
      setIsAromatic in interface IAtom
      Parameters:
      arom - aromatic status
      See Also:
    • 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 interface IAtom
      Returns:
      ring status
      See Also:
    • setIsInRing

      public void setIsInRing(boolean ring)
      Mark this atom as being in a ring.
      Specified by:
      setIsInRing in interface IAtom
      Parameters:
      ring - ring status
      See Also:
    • getMapIdx

      public int getMapIdx()
      Description copied from interface: IAtom
      Access the map index for this atom.
      Specified by:
      getMapIdx in interface IAtom
      Returns:
      the map index (0 if not set)
    • setMapIdx

      public void setMapIdx(int mapidx)
      Description copied from interface: IAtom
      Set the map index for this atom.
      Specified by:
      setMapIdx in interface IAtom
      Parameters:
      mapidx - the new map index
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • clone

      public IAtom clone() throws CloneNotSupportedException
      Returns a deep clone of this IChemObject.
      Specified by:
      clone in interface IAtom
      Specified by:
      clone in interface IChemObject
      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 interface IChemObject
      Overrides:
      toString in class Object
      Returns:
      a String representation of this object
    • getBuilder

      public IChemObjectBuilder getBuilder()
      Returns a IChemObjectBuilder for the data classes that extend this class.
      Specified by:
      getBuilder in interface ICDKObject
      Returns:
      The IChemObjectBuilder matching this ICDKObject
    • 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:
    • 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:
    • 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 interface IChemObject
      Parameters:
      bool - if true, then notification messages are sent.
      See Also:
    • getNotification

      public boolean getNotification()
      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:
    • 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:
    • 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:
    • 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 interface IChemObject
      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:
    • 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 interface IChemObject
      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:
    • 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 Map
      See Also:
    • 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

      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:
    • 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. IChemObject.AROMATIC or IChemObject.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);
      
      Specified by:
      setFlag in interface IChemObject
      Parameters:
      mask - flag to set the value for
      value - value to assign to flag
      See Also:
    • getFlag

      public boolean getFlag(int mask)
      Returns the value of a given flag. The flag is a mask from a given CDKConstant (e.g. IChemObject.AROMATIC).
      if(chemObject.getFlag(CDKConstants.ISAROMATIC)){
          // handle aromatic flag on this chem object
      }
      
      Specified by:
      getFlag in interface IChemObject
      Parameters:
      mask - flag to retrieve the value of
      Returns:
      true if the flag flag_type is set
      See Also:
    • 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 interface IChemObject
      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 interface IChemObject
      Parameters:
      properties - a Map specifying the property values
      See Also:
    • setFlags

      public void setFlags(boolean[] newFlags)
      Sets the whole set of flags. This set will iteratively invoke 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).
      Specified by:
      setFlags in interface IChemObject
      Parameters:
      newFlags - the new flags to set.
      See Also:
    • 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 use IChemObject.getFlagValue() if you need all the flags. For individual flags please use IChemObject.getFlag(int)
      Specified by:
      getFlags in interface IChemObject
      Returns:
      the flags.
      See Also:
    • 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 interface IChemObject
      Returns:
      numeric representation of the flags
    • set

      public void set(int flags)
      Description copied from interface: IChemObject
      Set the provided flags. Any on-bits in the input parameter are set on in the ChemObject.
      Specified by:
      set in interface IChemObject
      Parameters:
      flags - the flags
    • clear

      public void clear(int flags)
      Description copied from interface: IChemObject
      Clear the provided flags. Any on-bits in the input parameter are set on in the ChemObject.
      Specified by:
      clear in interface IChemObject
      Parameters:
      flags - the flags
    • is

      public boolean is(int flags)
      Description copied from interface: IChemObject
      Test if a flag(s) are set on this ChemObject. If multiple flags are provided they must all be set to return true.
      atom.set(IS_IN_RING);
      atom.is(IS_IN_RING); // false!
      atom.is(IS_IN_RING+IS_AROMATIC); // false!
      atom.set(IS_AROMATIC);
      atom.is(IS_IN_RING+IS_AROMATIC); // true!
      
      Specified by:
      is in interface IChemObject
      Parameters:
      flags - the flags
    • flags

      public int flags()
      Description copied from interface: IChemObject
      Access the current value of the flags for this ChemObject.
      Specified by:
      flags in interface IChemObject
      Returns:
      the flag value (32-bit integer)