Version 1.2 (June 2013)
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | List of all members
utils.XMLParser Class Reference

Class providing methods of parsing the XML simulation protocol file. More...

Inheritance diagram for utils.XMLParser:

Public Member Functions

 XMLParser (Element localRoot)
 Create an XML parser for a given XML local grouping. More...
 
 XMLParser (String fileName)
 
 XMLParser (String activePath, String protocolFile)
 Used to parse an XML file before a simulation log file is generated, when the simulation is being initialised. More...
 
void openXMLDocument (String fileName, boolean testDTD)
 Creates a DOM document for an XML protocol file of a given name. More...
 
void openXMLDocument (String activePath, String protocolFile, boolean testDTD)
 Used to open an XML file in simulation initialisation - where the log file has yet to be created. More...
 
LinkedList< Element > buildSetMarkUp (String childMarkup)
 Returns a linked list of all XML elements of a given tag name. More...
 
LinkedList< XMLParserbuildSetParser (String childMarkup)
 Returns a list of XML parsers from combining nodes in the protocol file. Used for boundary conditions. More...
 
XMLParser getChild (String childName)
 Returns the child node for a given XML tag name. More...
 
String getParam (String paramName)
 Searches the child nodes of a given tag for a particular parameter name. Returns the assigned string value if present. More...
 
Element getParamMarkUp (String paramName)
 Searches the child nodes of a given tag for a particular parameter name. Returns the XML element for that tag if present. More...
 
String getParam (String paramName, StringBuffer unit)
 Searches the child nodes of a given tag for a particular parameter name and a specified unit. Returns the String value of that tag if present. More...
 
double getParamDbl (String paramName)
 Returns the double value assigned to an XML tag in the protocol file. More...
 
double getParamDbl (String paramName, StringBuffer unit)
 For a given XML tag name, returns the value in the specified unit (if that tag exists) More...
 
int getParamInt (String paramName)
 For a given XML tag name, returns the value it is assigned (if that tag exists) More...
 
int getParamInt (String paramName, StringBuffer unit)
 For a given XML tag name, and a given unit of measurement, returns the value the tag is assigned (if that tag exists) More...
 
double getParamLength (String paramName)
 Returns a length parameter from the XML, converting to the correct unit as required. More...
 
double getParamMass (String paramName)
 Returns the mass of a specified parameter from the XML, calculating this using the unit of measurement for that parameter. More...
 
double getParamTime (String paramName)
 Gets a given parameter from the protocol file and converts into a double representing time. More...
 
double getParamConc (String paramName)
 Reads a concentration from the protocol file and converts this to the required unit. More...
 
DiscreteVector getParamXYZ (String paramName)
 Converts coordinates specified in the protocol file into a discrete vector. More...
 
Boolean getParamBool (String paramName)
 Read in boolean value of specified parameter from the XML file. More...
 
Boolean getParamBool (String paramName, StringBuffer unit)
 Read in boolean value and unit of measurement of a specified parameter from the XML file. More...
 
String getParamSuch (String paramName, String detailName)
 Searches through the attributes of the XML tags of a given parameter name to find the String value of a specified detail within that tag. More...
 
String getParamSuch (String paramName, String detailName, StringBuffer unit)
 Searches through the attributes of the XML tags of a given parameter name, in a specified unit to find the String value of a specified detail within that tag. More...
 
double getParamSuchDbl (String paramName, String detailName)
 Searches through the attributes of the XML tags of a given parameter name to find the Double value of a specified detail within that tag. More...
 
Boolean getParamSuchBool (String paramName, String detailName)
 Searches through the attributes of the XML tags of a given parameter name to find the boolean value of a specified detail within that tag. More...
 
double getParamSuchDbl (String paramName, String detailName, StringBuffer unit)
 Searches through the attributes of the XML tags of a given parameter name, in a specified unit to find the Double value of a specified detail within that tag. More...
 
Boolean getParamSuchBool (String paramName, String detailName, StringBuffer unit)
 Searches through the attributes of the XML tags of a given parameter name, in a specified unit to find the boolean value of a specified detail within that tag. More...
 
