org.xmlcml.cml
Class MoleculeImpl
java.lang.Object
|
+--org.apache.xerces.dom.NodeImpl
|
+--org.apache.xerces.dom.ChildNode
|
+--org.apache.xerces.dom.ChildAndParentNode
|
+--org.apache.xerces.dom.ElementImpl
|
+--uk.co.demon.ursus.dom.AbstractElementImpl
|
+--uk.co.demon.ursus.dom.PMRElementImpl
|
+--org.xmlcml.cml.CMLBaseImpl
|
+--org.xmlcml.cml.MoleculeImpl
- public class MoleculeImpl
- extends CMLBaseImpl
- implements Molecule
Molecule is the basic container for Atoms, Bonds, Electrons
Angles, Torsion, Sequences, Features, Crystal and other objects.
Molecules may contain other Molecules.
When objects such as AtomArray are set or added they are deep-copied,
to avoid unpleasant surprises later. In general Atom, AtomArray,
Bond, BondArray should not be shared between different molecules.
A molecule has only one set of Atoms and Bonds - if a molecule
is created with AtomArray and an Atom is subsequently added,
the components are effectively merged.
- See Also:
- Serialized Form
| Fields inherited from class org.apache.xerces.dom.ElementImpl |
attributes,
name |
| Fields inherited from class org.apache.xerces.dom.ChildAndParentNode |
changes,
firstChild,
nodeListIndex,
nodeListLength,
nodeListNode,
ownerDocument |
| Fields inherited from class org.apache.xerces.dom.ChildNode |
nextSibling,
previousSibling |
| Fields inherited from class org.apache.xerces.dom.NodeImpl |
ELEMENT_DEFINITION_NODE,
FIRSTCHILD,
flags,
IGNORABLEWS,
MUTATION_AGGREGATE,
MUTATION_ALL,
MUTATION_LOCAL,
MUTATION_NONE,
MUTATIONEVENTS,
OWNED,
ownerNode,
READONLY,
SETVALUE,
SPECIFIED,
SYNCCHILDREN,
SYNCDATA |
| Fields inherited from interface org.xmlcml.cml.CMLBase |
ANGLE,
ATOM,
ATOMARRAY,
BOND,
BONDARRAY,
BUILTIN,
CML,
CRYSTAL,
ELECTRON,
ELEMENT_COUNT,
ELEMENT_NAMES,
EXECUTE,
FEATURE,
FLOAT,
FLOAT_TYPE,
FLOATARRAY,
FLOATMATRIX,
FORMULA,
INTEGER,
INTEGER_TYPE,
INTEGERARRAY,
LINK,
LIST,
MOLECULE,
PACKAGE_NAME,
REACTION,
SEQUENCE,
STRING,
STRING_TYPE,
STRINGARRAY,
TORSION,
UNK,
UNK_ELEM,
UNKNOWN |
| Fields inherited from interface org.xmlcml.cml.HasId |
ID |
| Fields inherited from interface uk.co.demon.ursus.dom.PMRNode |
ATTRIBUTES,
CONTENT,
ELEMENTNAME,
IDLIST,
NESTED,
NESTEDATTS,
PACKAGENAME,
PRETTY,
SPLITFILES,
STYLE,
TAGGED,
UNTAGGED,
WHITESPACE,
XMLCONTENT |
| Fields inherited from interface org.w3c.dom.Node |
ATTRIBUTE_NODE,
CDATA_SECTION_NODE,
COMMENT_NODE,
DOCUMENT_FRAGMENT_NODE,
DOCUMENT_NODE,
DOCUMENT_TYPE_NODE,
ELEMENT_NODE,
ENTITY_NODE,
ENTITY_REFERENCE_NODE,
NOTATION_NODE,
PROCESSING_INSTRUCTION_NODE,
TEXT_NODE |
| Fields inherited from interface org.w3c.dom.Node |
ATTRIBUTE_NODE,
CDATA_SECTION_NODE,
COMMENT_NODE,
DOCUMENT_FRAGMENT_NODE,
DOCUMENT_NODE,
DOCUMENT_TYPE_NODE,
ELEMENT_NODE,
ENTITY_NODE,
ENTITY_REFERENCE_NODE,
NOTATION_NODE,
PROCESSING_INSTRUCTION_NODE,
TEXT_NODE |
| Fields inherited from interface org.xmlcml.cml.CMLBase |
ANGLE,
ATOM,
ATOMARRAY,
BOND,
BONDARRAY,
BUILTIN,
CML,
CRYSTAL,
ELECTRON,
ELEMENT_COUNT,
ELEMENT_NAMES,
EXECUTE,
FEATURE,
FLOAT,
FLOAT_TYPE,
FLOATARRAY,
FLOATMATRIX,
FORMULA,
INTEGER,
INTEGER_TYPE,
INTEGERARRAY,
LINK,
LIST,
MOLECULE,
PACKAGE_NAME,
REACTION,
SEQUENCE,
STRING,
STRING_TYPE,
STRINGARRAY,
TORSION,
UNK,
UNK_ELEM,
UNKNOWN |
| Fields inherited from interface org.xmlcml.cml.HasId |
ID |
| Fields inherited from interface uk.co.demon.ursus.dom.PMRNode |
ATTRIBUTES,
CONTENT,
ELEMENTNAME,
IDLIST,
NESTED,
NESTEDATTS,
PACKAGENAME,
PRETTY,
SPLITFILES,
STYLE,
TAGGED,
UNTAGGED,
WHITESPACE,
XMLCONTENT |
| Fields inherited from interface org.w3c.dom.Node |
ATTRIBUTE_NODE,
CDATA_SECTION_NODE,
COMMENT_NODE,
DOCUMENT_FRAGMENT_NODE,
DOCUMENT_NODE,
DOCUMENT_TYPE_NODE,
ELEMENT_NODE,
ENTITY_NODE,
ENTITY_REFERENCE_NODE,
NOTATION_NODE,
PROCESSING_INSTRUCTION_NODE,
TEXT_NODE |
| Fields inherited from interface org.w3c.dom.Node |
ATTRIBUTE_NODE,
CDATA_SECTION_NODE,
COMMENT_NODE,
DOCUMENT_FRAGMENT_NODE,
DOCUMENT_NODE,
DOCUMENT_TYPE_NODE,
ELEMENT_NODE,
ENTITY_NODE,
ENTITY_REFERENCE_NODE,
NOTATION_NODE,
PROCESSING_INSTRUCTION_NODE,
TEXT_NODE |
|
Constructor Summary |
protected |
MoleculeImpl()
|
|
MoleculeImpl(org.w3c.dom.Document document)
new Molecule in context |
|
MoleculeImpl(org.w3c.dom.Element element)
replace existing tree nodes by a Molecule |
| Methods inherited from class org.xmlcml.cml.CMLBaseImpl |
addValidity,
convertToSubclass,
getConventionName,
getDictRef,
getId,
getSubClassedElement,
getTitle,
getValidity,
help,
isValid,
main,
setConventionName,
setDictRef,
setId,
setTitle,
showElementNames,
test1,
updateDOMHasConvention,
updateDOMHasConvention,
updateDOMHasCount,
updateDOMHasDictRef,
updateDOMHasDictRef,
updateDOMHasId,
updateDOMHasId,
updateDOMHasTitle,
updateDOMHasTitle,
updateDOMHasUnits |
| Methods inherited from class org.apache.xerces.dom.ElementImpl |
cloneNode,
getAttribute,
getAttributeNode,
getAttributeNodeNS,
getAttributeNS,
getAttributes,
getElementsByTagName,
getElementsByTagNameNS,
getNodeName,
getNodeType,
getTagName,
hasAttribute,
hasAttributeNS,
normalize,
removeAttribute,
removeAttributeNode,
removeAttributeNS,
setAttribute,
setAttributeNode,
setAttributeNodeNS,
setAttributeNS,
setReadOnly,
setupDefaultAttributes,
synchronizeData |
| Methods inherited from class org.apache.xerces.dom.ChildAndParentNode |
changed,
changes,
getChildNodes,
getFirstChild,
getLastChild,
getLength,
getOwnerDocument,
hasChildNodes,
insertBefore,
item,
removeChild,
replaceChild,
synchronizeChildren,
synchronizeChildren |
| Methods inherited from class org.apache.xerces.dom.ChildNode |
getNextSibling,
getParentNode,
getPreviousSibling |
| Methods inherited from class org.apache.xerces.dom.NodeImpl |
addEventListener,
appendChild,
dispatchEvent,
finalize,
getLocalName,
getNamespaceURI,
getNodeValue,
getPrefix,
getReadOnly,
getUserData,
removeEventListener,
setNodeValue,
setPrefix,
setUserData,
supports,
toString |
| Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
atomVector
protected java.util.Vector atomVector
bondVector
protected java.util.Vector bondVector
electronVector
protected java.util.Vector electronVector
moleculeVector
protected java.util.Vector moleculeVector
angleVector
protected java.util.Vector angleVector
torsionVector
protected java.util.Vector torsionVector
crystal
protected Crystal crystal
sequenceVector
protected java.util.Vector sequenceVector
featureVector
protected java.util.Vector featureVector
atomArray
protected AtomArray atomArray
bondArray
protected BondArray bondArray
atomIdTable
protected java.util.Hashtable atomIdTable
bondIdTable
protected java.util.Hashtable bondIdTable
bondHashTable
protected java.util.Hashtable bondHashTable
count
protected double count
MoleculeImpl
protected MoleculeImpl()
MoleculeImpl
public MoleculeImpl(org.w3c.dom.Element element)
- replace existing tree nodes by a Molecule
MoleculeImpl
public MoleculeImpl(org.w3c.dom.Document document)
- new Molecule in context
run
public void run(Execute execute)
throws java.lang.Exception
- run an <execute> child
- Specified by:
- run in interface Molecule
deleteAtom
public void deleteAtom(org.w3c.dom.Element executeChild)
throws CMLException
- deletes Atoms, bonds, etc. controlled from XML execute script
output
public void output(org.w3c.dom.Element executeChild)
throws java.lang.Exception
getAtomArray
public AtomArray getAtomArray()
- packs current Atoms into an AtomArray
- Specified by:
- getAtomArray in interface Molecule
- Returns:
- AtomArray the atoms; empty AtomArray if none
addAtom
public void addAtom(Atom atom)
throws CMLException
- adds the Atom to the Atom content
of the Molecule. The atom is shallow-copied
- Specified by:
- addAtom in interface Molecule
deleteAtom
public void deleteAtom(Atom atom)
throws CMLException
- deletes the Atom from the Atom content of the Molecule.
If atom does not exist, or is in a different Molecule or
is null, no action. Also deletes all HasAtomRefs (Bonds, Angles...)
that refer to atom.
NOTE: This does NOT check the validity of the Molecule after
deletion.
- Specified by:
- deleteAtom in interface Molecule
- Tags copied from interface: Molecule
- Parameters:
Atom - atom to be deleted- Throws:
- CMLException - atom does not belong to this molecule
deleteHasAtomRefs
protected void deleteHasAtomRefs(HasAtomRefs har)
throws CMLException
deleteAtomWithId
public void deleteAtomWithId(java.lang.String id)
throws CMLException
- as above but finds atom by id
getAtomVector
public java.util.Vector getAtomVector()
- extracts ALL the Atoms as a Vector
- Specified by:
- getAtomVector in interface Molecule
- Returns:
- Vector empty Vector if no atoms
getAtomIdTable
public java.util.Hashtable getAtomIdTable()
- Specified by:
- getAtomIdTable in interface Molecule
getAtomById
public Atom getAtomById(java.lang.String id)
- Specified by:
- getAtomById in interface Molecule
getAtomCount
public int getAtomCount()
- Specified by:
- getAtomCount in interface Molecule
getBondArray
public BondArray getBondArray()
- extracts ALL the bonds in a single BondArray.
- Specified by:
- getBondArray in interface Molecule
- Returns:
- BondArray the bonds; empty BondArray if none
getBond
public Bond getBond(Atom atom1,
Atom atom2)
- Description copied from interface: Molecule
- get a bond from the atoms - order is irrelevant
- Specified by:
- getBond in interface Molecule
- Tags copied from interface: Molecule
- Parameters:
Atom - atom1 first atomAtom - atom2 other atom
addBond
public void addBond(Bond bond)
throws CMLException
- adds the Bond to the Bond content
of the Molecule. The bond is shallow-copied
- Specified by:
- addBond in interface Molecule
deleteBond
public void deleteBond(Bond bond)
throws CMLException
- deletes the Bond from the Bond content of the Molecule.
If bond does not exist, or is in a different Molecule or
is null, no action.
- Specified by:
- deleteBond in interface Molecule
- Tags copied from interface: Molecule
- Throws:
- CMLException - bond does not belong to this Molecule
getBondVector
public java.util.Vector getBondVector()
- extracts ALL the Bonds as a Vector
- Specified by:
- getBondVector in interface Molecule
- Returns:
- Vector empty Vector if no bonds
getBondCount
public int getBondCount()
- Specified by:
- getBondCount in interface Molecule
addAngle
public void addAngle(Angle angle)
- adds the Angle to the Angle content
of the Molecule. The angle is shallow-copied
- Specified by:
- addAngle in interface Molecule
deleteAngle
public void deleteAngle(Angle angle)
- deletes the Angle from the Angle content of the Molecule.
If angle does not exist, or is in a different Molecule or
is null, no action.
- Specified by:
- deleteAngle in interface Molecule
getAngleVector
public java.util.Vector getAngleVector()
- extracts ALL the Angles as a Vector
- Specified by:
- getAngleVector in interface Molecule
- Returns:
- Vector empty Vector if no angles
addTorsion
public void addTorsion(Torsion torsion)
- adds the Torsion to the Torsion content
of the Molecule. The torsion is shallow-copied
- Specified by:
- addTorsion in interface Molecule
deleteTorsion
public void deleteTorsion(Torsion torsion)
- deletes the Torsion from the Torsion content of the Molecule.
If torsion does not exist, or is in a different Molecule or
is null, no action.
- Specified by:
- deleteTorsion in interface Molecule
getTorsionVector
public java.util.Vector getTorsionVector()
- extracts ALL the Torsions as a Vector
- Specified by:
- getTorsionVector in interface Molecule
- Returns:
- Vector empty Vector if no torsions
getCrystal
public Crystal getCrystal()
- extracts Crystal if present
- Specified by:
- getCrystal in interface Molecule
- Returns:
- Crystal. null if none
setCrystal
public void setCrystal(Crystal crystal)
- replaces Crystal information; if null, deletes any
existing Crystal
- Specified by:
- setCrystal in interface Molecule
- Parameters:
Crystal - the crystallographic information
getSequence
public Sequence getSequence()
- extracts the FIRST Sequence if any present
- Specified by:
- getSequence in interface Molecule
- Returns:
- Sequence. null if none
addSequence
public void addSequence(Sequence sequence)
- Adds a Sequence to the Molecule content.
- Specified by:
- addSequence in interface Molecule
- Parameters:
Sequence - the sequence to be added. null is ignored
deleteSequence
public void deleteSequence(Sequence sequence)
- Deletes a Sequence from the Molecule content.
- Specified by:
- deleteSequence in interface Molecule
- Parameters:
Sequence - the sequence to be deleted. null is ignored
getSequenceVector
public java.util.Vector getSequenceVector()
- extracts ALL the Sequences as a Vector
- Specified by:
- getSequenceVector in interface Molecule
- Returns:
- Vector empty Vector if no Sequences
getFeature
public Feature getFeature()
- extracts the FIRST Feature if any present
- Specified by:
- getFeature in interface Molecule
- Returns:
- Feature. null if none
addFeature
public void addFeature(Feature feature)
- Adds a Feature to the Molecule content.
- Specified by:
- addFeature in interface Molecule
- Parameters:
Feature - the feature to be added. null is ignored
deleteFeature
public void deleteFeature(Feature feature)
- Deletes a Feature from the Molecule content.
- Specified by:
- deleteFeature in interface Molecule
- Parameters:
Feature - the feature to be deleted. null is ignored
getFeatureVector
public java.util.Vector getFeatureVector()
- extracts ALL the Features as a Vector
- Specified by:
- getFeatureVector in interface Molecule
- Returns:
- Vector empty Vector if no Features
addElectron
public void addElectron(Electron electron)
- Adds a Electron to the Molecule content.
- Specified by:
- addElectron in interface Molecule
- Parameters:
Electron - the electron to be added. null is ignored
deleteElectron
public void deleteElectron(Electron electron)
- Deletes a Electron from the Molecule content.
- Specified by:
- deleteElectron in interface Molecule
- Parameters:
Electron - the electron to be deleted. null is ignored
getElectronVector
public java.util.Vector getElectronVector()
- extracts ALL the Electrons as a Vector
- Specified by:
- getElectronVector in interface Molecule
- Returns:
- Vector empty Vector if no Electrons
addMolecule
public void addMolecule(Molecule molecule)
- Adds a Molecule to the Molecule content.
- Specified by:
- addMolecule in interface Molecule
- Parameters:
Molecule - the molecule to be added. null is ignored
deleteMolecule
public void deleteMolecule(Molecule molecule)
- Deletes a Molecule from the Molecule content.
- Specified by:
- deleteMolecule in interface Molecule
- Parameters:
Molecule - the molecule to be deleted. null is ignored
getMoleculeVector
public java.util.Vector getMoleculeVector()
- extracts ALL the Molecules as a Vector
- Specified by:
- getMoleculeVector in interface Molecule
- Returns:
- Vector empty Vector if no Molecules
setCount
public void setCount(double count)
- Specified by:
- setCount in interface Molecule
getCount
public double getCount()
- Specified by:
- getCount in interface Molecule
processDOM
public void processDOM()
throws CMLException
- Description copied from interface: PMRElement
- carries out class-specific processing for subclasses of PMRElement.
The default for a generic PMRElement is no-op. Often creates an internal model
- Overrides:
- processDOM in class CMLBaseImpl
- Tags copied from class: PMRElementImpl
- Throws:
- java.lang.Exception - these can be of many kinds and may include class-specific ones
updateDOMHasCount
public void updateDOMHasCount()
updateDOM
public void updateDOM()
throws CMLException
- when the DOM is built from legacy the tree may be delayed. This
should be called after legacy has been read in - will recursively
call its children to update them. Forces complete rebuild
- Overrides:
- updateDOM in class CMLBaseImpl
debug
public void debug(java.io.Writer w)
throws java.io.IOException
- output debug info to Writer
- Overrides:
- debug in class CMLBaseImpl
- Parameters:
Writer - w output