XmlCmlReader
Date: 2019-10-22

org.jmol.adapter.readers.xml

## Class XmlCmlReader

- java.lang.Object
- - org.jmol.adapter.smarter.AtomSetCollectionReader
  - - org.jmol.adapter.readers.xml.XmlReader
    - - org.jmol.adapter.readers.xml.XmlCmlReader

- All Implemented Interfaces:
    javajs.api.GenericLineReader
  Direct Known Subclasses:
    XmlMOReader

      public class XmlCmlReader
      extends XmlReader

  A CML2 Reader - If passed a bufferedReader (from a file or inline string), we generate a SAX parser and use callbacks to construct an AtomSetCollection. If passed a JSObject (from LiveConnect) we treat it as a JS DOM tree, and walk the tree, (using the same processing as the SAX parser) to construct the AtomSetCollection. symmetry added by Bob Hanson: setSpaceGroupName() setUnitCellItem() setFractionalCoordinates() setAtomCoord() applySymmetryAndSetTrajectory() "isotope" added 4/6/2009 Bob Hanson

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private int` | `aaLen`
    `protected static int` | `ASSOCIATION` state constants
    `private Atom[]` | `atomArray`
    `private java.util.Properties` | `atomIdNames`
    `private int` | `atomIndex0`
    `private Bond[]` | `bondArray`
    `private int` | `bondCount`
    `private java.lang.String` | `cellParameterType`
    `private boolean` | `checkedSerial`
    `protected static int` | `CML` state constants
    `protected static int` | `CRYSTAL` state constants
    `protected static int` | `CRYSTAL_SCALAR` state constants
    `protected static int` | `CRYSTAL_SYMMETRY` state constants
    `protected static int` | `CRYSTAL_SYMMETRY_TRANSFORM3` state constants
    `private javajs.util.BS` | `deleteAtoms`
    `private boolean` | `embeddedCrystal`
    `private boolean` | `haveMolecule`
    `protected java.util.Map<java.lang.String,java.lang.Object>` | `htModelAtomMap`
    `private boolean` | `isSerial`
    `private javajs.util.Lst<java.lang.String[]>` | `joinList`
    `protected static int` | `LATTICE_VECTOR` state constants
    `private int` | `latticeVectorPtr`
    `private java.lang.String` | `localSpaceGroupName`
    `private java.util.Map<Atom,java.lang.String>` | `mapRtoA`
    `protected static int` | `MODULE` state constants
    `private int` | `moduleNestingLevel`
    `protected static int` | `MOLECULE` state constants
    `protected static int` | `MOLECULE_ATOM` state constants
    `protected static int` | `MOLECULE_ATOM_ARRAY` state constants
    `protected static int` | `MOLECULE_ATOM_BUILTIN` state constants
    `protected static int` | `MOLECULE_ATOM_SCALAR` state constants
    `protected static int` | `MOLECULE_BOND` state constants
    `protected static int` | `MOLECULE_BOND_ARRAY` state constants
    `protected static int` | `MOLECULE_BOND_BUILTIN` state constants
    `protected static int` | `MOLECULE_BOND_STEREO` state constants
    `protected static int` | `MOLECULE_FORMULA` state constants
    `protected java.lang.String` | `moleculeID`
    `private int` | `moleculeNesting`
    `private boolean` | `optimize2d`
    `protected boolean` | `processing`
    `private java.lang.String` | `scalarDictRef`
    `private java.lang.String` | `scalarDictValue`
    `private java.lang.String` | `scalarTitle`
    `protected static int` | `START` state constants
    `protected int` | `state`
    `protected static int` | `SYMMETRY` state constants
    `private int` | `tokenCount`
    `protected java.lang.String[]` | `tokens`
    `private static java.lang.String[]` | `unitCellParamTags`

    - ### Fields inherited from class org.jmol.adapter.readers.xml.XmlReader

      `atom, atts, bond, chars, keepChars, parent`

    - ### Fields inherited from class org.jmol.adapter.smarter.AtomSetCollectionReader

      `addedData, addedDataKey, addVibrations, allowPDBFilter, ANGSTROMS_PER_BOHR, applySymmetryToBonds, asc, baseAtomIndex, binaryDoc, bsFilter, bsModels, calculationType, continuing, debugging, desiredModelNumber, desiredSpaceGroupIndex, desiredVibrationNumber, doApplySymmetry, doCentralize, doCheckUnitCell, doConvertToFractional, doPackUnitCell, doProcessLines, doReadMolecularOrbitals, dssr, fileName, fileOffset, filePath, fileScaling, fillRange, filter, filterHetero, fixJavaFloat, forcePacked, getHeader, haveAtomFilter, haveModel, havePartialChargeFilter, htParams, ignoreFileSpaceGroupName, ignoreFileSymmetryOperators, ignoreFileUnitCell, ignoreStructure, iHaveFractionalCoordinates, iHaveSymmetryOperators, iHaveUnitCell, isBinary, isConcatenated, isDSSP1, isFinalized, isMolecular, isPrimitive, isSequential, isTrajectory, latticeCells, latticeScaling, latticeType, line, lstNCS, matUnitCellOrientation, modDim, modelNumber, ms, mustFinalizeModelSet, next, out, packingError, prevline, primitiveToCrystal, ptLine, ptSupercell, reader, readerName, requiresBSFilter, reverseModels, rotateHexCell, sgName, stateScriptVersionInt, strSupercell, symmetry, templateAtomCount, thisBiomolecule, trajectorySteps, unitCellOffset, unitCellParams, useAltNames, useFileModelNumbers, validation, vibrationNumber, vibsFractional, vwr`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XmlCmlReader()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private void` | `addAtom(Atom atom)`
    `private void` | `addBond(Bond bond)`
    `private void` | `addNewBond(java.lang.String a1, java.lang.String a2, int order)`
    `void` | `applySymmetryAndSetTrajectory()`
    `(package private) void` | `breakOutAtomTokens(java.lang.String str)`
    `(package private) void` | `breakOutBondTokens(java.lang.String str)`
    `private void` | `breakOutTokens(java.lang.String str)`
    `(package private) void` | `checkAtomArrayLength(int newAtomCount)`
    `(package private) void` | `checkBondArrayLength(int newBondCount)`
    `private boolean` | `checkBondToR(java.lang.String a1name, java.lang.String a2name)` Checks to see if we have a bond to R and, if so, adds this R atom as a key to its attached atom
    `private void` | `checkUnitCellItem(java.lang.String[] tags, java.lang.String value)`
    `private void` | `createNewAtomSet()`
    `void` | `endDocument()`
    `private java.lang.String` | `fixSerialName(java.lang.String a)`
    `private int` | `getAtomIndex(java.lang.String label)`
    `private void` | `getDictRefValue()`
    `private int` | `parseBondToken(java.lang.String str)`
    `void` | `processEnd2(java.lang.String name)`
    `(package private) void` | `processEndElement(java.lang.String name)`
    `protected void` | `processStart2(java.lang.String name)`
    `void` | `processStartElement(java.lang.String name, java.lang.String nodeName)`
    `protected void` | `processXml(XmlReader parent, java.lang.Object saxReader)` the current state
    `private void` | `setAtomNames()`

    - ### Methods inherited from class org.jmol.adapter.readers.xml.XmlReader

      `createDomNodeJS, initCML, initializeReader, processDOM, processXml2, setKeepChars`

    - ### Methods inherited from class org.jmol.adapter.smarter.AtomSetCollectionReader

      `addAtomXYZSymName, addExplicitLatticeVector, addJmolScript, addSites, addSiteScript, appendLoadNote, appendUunitCellInfo, applySymTrajASCR, checkCurrentLineForScript, checkFilterKey, checkLastModel, checkLine, checkLineForScript, clearUnitCell, cloneLastAtomSet, discardLinesUntilBlank, discardLinesUntilContains, discardLinesUntilContains2, discardLinesUntilNonBlank, discardLinesUntilStartsWith, discardPreviousAtoms, doGetModel, doGetVibration, doPreSymmetry, fill3x3, fillDataBlock, fillDataBlockFixed, fillFloatArray, fillFrequencyData, filterAtom, filterReject, finalizeMOData, finalizeModelSet, finalizeReaderASCR, finalizeSubclassReader, finalizeSubclassSymmetry, forceSymmetry, fractionalizeCoordinates, getElementSymbol, getFilter, getFortranFormatLengths, getInterface, getNewSymmetry, getStrings, getSymmetry, getTokens, getTokensFloat, initializeSymmetry, initializeSymmetryOptions, initializeTrajectoryFile, isLastModel, newAtomSet, parseFloat, parseFloatRange, parseFloatStr, parseInt, parseIntAt, parseIntRange, parseIntStr, parseToken, parseTokenNext, parseTokenRange, parseTokenStr, processBinaryDocument, rd, read3Vectors, readDataObject, readLines, readNextLine, rejectAtomName, RL, set2D, setAtomCoord, setAtomCoordScaled, setAtomCoordTokens, setAtomCoordXYZ, setChainID, setElementAndIsotope, setFilter, setFilterAtomTypeStr, setFractionalCoordinates, setIsPDB, setLoadNote, setModelPDB, setSpaceGroupName, setSymmetryOperator, setTransform, setUnitCell, setUnitCellItem, setup, setupASCR`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### scalarDictRef

          private java.lang.String scalarDictRef

    - #### scalarDictValue

          private java.lang.String scalarDictValue

    - #### scalarTitle

          private java.lang.String scalarTitle

    - #### cellParameterType

          private java.lang.String cellParameterType

    - #### checkedSerial

          private boolean checkedSerial

    - #### isSerial

          private boolean isSerial

    - #### moleculeNesting

          private int moleculeNesting

    - #### latticeVectorPtr

          private int latticeVectorPtr

    - #### embeddedCrystal

          private boolean embeddedCrystal

    - #### atomIdNames

          private java.util.Properties atomIdNames

    - #### tokens

          protected java.lang.String[] tokens

    - #### aaLen

          private int aaLen

    - #### atomArray

          private Atom[] atomArray

    - #### bondCount

          private int bondCount

    - #### bondArray

          private Bond[] bondArray

    - #### tokenCount

          private int tokenCount

    - #### moduleNestingLevel

          private int moduleNestingLevel

    - #### haveMolecule

          private boolean haveMolecule

    - #### localSpaceGroupName

          private java.lang.String localSpaceGroupName

    - #### processing

          protected boolean processing

    - #### state

          protected int state

    - #### atomIndex0

          private int atomIndex0

    - #### joinList

          private javajs.util.Lst<java.lang.String[]> joinList

    - #### mapRtoA

          private java.util.Map<Atom,java.lang.String> mapRtoA

    - #### deleteAtoms

          private javajs.util.BS deleteAtoms

    - #### moleculeID

          protected java.lang.String moleculeID

    - #### htModelAtomMap

          protected java.util.Map<java.lang.String,java.lang.Object> htModelAtomMap

    - #### optimize2d

          private boolean optimize2d

    - #### START

          protected static final int START

      state constants
      See Also:
        Constant Field Values

    - #### CML

          protected static final int CML

      state constants
      See Also:
        Constant Field Values

    - #### CRYSTAL

          protected static final int CRYSTAL

      state constants
      See Also:
        Constant Field Values

    - #### CRYSTAL_SCALAR

          protected static final int CRYSTAL_SCALAR

      state constants
      See Also:
        Constant Field Values

    - #### CRYSTAL_SYMMETRY

          protected static final int CRYSTAL_SYMMETRY

      state constants
      See Also:
        Constant Field Values

    - #### CRYSTAL_SYMMETRY_TRANSFORM3

          protected static final int CRYSTAL_SYMMETRY_TRANSFORM3

      state constants
      See Also:
        Constant Field Values

    - #### MOLECULE

          protected static final int MOLECULE

      state constants
      See Also:
        Constant Field Values

    - #### MOLECULE_ATOM_ARRAY

          protected static final int MOLECULE_ATOM_ARRAY

      state constants
      See Also:
        Constant Field Values

    - #### MOLECULE_ATOM

          protected static final int MOLECULE_ATOM

      state constants
      See Also:
        Constant Field Values

    - #### MOLECULE_ATOM_SCALAR

          protected static final int MOLECULE_ATOM_SCALAR

      state constants
      See Also:
        Constant Field Values

    - #### MOLECULE_BOND_ARRAY

          protected static final int MOLECULE_BOND_ARRAY

      state constants
      See Also:
        Constant Field Values

    - #### MOLECULE_BOND

          protected static final int MOLECULE_BOND

      state constants
      See Also:
        Constant Field Values

    - #### MOLECULE_BOND_STEREO

          protected static final int MOLECULE_BOND_STEREO

      state constants
      See Also:
        Constant Field Values

    - #### MOLECULE_FORMULA

          protected static final int MOLECULE_FORMULA

      state constants
      See Also:
        Constant Field Values

    - #### MOLECULE_ATOM_BUILTIN

          protected static final int MOLECULE_ATOM_BUILTIN

      state constants
      See Also:
        Constant Field Values

    - #### MOLECULE_BOND_BUILTIN

          protected static final int MOLECULE_BOND_BUILTIN

      state constants
      See Also:
        Constant Field Values

    - #### MODULE

          protected static final int MODULE

      state constants
      See Also:
        Constant Field Values

    - #### SYMMETRY

          protected static final int SYMMETRY

      state constants
      See Also:
        Constant Field Values

    - #### LATTICE_VECTOR

          protected static final int LATTICE_VECTOR

      state constants
      See Also:
        Constant Field Values

    - #### ASSOCIATION

          protected static final int ASSOCIATION

      state constants
      See Also:
        Constant Field Values

    - #### unitCellParamTags

          private static final java.lang.String[] unitCellParamTags

  - ### Constructor Detail

    - #### XmlCmlReader

          public XmlCmlReader()

  - ### Method Detail

    - #### processXml

          protected void processXml(XmlReader parent,
                                    java.lang.Object saxReader)
                             throws java.lang.Exception

      the current state
      Overrides:
        `processXml` in class `XmlReader`
      Throws:
        `java.lang.Exception`

    - #### processStartElement

          public void processStartElement(java.lang.String name,
                                          java.lang.String nodeName)

      Overrides:
        `processStartElement` in class `XmlReader`
        `nodeName` - TODO

    - #### processStart2

          protected void processStart2(java.lang.String name)

    - #### getAtomIndex

          private int getAtomIndex(java.lang.String label)

    - #### processEndElement

          void processEndElement(java.lang.String name)

      Overrides:
        `processEndElement` in class `XmlReader`

    - #### processEnd2

          public void processEnd2(java.lang.String name)

    - #### addBond

          private void addBond(Bond bond)

    - #### checkBondToR

          private boolean checkBondToR(java.lang.String a1name,
                                       java.lang.String a2name)

      Checks to see if we have a bond to R and, if so, adds this R atom as a key to its attached atom
      Parameters:
        `a1name` -
        `a2name` -
      Returns:
        true if handled so no need to add a bond

    - #### setAtomNames

          private void setAtomNames()

    - #### addNewBond

          private void addNewBond(java.lang.String a1,
                                  java.lang.String a2,
                                  int order)

    - #### fixSerialName

          private java.lang.String fixSerialName(java.lang.String a)

    - #### getDictRefValue

          private void getDictRefValue()

    - #### checkUnitCellItem

          private void checkUnitCellItem(java.lang.String[] tags,
                                         java.lang.String value)

    - #### addAtom

          private void addAtom(Atom atom)

    - #### parseBondToken

          private int parseBondToken(java.lang.String str)

    - #### breakOutTokens

          private void breakOutTokens(java.lang.String str)

    - #### breakOutAtomTokens

          void breakOutAtomTokens(java.lang.String str)

    - #### checkAtomArrayLength

          void checkAtomArrayLength(int newAtomCount)

    - #### breakOutBondTokens

          void breakOutBondTokens(java.lang.String str)

    - #### checkBondArrayLength

          void checkBondArrayLength(int newBondCount)

    - #### createNewAtomSet

          private void createNewAtomSet()

    - #### applySymmetryAndSetTrajectory

          public void applySymmetryAndSetTrajectory()

      Overrides:
        `applySymmetryAndSetTrajectory` in class `XmlReader`

    - #### endDocument

          public void endDocument()

      Overrides:
        `endDocument` in class `XmlReader`