Element getChildSuchAttribute (String childName, String attrName, String attrValue)
 Returns the XML element matching the specified tag name, attribute name, and attribute value. If not find return the local root. More...
 
String getAttributeStr (String attributeName)
 Return the string value of an attribute of the current localroot of the XML file. More...
 
double getAttributeDbl (String attributeName)
 Return the double value of an attribute of the current localroot of the XML file. More...
 
String getChildAttrStr (String childName, String attrName)
 Return the string value of a child attribute of the current localroot of the XML file. More...
 
double getChildAttrDbl (String childName, String attrName)
 Returns the value assigned to an attribute within a child node. More...
 
List< Element > getChildren (String childName)
 Returns a list of the children of a given XML child tag name. More...
 
Element getChildElement (String childName)
 Returns the XML element of a given child node tag name. More...
 
String getAttribute (String attributeName)
 Return the value assigned to a given XML tag. More...
 
Element getElement ()
 Return the current XML local root element. More...
 
Object instanceCreator (String prefix)
 Creates an instance of a class using a string containing that class name. More...
 
double getDblAttrOfChildSuchAttribute (String childName, String attrName, String attrValue, String attr2Name)
 Used for Epi-Bac scenarios - retrieving list of environments to which this species is sensitive to and the correspondent probability of dying if under the influence of that environment. More...
 

Detailed Description

Class providing methods of parsing the XML simulation protocol file.

In iDynoMiCS, protocol files are used to create the conditions under which a simulation is run. This is specified in XML. During initialisation, the simulation will require access to tags within this file. This class provides a means of accessing the data in these tags

Constructor & Destructor Documentation

utils.XMLParser.XMLParser ( Element  localRoot)

Create an XML parser for a given XML local grouping.

Create an XML parser for a given XML local grouping

Parameters
localRootAn element that is the root of a group of XML tags
utils.XMLParser.XMLParser ( String  fileName)

Create an XML parser object for an XML file of a given name

Parameters
fileNameThe name of the XML file to be processed
utils.XMLParser.XMLParser ( String  activePath,
String  protocolFile 
)

Used to parse an XML file before a simulation log file is generated, when the simulation is being initialised.

There are some checks the simulation needs to do on initialisation (with the protocol file). This is before the simulation log is generated. These errors get stored in a separate log file

Parameters
activePathThe path to the protocol file to open
protocolFileThe protocol file to read in

Member Function Documentation

LinkedList<Element> utils.XMLParser.buildSetMarkUp ( String  childMarkup)

Returns a linked list of all XML elements of a given tag name.

Returns a linked list of all XML elements within that protocol file that have a given tag name

Parameters
childMarkupThe tag name of the elements to put in the list
Returns
A linked list of all the elements of the given tag name
LinkedList<XMLParser> utils.XMLParser.buildSetParser ( String  childMarkup)

Returns a list of XML parsers from combining nodes in the protocol file. Used for boundary conditions.

Returns a list of XML parsers from combining nodes in the protocol file. Used for boundary conditions

Parameters
childMarkupThe XML tag for which many nodes may exist. boundaryCondition is a good example
Returns
Linked list of XML parsers for each of the nodes of this name that are found in the protocol file
String utils.XMLParser.getAttribute ( String  attributeName)

Return the value assigned to a given XML tag.

Returns the value assigned to a given XML tag in a protocol file

Parameters
attributeNameThe XML tag for which the associated value is needed
Returns
The string value assigned to that tag in the protocol file
double utils.XMLParser.getAttributeDbl ( String  attributeName)

Return the double value of an attribute of the current localroot of the XML file.

Return the double value of an attribute of the current localroot of the XML file

Parameters
attributeNameThe attribute name for which the value is being sought
Returns
The double value of that attribute, if present
String utils.XMLParser.getAttributeStr ( String  attributeName)

Return the string value of an attribute of the current localroot of the XML file.

Return the string value of an attribute of the current localroot of the XML file

