gov.sns.xal.model.xml
Class LatticeXmlParser

java.lang.Object
  |
  +--gov.sns.xal.model.xml.LatticeXmlParser

public class LatticeXmlParser
extends java.lang.Object

Utility class for building an XAL Model Lattice from a corresponding XML file.


Field Summary
static java.lang.String s_strAttrAuth
           
static java.lang.String s_strAttrDate
           
static java.lang.String s_strAttrId
           
static java.lang.String s_strAttrLen
           
static java.lang.String s_strAttrName
           
static java.lang.String s_strAttrSep
           
static java.lang.String s_strAttrText
           
static java.lang.String s_strAttrType
           
static java.lang.String s_strAttrVal
           
static java.lang.String s_strAttrVer
           
static java.lang.String s_strElemComm
           
static java.lang.String s_strElemElem
           
static java.lang.String s_strElemLatt
          Attributes for XAL/MODEL/LATTICE DTD
static java.lang.String s_strElemParam
           
static java.lang.String s_strElemSeq
           
 
Constructor Summary
LatticeXmlParser()
          Creates a new instance of LatticeXmlParser
 
Method Summary
protected static void addParameter(DataAdaptor dapt, java.lang.String strName, java.lang.String strType, java.lang.String strValue)
          Add a parameter child to a DataAdaptor
protected  java.lang.String attrValue(DataAdaptor dapt, java.lang.String strAttrName)
          Returns the attribute value string from a DataAdaptor interface.
protected  java.lang.String buildComment(DataAdaptor daptComm)
          Return the comment string from a comment element within a sequence.
protected  IElement buildElement(DataAdaptor daptElem)
          Build a IElement object according to parameters specified in a data adaptor.
protected  ElementSeq buildSequence(DataAdaptor daptSeq)
          Build a sequence with its elements from a data source represented by a DataAdaptor interface.
protected  void loadComposite(IComposite secNew, DataAdaptor daptSeq)
          Load an ElementSeq object with it's components
protected  void loadElement(IElement elem, DataAdaptor daptElem)
          Load an IElement object with its parameters specified in the data adaptor.
static Lattice parse(java.lang.String fileUri, boolean bolValidate)
          Parses the XML file specified by the supplied URI.
 Lattice parseAdaptor(DataAdaptor adaptor)
           
static Lattice parseDataAdaptor(DataAdaptor adaptor)
          Parses the supplied DataAdaptor and return a Lattice object configured according to the Adaptor.
 Lattice parseUrl(java.lang.String strFile, boolean bolValidate)
          Parse an XAL Model lattice file and build the corresponding Lattice object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_strElemLatt

public static final java.lang.String s_strElemLatt
Attributes for XAL/MODEL/LATTICE DTD

See Also:
Constant Field Values

s_strElemSeq

public static final java.lang.String s_strElemSeq
See Also:
Constant Field Values

s_strElemElem

public static final java.lang.String s_strElemElem
See Also:
Constant Field Values

s_strElemParam

public static final java.lang.String s_strElemParam
See Also:
Constant Field Values

s_strElemComm

public static final java.lang.String s_strElemComm
See Also:
Constant Field Values

s_strAttrId

public static final java.lang.String s_strAttrId
See Also:
Constant Field Values

s_strAttrLen

public static final java.lang.String s_strAttrLen
See Also:
Constant Field Values

s_strAttrVer

public static final java.lang.String s_strAttrVer
See Also:
Constant Field Values

s_strAttrAuth

public static final java.lang.String s_strAttrAuth
See Also:
Constant Field Values

s_strAttrDate

public static final java.lang.String s_strAttrDate
See Also:
Constant Field Values

s_strAttrText

public static final java.lang.String s_strAttrText
See Also:
Constant Field Values

s_strAttrName

public static final java.lang.String s_strAttrName
See Also:
Constant Field Values

s_strAttrType

public static final java.lang.String s_strAttrType
See Also:
Constant Field Values

s_strAttrVal

public static final java.lang.String s_strAttrVal
See Also:
Constant Field Values

s_strAttrSep

public static final java.lang.String s_strAttrSep
See Also:
Constant Field Values
Constructor Detail

LatticeXmlParser

public LatticeXmlParser()
Creates a new instance of LatticeXmlParser

Method Detail

parse

public static Lattice parse(java.lang.String fileUri,
                            boolean bolValidate)
                     throws ParsingException
Parses the XML file specified by the supplied URI. Return a Lattice object configured according to the file.

Parameters:
fileUri - the URI specifying the XML file to parse
bolValidate - apply XML DTD validation
Returns:
the lattice object described by the XML file
Throws:
ParsingException - An exception was encountered in parsing

parseDataAdaptor

public static Lattice parseDataAdaptor(DataAdaptor adaptor)
                                throws ParsingException
