org.jmol.adapter.readers.xml
Class XmlReader

java.lang.Object
  extended by org.jmol.adapter.smarter.AtomSetCollectionReader
      extended by org.jmol.adapter.readers.xml.XmlReader
Direct Known Subclasses:
XmlArgusReader, XmlChem3dReader, XmlCmlReader, XmlOdysseyReader, XmlQEReader, XmlVaspReader, XmlXsdReader

public class XmlReader
extends AtomSetCollectionReader

A generic XML reader template -- by itself, does nothing. The actual readers are XmlCmlReader, XmlMolproReader (which is an extension of XmlCmlReader, XmlChem3dReader, and XmlOdysseyReader, which is wholely different. XmlReader takes all XML streams, whether from a file reader or from DOM. This class functions as a resolver, since it: (1) identifying the specific strain of XML to be handled, and (2) passing the responsibility on to the correct format-specific XML readers. There are parallel entry points and handler methods for reader and DOM. Each format-specific XML reader then assigns its own handler to manage the parsing of elements. In addition, this class handles generic XML tag parsing. XmlReader.JmolXmlHandler extends DefaultHandler is the generic interface to both reader and DOM element parsing. XmlCmlReader extends XmlReader and is where I'd like Andrew to take charge. XmlCmlReader.CmlHandler extends XmlReader.JmolXmlHandler is generic XmlMolproReader extends XmlCmlReader. If you feel like expanding on that, feel free. XmlMolproReader.MolprolHandler extends XmlCmlReader.CmlHandler adds Molpro-specific XML tag processing XmlChem3dReader extends XmlReader. That one is simple; no need to expand on it at this time. XmlChem3dReader.Chem3dHandler extends XmlReader.JmolXmlHandler is generic XmlOdysseyReader extends XmlReader. That one is simple; no need to expand on it at this time. XmlOdysseyReader.OdysseyHandler extends XmlReader.JmolXmlHandler is generic Note that the tag processing routines are shared between SAX and DOM processors. This means that attributes must be transformed from either Attributes (SAX) or JSObjects (DOM) to Hashtable name:value pairs. This is taken care of in JmolXmlHandler for all readers. TODO 27/8/06: Several aspects of CifReader are NOT YET implemented here. These include loading a specific model when there are several, applying the symmetry, and loading fractional coordinates. [DONE for CML reader 2/2007 RMH] The DOM reader is NOT CHECKED OVER, and I do not think that it supports reading characters between start/end tags: characters If you work on this, please read formats other than CML into DOM so that we can see that that works as well. Test files: molpro: vib.xml odyssey: water.xodydata cml: a wide variety of files in data-files. Feel free to prune if some are not of use. -Bob Hanson


Nested Class Summary
static class XmlReader.DummyResolver
           
 class XmlReader.JmolXmlHandler
           
 
Field Summary
protected  Atom atom
           
protected  java.lang.String chars
           
(package private)  java.lang.String[] implementedAttributes
           
protected  boolean keepChars
           
protected  XmlReader parent
           
 
Fields inherited from class org.jmol.adapter.smarter.AtomSetCollectionReader
addVibrations, ANGSTROMS_PER_BOHR, applySymmetryToBonds, atomSetCollection, bsFilter, bsModels, calculationType, continuing, desiredModelNumber, desiredVibrationNumber, doApplySymmetry, doc, doCheckUnitCell, doPackUnitCell, doProcessLines, filter, filterHetero, getHeader, haveModel, havePartialChargeFilter, htParams, ignoreFileSpaceGroupName, ignoreFileSymmetryOperators, ignoreFileUnitCell, iHaveFractionalCoordinates, iHaveSymmetryOperators, iHaveUnitCell, isBinary, isSequential, isTrajectory, latticeCells, line, matUnitCellOrientation, modelNumber, next, notionalUnitCell, os, prevline, ptLine, reader, readerName, readMolecularOrbitals, spaceGroup, stateScriptVersionInt, supercell, symmetry, templateAtomCount, useAltNames, vibrationNumber, viewer
 
Constructor Summary
XmlReader()
           
 
Method Summary
private  org.xml.sax.XMLReader allocateXmlReader14()
           
private  org.xml.sax.XMLReader allocateXmlReaderAelfred2()
           
private  java.lang.Object getXmlReader()
           
private  org.xml.sax.XMLReader getXMLReader()
           
 void initializeReader()
           
protected  void parseReaderXML(org.xml.sax.XMLReader xmlReader)
           
protected  void processEndElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
protected  void processStartElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, java.util.Map<java.lang.String,java.lang.String> atts)
           