Parameters
attributeNameThe attribute name for which the value is being sought
Returns
The string value of that attribute, if present
XMLParser utils.XMLParser.getChild ( String  childName)

Returns the child node for a given XML tag name.

Returns the child node for a given XML tag name

Parameters
childNameThe XML tag name to return
Returns
An XML parser containing the tags relating to this XML child tag
double utils.XMLParser.getChildAttrDbl ( String  childName,
String  attrName 
)

Returns the value assigned to an attribute within a child node.

Returns the value assigned to an attribute within a child node. Checking computation domain dimension is one example of its use

Parameters
childNameThe name of the child node of which the attribute value is being sought
attrNameThe name of the attribute for which the value is required
Returns
Double value assigned to that attribute, if present
String utils.XMLParser.getChildAttrStr ( String  childName,
String  attrName 
)

Return the string value of a child attribute of the current localroot of the XML file.

Return the string value of a child attribute of the current localroot of the XML file

Parameters
childNameName of the XML child tag
attrNameThe attribute of that tag for which the value is being sought
Returns
The string value of that attribute, if present
Element utils.XMLParser.getChildElement ( String  childName)

Returns the XML element of a given child node tag name.

Returns the XML element of a given child node tag name

Parameters
childNameThe child tag name for which the XML element is required
Returns
An XML element containing the tags for the specified child name
List<Element> utils.XMLParser.getChildren ( String  childName)

Returns a list of the children of a given XML child tag name.

Returns a list of the children of a given XML child tag name

Parameters
childNameThe name of a child tag in the XML file for which the list of children is required
Returns
List of XML elements containing the children of the specified tag name
Element utils.XMLParser.getChildSuchAttribute ( String  childName,
String  attrName,
String  attrValue 
)

Returns the XML element matching the specified tag name, attribute name, and attribute value. If not find return the local root.

Returns the XML element matching the specified tag name, attribute name, and attribute value. If not find return the local root

Parameters
childNameThe XML tag required
attrNameThe name of the attribute within that tag
attrValueThe value of the attribute within that tag
Returns
The XML element that matches these three criteria
double utils.XMLParser.getDblAttrOfChildSuchAttribute ( String  childName,
String  attrName,
String  attrValue,
String  attr2Name 
)

Used for Epi-Bac scenarios - retrieving list of environments to which this species is sensitive to and the correspondent probability of dying if under the influence of that environment.

Used for Epi-Bac scenarios - retrieving list of environments to which this species is sensitive to and the correspondent probability of dying if under the influence of that environment

Parameters
childNameThe name of the XML tag that contains the information on this parameter
attrNameThe name of the first attribute within that XML tag
attrValueThe value of the first attribute
attr2NameThe name of the related attribute that is required to find this value
Returns
Double value assigned to this tag
Element utils.XMLParser.getElement ( )

Return the current XML local root element.

Return the current XML local root element

Returns
XML Element for the current local root
String utils.XMLParser.getParam ( String  paramName)

Searches the child nodes of a given tag for a particular parameter name. Returns the assigned string value if present.

Searches the child nodes of a given tag for a particular parameter name. Returns the assigned string value if present

Parameters
paramNameThe name of the parameter for which a String value is being sought
Returns
String value assigned to that parameter, if present
String utils.XMLParser.getParam ( String  paramName,
StringBuffer  unit 
)

Searches the child nodes of a given tag for a particular parameter name and a specified unit. Returns the String value of that tag if present.

Searches the child nodes of a given tag for a particular parameter name and a specified unit. Returns the String value of that tag if present

Parameters
paramNameThe name of the parameter for which a String value is being sought
unitThe unit that this parameter should be
Returns
The value assigned to this tag in the protocol file, if present
Boolean utils.XMLParser.getParamBool ( String  paramName)

Read in boolean value of specified parameter from the XML file.

Reads in boolean value of specified parameter from the XML file

Parameters
paramNameThe parameter to be retrieved from the XML file
Returns
Boolean value assigned to this parameter
Boolean utils.XMLParser.getParamBool ( String  paramName,
StringBuffer  unit 
)

