Package xal.model.xml
Class LatticeXmlParser
java.lang.Object
xal.model.xml.LatticeXmlParser
Utility class for building an XAL Model Lattice from a corresponding XML
file.
- Author:
- Christopher Allen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Attributes for XAL/MODEL/LATTICE DTDstatic final String
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static void
addParameter
(DataAdaptor dapt, String strName, String strType, String strValue) Add a parameter child to a DataAdaptorprotected String
attrValue
(DataAdaptor dapt, String strAttrName) Returns the attribute value string from a DataAdaptor interface.protected 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 componentsprotected void
loadElement
(IElement elem, DataAdaptor daptElem) Load an IElement object with its parameters specified in the data adaptor.static Lattice
Parses the XML file specified by the supplied URI.parseAdaptor
(DataAdaptor adaptor) Parses the given data source for modeling lattice information and creates the corresponding lattice.static Lattice
parseDataAdaptor
(DataAdaptor adaptor) Parses the supplied DataAdaptor and return aLattice
object configured according to the Adaptor.Parse an XAL Model lattice file and build the corresponding Lattice object.
-
Field Details
-
ELEM_LATT
Attributes for XAL/MODEL/LATTICE DTD- See Also:
-
ELEM_SEQ
- See Also:
-
ELEM_ELEM
- See Also:
-
ELEM_PARAM
- See Also:
-
ELEM_COMM
- See Also:
-
ATTR_ID
- See Also:
-
ATTR_LEN
- See Also:
-
ATTR_VER
- See Also:
-
ATTR_AUTH
- See Also:
-
ATTR_DATE
- See Also:
-
ATTR_TEXT
- See Also:
-
ATTR_NAME
- See Also:
-
ATTR_TYPE
- See Also:
-
ATTR_VAL
- See Also:
-
ATTR_SEP
- See Also:
-
-
Constructor Details
-
LatticeXmlParser
public LatticeXmlParser()
-
-
Method Details
-
parse
Parses the XML file specified by the supplied URI. Return aLattice
object configured according to the file.- Parameters:
fileUri
- the URI specifying the XML file to parsebolValidate
- apply XML DTD validation- Returns:
- the lattice object described by the XML file
- Throws:
ParsingException
- An exception was encountered in parsing
-
parseDataAdaptor
Parses the supplied DataAdaptor and return aLattice
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
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 filebolValidate
- apply XML DTD validation- Returns:
- Lattice object built according to file contents
- Throws:
ParsingException
- An exception was encountered in parsing
-
parseAdaptor
Parses the given data source for modeling lattice information and creates the corresponding lattice.- Parameters:
adaptor
- data source containing the modeling lattice- Returns:
- model lattice object created from the given data source
- Throws:
ParsingException
- general format exception- Since:
- Apr 13, 2011
-
buildSequence
protected ElementSeq buildSequence(DataAdaptor daptSeq) throws DataFormatException, NumberFormatException, ClassNotFoundException, InstantiationException, 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 specificationNumberFormatException
- numeric parameter is malformed and unparsableClassNotFoundException
- an unknown Element type was encounteredInstantiationException
- unable to instantiate an IElement instanceNoSuchMethodException
- unknown or invalid Parameter for an Element was encountered
-
buildComment
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 InstantiationException, ClassNotFoundException, DataFormatException, NoSuchMethodException 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:
InstantiationException
- unable to instantiate an IElement instanceClassNotFoundException
- an unknown IElement type was encounteredDataFormatException
- bad parameter format encounteredNoSuchMethodException
- unknown or invalid Parameter for an IElement was encountered
-
loadComposite
protected void loadComposite(IComposite secNew, DataAdaptor daptSeq) throws DataFormatException, NumberFormatException, ClassNotFoundException, NoSuchMethodException, InstantiationException Load an ElementSeq object with it's components- Parameters:
secNew
- ElementSeq object to be loadeddaptSeq
- data adaptor containing sequence information- Throws:
ClassNotFoundException
- an unknown Element type was encounteredDataFormatException
- bad parameter formatNumberFormatException
- bad number format in parameter valueNoSuchMethodException
- unknown or invalid Parameter for an Element was encounteredInstantiationException
-
loadElement
protected void loadElement(IElement elem, DataAdaptor daptElem) throws DataFormatException, NoSuchMethodException, NumberFormatException Load an IElement object with its parameters specified in the data adaptor.- Parameters:
elem
- IElement object to have parameter assigneddaptElem
- data adaptor containing all parameter information for element- Throws:
DataFormatException
- bad parameter formatNumberFormatException
- numeric value was malformed and unparseableNoSuchMethodException
- unknown or invalid Parameter for an Element was encountered
-
attrValue
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, String strName, String strType, String strValue) Add a parameter child to a DataAdaptor
-