protected  void processXml(java.lang.Object DOMNode)
           
private  java.lang.Object processXml(org.xml.sax.XMLReader xmlReader)
           
protected  void processXml(XmlReader parent, AtomSetCollection atomSetCollection, java.io.BufferedReader reader, netscape.javascript.JSObject DOMNode)
           
protected  void processXml(XmlReader parent, AtomSetCollection atomSetCollection, java.io.BufferedReader reader, org.xml.sax.XMLReader xmlReader)
           
protected  void setKeepChars(boolean TF)
           
 
Methods inherited from class org.jmol.adapter.smarter.AtomSetCollectionReader
addJmolScript, addPrimitiveLatticeVector, addSites, addSiteScript, appendLoadNote, applySymmetryAndSetTrajectory, checkFilter, checkLastModel, checkLine, checkLineForScript, checkLineForScript, clearUnitCell, cloneLastAtomSet, discardLinesUntilBlank, discardLinesUntilContains, discardLinesUntilContains, discardLinesUntilNonBlank, discardLinesUntilStartsWith, doGetModel, doGetVibration, fillDataBlock, fillDataBlock, fillFloatArray, fillFrequencyData, filterAtom, finalizeReader, getElementSymbol, getFortranFormatLengths, getStrings, getSymmetry, getTokens, getTokens, getTokens, getTokensFloat, initializeSymmetry, isLastModel, newAtomSet, parseFloat, parseFloat, parseFloat, parseInt, parseInt, parseInt, parseInt, parseStringInfestedFloatArray, parseToken, parseToken, parseToken, parseTokenNext, parseTrimmed, parseTrimmed, processBinaryDocument, read3Vectors, readData, readLine, readLines, set2D, setAtomCoord, setAtomCoord, setFilter, setFractionalCoordinates, setIsPDB, setMOData, setPdb, setSpaceGroupName, setSymmetryOperator, setTransform, setUnitCell, setUnitCellItem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected XmlReader parent

atom

protected Atom atom

implementedAttributes

java.lang.String[] implementedAttributes

keepChars

protected boolean keepChars

chars

protected java.lang.String chars
Constructor Detail

XmlReader

public XmlReader()
Method Detail

initializeReader

public void initializeReader()
                      throws java.lang.Exception
Overrides:
initializeReader in class AtomSetCollectionReader
Throws:
java.lang.Exception

getXMLReader

private org.xml.sax.XMLReader getXMLReader()

allocateXmlReader14

private org.xml.sax.XMLReader allocateXmlReader14()

allocateXmlReaderAelfred2

private org.xml.sax.XMLReader allocateXmlReaderAelfred2()

processXml

private java.lang.Object processXml(org.xml.sax.XMLReader xmlReader)
                             throws java.lang.Exception
Throws:
java.lang.Exception

getXmlReader

private java.lang.Object getXmlReader()

processXml

protected void processXml(XmlReader parent,
                          AtomSetCollection atomSetCollection,
                          java.io.BufferedReader reader,
                          org.xml.sax.XMLReader xmlReader)
Parameters:
parent -
atomSetCollection -
reader -
xmlReader -

parseReaderXML

protected void parseReaderXML(org.xml.sax.XMLReader xmlReader)

processXml

protected void processXml(java.lang.Object DOMNode)
Overrides:
processXml in class AtomSetCollectionReader

processXml

protected void processXml(XmlReader parent,
                          AtomSetCollection atomSetCollection,
                          java.io.BufferedReader reader,
                          netscape.javascript.JSObject DOMNode)
Parameters:
parent -
atomSetCollection -
reader -
DOMNode -

processStartElement

protected void processStartElement(java.lang.String namespaceURI,
                                   java.lang.String localName,
                                   java.lang.String qName,
                                   java.util.Map<java.lang.String,java.lang.String> atts)
Parameters:
namespaceURI -
localName -
qName -
atts -

setKeepChars

protected void setKeepChars(boolean TF)

processEndElement

protected void processEndElement(java.lang.String uri,
                                 java.lang.String localName,
                                 java.lang.String qName)
Parameters:
uri -
localName -
qName -