Parses the supplied DataAdaptor and return a Lattice object configured according to the Adaptor.

Parameters:
adaptor - the DataAdaptor containing the Lattice definition
Returns:
the lattice object described by the XML file
Throws:
ParsingException - An exception was encountered in parsing

parseUrl

public Lattice parseUrl(java.lang.String strFile,
                        boolean bolValidate)
                 throws ParsingException
Parse an XAL Model lattice file and build the corresponding Lattice object. The lattice file can be validated by setting the DTD validation flag. The file indicated must be a properly formated XML file.

Parameters:
strFile - URL of lattice description file
bolValidate - apply XML DTD validation
Returns:
Lattice object built according to file contents
Throws:
ParsingException - An exception was encountered in parsing

parseAdaptor

public Lattice parseAdaptor(DataAdaptor adaptor)
                     throws ParsingException
ParsingException

buildSequence

protected ElementSeq buildSequence(DataAdaptor daptSeq)
                            throws DataFormatException,
                                   java.lang.NumberFormatException,
                                   java.lang.ClassNotFoundException,
                                   java.lang.InstantiationException,
                                   java.lang.NoSuchMethodException
Build a sequence with its elements from a data source represented by a DataAdaptor interface. The data adaptor should be configured according to the XAL_MODEL.DTD definition. Therefore, the elements and sub-sequences contained in this sequence need to be represented as child adaptors.

Parameters:
daptSeq - data source containing sequence structure
Returns:
new ElementSeq object built according to data adaptor
Throws:
DataFormatException - data does not conform to XAL_MODEL.DTD specification
java.lang.NumberFormatException - numeric parameter is malformed and unparsable
java.lang.ClassNotFoundException - an unknown Element type was encountered
java.lang.InstantiationException - unable to instantiate an IElement instance
java.lang.NoSuchMethodException - unknown or invalid Parameter for an Element was encountered

buildComment

protected java.lang.String buildComment(DataAdaptor daptComm)
Return the comment string from a comment element within a sequence.

Parameters:
daptComm - data adaptor containing comment element
Returns:
comment string
Throws:
MissingDataException - an attribute was missing from the comment

buildElement

protected IElement buildElement(DataAdaptor daptElem)
                         throws java.lang.InstantiationException,
                                java.lang.ClassNotFoundException,
                                DataFormatException,
                                java.lang.NoSuchMethodException,
                                java.lang.NumberFormatException
Build a IElement object according to parameters specified in a data adaptor.

Parameters:
daptElem - data adaptor containing element parameters
Returns:
new IElement instance specified by the data adaptor
Throws:
java.lang.InstantiationException - unable to instantiate an IElement instance
java.lang.ClassNotFoundException - an unknown IElement type was encountered
DataFormatException - bad parameter format encountered
java.lang.NumberFormatException - bad number format encountered in parameter value
java.lang.NoSuchMethodException - unknown or invalid Parameter for an IElement was encountered

loadComposite

protected void loadComposite(IComposite secNew,
                             DataAdaptor daptSeq)
                      throws DataFormatException,
                             java.lang.NumberFormatException,
                             java.lang.ClassNotFoundException,
                             java.lang.NoSuchMethodException,
                             java.lang.InstantiationException
Load an ElementSeq object with it's components

Parameters:
daptSeq - data adaptor containing sequence information
Throws:
java.lang.ClassNotFoundException - an unknown Element type was encountered
DataFormatException - bad parameter format
java.lang.NumberFormatException - bad number format in parameter value
java.lang.NoSuchMethodException - unknown or invalid Parameter for an Element was encountered
java.lang.InstantiationException

loadElement

protected void loadElement(IElement elem,
                           DataAdaptor daptElem)
                    throws DataFormatException,
                           java.lang.NoSuchMethodException,
                           java.lang.NumberFormatException
Load an IElement object with its parameters specified in the data adaptor.

Parameters:
elem - IElement object to have parameter assigned
daptElem - data adaptor containing all parameter information for element
Throws:
DataFormatException - bad paramter format
java.lang.NumberFormatException - numeric value was malformed and unparseable
java.lang.NoSuchMethodException - unknown or invalid Parameter for an Element was encountered

attrValue

protected java.lang.String attrValue(DataAdaptor dapt,
                                     java.lang.String strAttrName)
                              throws MissingDataException
Returns the attribute value string from a DataAdaptor interface. Performs error checking in that a MissingDataException is thrown if attribute does not exist.

Parameters:
strAttrName - attribute name
Returns:
string value of attribute
Throws:
MissingDataException - specified attribute not present in DataAdaptor

addParameter

protected static void addParameter(DataAdaptor dapt,
                                   java.lang.String strName,
                                   java.lang.String strType,
                                   java.lang.String strValue)
Add a parameter child to a DataAdaptor