public class MolecularFormula extends Object implements IMolecularFormula
IIsotope
.
Examples:
[C5H5]-
C6H6
12C513CH6
Constructor and Description |
---|
MolecularFormula()
Constructs an empty MolecularFormula.
|
Modifier and Type | Method and Description |
---|---|
IMolecularFormula |
add(IMolecularFormula formula)
Adds an molecularFormula to this MolecularFormula.
|
IMolecularFormula |
addIsotope(IIsotope isotope)
Adds an Isotope to this MolecularFormula one time.
|
IMolecularFormula |
addIsotope(IIsotope isotope,
int count)
Adds an Isotope to this MolecularFormula in a number of occurrences.
|
Object |
clone()
Clones this MolecularFormula object and its content.
|
boolean |
contains(IIsotope isotope)
True, if the MolecularFormula contains the given IIsotope object and not
the instance.
|
IChemObjectBuilder |
getBuilder()
Returns a
IChemObjectBuilder for the data classes that extend
this class. |
Integer |
getCharge()
Access the charge of this IMolecularFormula.
|
int |
getIsotopeCount()
Checks a set of Nodes for the number of different isotopes in the
IMolecularFormula.
|
int |
getIsotopeCount(IIsotope isotope)
Checks a set of Nodes for the occurrence of the isotope in the
IMolecularFormula from a particular isotope.
|
Map<Object,Object> |
getProperties()
Returns a Map with the IChemObject's properties.I should
integrate into ChemObject.
|
<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.
|
Iterable<IIsotope> |
isotopes()
Returns an Iterator for looping over all isotopes in this IMolecularFormula.
|
protected boolean |
isTheSame(IIsotope isotopeOne,
IIsotope isotopeTwo)
Compare to IIsotope.
|
void |
removeAllIsotopes()
Removes all isotopes of this molecular formula.
|
void |
removeIsotope(IIsotope isotope)
Removes the given isotope from the MolecularFormula.
|
void |
removeProperty(Object description)
Removes a property for a IChemObject.
|
void |
setCharge(Integer charge)
Sets the charge of this IMolecularFormula, since there is no atom
associated with the charge the number of a given isotope is not modified.
|
void |
setProperties(Map<Object,Object> properties)
Sets the properties of this object.
|
void |
setProperty(Object description,
Object property)
Sets a property for a IChemObject.
|
public IMolecularFormula add(IMolecularFormula formula)
add
in interface IMolecularFormula
formula
- The molecularFormula to be added to this chemObjectpublic IMolecularFormula addIsotope(IIsotope isotope)
addIsotope
in interface IMolecularFormula
isotope
- The isotope to be added to this MolecularFormulaaddIsotope(IIsotope, int)
public IMolecularFormula addIsotope(IIsotope isotope, int count)
addIsotope
in interface IMolecularFormula
isotope
- The isotope to be added to this MolecularFormulacount
- The number of occurrences to addaddIsotope(IIsotope)
public boolean contains(IIsotope isotope)
contains
in interface IMolecularFormula
isotope
- The IIsotope this MolecularFormula is searched forpublic Integer getCharge()
getCharge
in interface IMolecularFormula
IMolecularFormula.setCharge(java.lang.Integer)
public int getIsotopeCount(IIsotope isotope)
getIsotopeCount
in interface IMolecularFormula
isotope
- The IIsotope to look forgetIsotopeCount()
public int getIsotopeCount()
getIsotopeCount
in interface IMolecularFormula
getIsotopeCount(IIsotope)
public Iterable<IIsotope> isotopes()
isotopes
in interface IMolecularFormula
public void setCharge(Integer charge)
// Correct usage IMolecularFormula phenolate = MolecularFormulaManipulator.getMolecularFormula("C6H5O", builder) mf.setCharge(-1); // MF=C6H5O- // Wrong! the H6 is not automatically adjust IMolecularFormula phenolate = MolecularFormulaManipulator.getMolecularFormula("C6H6O", builder) mf.setCharge(-1); // MF=C6H6O- (wrong)If you wish to adjust the protonation of a formula try the convenience method of the
MolecularFormulaManipulator
:
IMolecularFormula mf = MolecularFormulaManipulator.getMolecularFormula("[C6H5O]-", bldr); MolecularFormulaManipulator.adjustProtonation(mf, +1); MolecularFormulaManipulator.getString(mf); // "C6H6O"
setCharge
in interface IMolecularFormula
charge
- The partial chargeIMolecularFormula.getCharge()
public void removeAllIsotopes()
removeAllIsotopes
in interface IMolecularFormula
public void removeIsotope(IIsotope isotope)
removeIsotope
in interface IMolecularFormula
isotope
- The IIsotope to be removedpublic Object clone() throws CloneNotSupportedException
clone
in interface IMolecularFormula
clone
in class Object
CloneNotSupportedException
public void setProperty(Object description, Object property)
setProperty
in interface IMolecularFormula
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 IMolecularFormula
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)
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 IMolecularFormula
T
- generic return typedescription
- An object description of the property (most likely a
unique string)IMolecularFormula.setProperty(java.lang.Object, java.lang.Object)
,
IMolecularFormula.getProperty(Object, Class)
,
IMolecularFormula.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 IMolecularFormula
T
- generic type (of provided class)description
- description of a property (normally a string)c
- type of the value to be returnedIMolecularFormula.getProperty(Object)
,
IMolecularFormula.getProperties()
public Map<Object,Object> getProperties()
getProperties
in interface IMolecularFormula
setProperties(java.util.Map<java.lang.Object, java.lang.Object>)
public void setProperties(Map<Object,Object> properties)
setProperties
in interface IMolecularFormula
properties
- a Hashtable specifying the property valuesgetProperties()
protected boolean isTheSame(IIsotope isotopeOne, IIsotope isotopeTwo)
isotopeOne
- The first Isotope to compareisotopeTwo
- The second Isotope to comparepublic IChemObjectBuilder getBuilder()
ICDKObject
IChemObjectBuilder
for the data classes that extend
this class.getBuilder
in interface ICDKObject
IChemObjectBuilder
matching this ICDKObject
Copyright © 2021. All rights reserved.