Read in boolean value and unit of measurement of a specified parameter from the XML file.

Read in boolean value and unit of measurement of a specified parameter from the XML file

Parameters
paramNameThe parameter to be retrieved from the XML file
unitThe unit of measurement specified for this parameter
Returns
Boolean value assigned to this parameter
double utils.XMLParser.getParamConc ( String  paramName)

Reads a concentration from the protocol file and converts this to the required unit.

Reads a concentration from the protocol file and converts this to the required unit

Parameters
paramNameThe concentration of the parameter to be retrieved from the protocol file
Returns
The calculated concentration level for this simulation parameter
double utils.XMLParser.getParamDbl ( String  paramName)

Returns the double value assigned to an XML tag in the protocol file.

Returns the double value assigned to an XML tag in the protocol file, if the tag is present

Parameters
paramNameThe XML parameter for which the value is required
Returns
Double value assigned to that XML tag
double utils.XMLParser.getParamDbl ( String  paramName,
StringBuffer  unit 
)

For a given XML tag name, returns the value in the specified unit (if that tag exists)

For a given XML tag name, returns the value in the specified unit (if that tag exists)

Parameters
paramNameThe name of the XML tag for which a value is required
unitThe unit that this parameter is required to be within
Returns
The double value assigned to that parameter, in the required unit
int utils.XMLParser.getParamInt ( String  paramName)

For a given XML tag name, returns the value it is assigned (if that tag exists)

For a given XML tag name, returns the value it is assigned (if that tag exists)

Parameters
paramNameThe name of the XML tag for which a value is required
Returns
The int value assigned to that parameter
int utils.XMLParser.getParamInt ( String  paramName,
StringBuffer  unit 
)

For a given XML tag name, and a given unit of measurement, returns the value the tag is assigned (if that tag exists)

For a given XML tag name, and a given unit of measurement, returns the value the tag is assigned (if that tag exists)

Parameters
paramNameThe name of the XML tag for which a value is required
unitThe unif of measurement specified for this parameter
Returns
The int value assigned to that parameter
double utils.XMLParser.getParamLength ( String  paramName)

Returns a length parameter from the XML, converting to the correct unit as required.

Returns a length parameter from the XML, converting to the correct unit as required

Parameters
paramNameThe name of the parameter for which the length value should be returned
Returns
The length value assigned to this parameter in the protocol file
Element utils.XMLParser.getParamMarkUp ( String  paramName)

Searches the child nodes of a given tag for a particular parameter name. Returns the XML element for that tag if present.

Searches the child nodes of a given tag for a particular parameter name. Returns the XML element for that tag if present

Parameters
paramNameThe name of the parameter for which a String value is being sought
Returns
XML Element contains the tags relating to that parameter, if present
double utils.XMLParser.getParamMass ( String  paramName)

Returns the mass of a specified parameter from the XML, calculating this using the unit of measurement for that parameter.

Returns the mass of a specified parameter from the XML, calculating this using the unit of measurement for that parameter

Parameters
paramNameThe name of the parameter for which the mass should be returned
Returns
The calculated mass of this parameter
String utils.XMLParser.getParamSuch ( String  paramName,
String  detailName 
)

Searches through the attributes of the XML tags of a given parameter name to find the String value of a specified detail within that tag.

Searches through the attributes of the XML tags of a given parameter name to find the value of a specified detail within that tag

Parameters
paramNameThe parameter name for which the value is required
detailNameThe name of the detail element which is part of that tag, if present
Returns
The text associated with the specified detail of this tag
String utils.XMLParser.getParamSuch ( String  paramName,
String  detailName,
StringBuffer  unit 
)

Searches through the attributes of the XML tags of a given parameter name, in a specified unit to find the String value of a specified detail within that tag.

Searches through the attributes of the XML tags of a given parameter name to find the value of a specified detail within that tag

Parameters
paramNameThe parameter name for which the value is required
detailNameThe name of the detail element which is part of that tag, if present
unitThe unit that this parameter should be measured in
Returns
The text associated with the specified detail of this tag
Boolean utils.XMLParser.getParamSuchBool ( String  paramName,
String  detailName 
)

Searches through the attributes of the XML tags of a given parameter name to find the boolean value of a specified detail within that tag.

Searches through the attributes of the XML tags of a given parameter name to find the boolean value of a specified detail within that tag

Parameters
paramNameThe parameter name for which the value is required
detailNameThe name of the detail element which is part of that tag, if present
Returns
The boolean value associated with the specified detail of this tag
Boolean utils.XMLParser.getParamSuchBool ( String  paramName,
String  detailName,
StringBuffer  unit 
)

Searches through the attributes of the XML tags of a given parameter name, in a specified unit to find the boolean value of a specified detail within that tag.

Searches through the attributes of the XML tags of a given parameter name to find the boolean value of a specified detail within that tag

Parameters
paramNameThe parameter name for which the value is required
detailNameThe name of the detail element which is part of that tag, if present
unitThe unit that this parameter should be measured in
Returns
The boolean value associated with the specified detail of this tag
double utils.XMLParser.getParamSuchDbl ( String  paramName,
String  detailName 
)

Searches through the attributes of the XML tags of a given parameter name to find the Double value of a specified detail within that tag.

Searches through the attributes of the XML tags of a given parameter name to find the Double value of a specified detail within that tag

Parameters
paramNameThe parameter name for which the value is required
detailNameThe name of the detail element which is part of that tag, if present
Returns
The double value associated with the specified detail of this tag
double utils.XMLParser.getParamSuchDbl ( String  paramName,
String  detailName,
StringBuffer  unit 
)

Searches through the attributes of the XML tags of a given parameter name, in a specified unit to find the Double value of a specified detail within that tag.

Searches through the attributes of the XML tags of a given parameter name to find the Double value of a specified detail within that tag

Parameters
paramNameThe parameter name for which the value is required
detailNameThe name of the detail element which is part of that tag, if present
unitThe unit that this parameter should be measured in
Returns
The double value associated with the specified detail of this tag
double utils.XMLParser.getParamTime ( String  paramName)

Gets a given parameter from the protocol file and converts into a double representing time.

Gets a given parameter from the protocol file and converts into a double representing time

Parameters
paramNameThe parameter to be retrieved from the XML file
Returns
Double of the value of this parameter converted into a unit of time
DiscreteVector utils.XMLParser.getParamXYZ ( String  paramName)

Converts coordinates specified in the protocol file into a discrete vector.

Converts coordinates specified in the protocol file into a discrete vector. Used for boundary conditions and specifications of birth area of agents

Parameters
paramNameThe protocol file parameter specified as X,Y,and Z coordinated
Returns
A discrete vector containing these three coordinates
Object utils.XMLParser.instanceCreator ( String  prefix)

Creates an instance of a class using a string containing that class name.

Creates an instance of a class using a string containing that class name. Useful for a set of boundary conditions, for example

Parameters
prefixThe class for which a new instance is being created
Returns
An object of the class stated in the prefix string
void utils.XMLParser.openXMLDocument ( String  fileName,
boolean  testDTD 
)

Creates a DOM document for an XML protocol file of a given name.

Creates a DOM document for an XML protocol file of a given name

Parameters
fileNameThe name of the XML protocol file being processed
testDTDBoolean stating whether or not schema validation should be applied on reading the XML file
void utils.XMLParser.openXMLDocument ( String  activePath,
String  protocolFile,
boolean  testDTD 
)

Used to open an XML file in simulation initialisation - where the log file has yet to be created.

Used to open an XML file in simulation initialisation - where the log file has yet to be created. This is the case as the simulation log file location is specified in the protocol file. If that can't be read then there is a problem

Parameters
activePathString of path to protocol file being processed
protocolFileThe protocol file to be read
testDTDBoolean stating whether or not schema validation should be applied on reading the XML file

The documentation for this class was generated from the following file: