Package com.uppaal.model.io2
Class XMLReader
java.lang.Object
com.uppaal.model.io2.XMLReader
public class XMLReader extends Object
The class for xml file read
-
Field Summary
Fields Modifier and Type Field Description protected XMLEvent
event
protected Map<String,InstanceLine>
instances
protected Map<String,AbstractLocation>
locations
protected XMLEventReader
reader
-
Constructor Summary
Constructors Constructor Description XMLReader(InputStream s)
Constructor -
Method Summary
Modifier and Type Method Description protected InstanceLine
anchor(Update element)
Get the update anchor instanceprotected ArrayList<InstanceLine>
anchors(Condition element)
Get the anchor instances for a conditionprotected boolean
begin(String tag)
Read until the beginning of a given tag.protected void
branchpoints(Template template)
Parse the branchpoint tag: x, y, color and id attributes.protected void
committed(Location location)
Parse optional committed tag.protected void
conditions(LscTemplate template)
Parse the conditions data, tag 'condition'protected void
declaration(Node node)
Parse the 'declaration' text.protected void
edges(Template template)
Parse the edge tag(s) if any: controllable, color, label(s) and nail(s).protected void
fixedname(Node node)
Parse the plain name label without attributes.protected String
getAttribute(String name)
Get the attribute stringprotected Color
getColor(String attribute)
Get the color valueprotected Integer
getCoordinate(String attribute)
get coordinate valueprotected Integer
getYLocation()
Get the y coordinate data of the location, tag 'lsclocation'protected void
init(Template template)
Parse optional init tag.protected void
instances(LscTemplate template)
Parse the instance data, tag 'instance'.protected void
instantiation(Document document)
Parse optional instantiation tag.protected void
label(LscElement element)
Parse the LSC label tag.protected void
labels(Node node)
Parse the label tag: kind, x, y, color and inner text.protected void
locations(Template template)
Parse all subsequent location tag(s) if any.protected void
lscTemplates(Document document)
Parse the LSC tag(s) if any: name, parameter, type, mode, role, declaration, locations, instances, prechart, messages, conditions, updates.protected void
messages(LscTemplate template)
Parse the messages data, tag 'message'protected InstanceLine
messageSource()
Parse the message source data, tag 'source'protected InstanceLine
messageTarget()
Parse the message target data, tag 'target'protected void
mode(AbstractTemplate node)
Parse the mode tag.protected void
nails(Edge edge)
Parse the nail tag(s) if any: x, y attributes.protected void
name(Node node)
Parse the name label data: name, x, y and color.protected void
next()
The next read eventprotected void
parameter(AbstractTemplate node)
Parse an optional parameter tag text.Document
parse(Element prototype)
Parse the document.protected void
prechart(LscTemplate template)
Parse the prechart data, tag 'prechart'protected void
project(Document document)
Parse the document starting with 'project' or 'nta', through templates, instantiation, system declaration and queries.protected void
queries(Document document)
Parse 'queries' tag with inner 'query' tags containing 'formula' and 'comment' tags.protected String
readText()
Read the text inside a tag.protected void
role(AbstractTemplate node)
Parse the role tag.static void
setXMLResolver(XMLResolver value)
Set a custom XMLResolver to be used with XMLEventReader.protected AbstractLocation
source()
Parse the source (location/branchpoint) tag: ref attribute.protected void
system(Document document)
Parse optional system tag.protected AbstractLocation
target()
Parse the target (location/branchpoint) tag: ref attribute.protected void
temperature(Node node)
Parse the temperature tag of a conditionprotected void
templates(Document document)
Parse the template tag(s) if any: name, parameter, declaration, locations, branchpoints, initial location and edges.protected void
type(AbstractTemplate node)
Parse the type tag of TA or LSC template.protected void
updates(LscTemplate template)
Parse the updates data, tag 'update'protected void
urgent(Location location)
Parse optional urgent tag.protected void
yLocation(LscElement element, String property)
Set the y coordinate of the location in lscElement.protected void
yloccoord(LscTemplate template)
Parse the y coordinate data of the location, tag 'yloccoord'
-
Field Details
-
Constructor Details
-
XMLReader
Constructor- Parameters:
s
- - The input stream- Throws:
XMLStreamException
-
-
Method Details
-
setXMLResolver
Set a custom XMLResolver to be used with XMLEventReader.- Parameters:
value
- resolver.
-
parse
Parse the document.- Parameters:
prototype
- default properties for the model document.- Returns:
- the model document.
- Throws:
XMLStreamException
- parsing error.
-
next
The next read event- Throws:
XMLStreamException
- parse exception.
-
begin
Read until the beginning of a given tag.- Parameters:
tag
- the name of the tag- Returns:
- true if the next tag has the given name.
- Throws:
XMLStreamException
- parsing error
-
readText
Read the text inside a tag.- Returns:
- s the content string
- Throws:
XMLStreamException
- parsing error
-
getAttribute
Get the attribute string- Parameters:
name
- - The attribute name- Returns:
- The attribute string
-
getCoordinate
get coordinate value- Parameters:
attribute
- - The attribute name- Returns:
- The value
-
getColor
Get the color value- Parameters:
attribute
- - The attribute name- Returns:
- - The color
-
project
Parse the document starting with 'project' or 'nta', through templates, instantiation, system declaration and queries.- Parameters:
document
- - AST for the model document- Throws:
XMLStreamException
- parsing error
-
declaration
Parse the 'declaration' text.- Parameters:
node
- parent TA or LSC template.- Throws:
XMLStreamException
- parsing error
-
name
Parse the name label data: name, x, y and color.- Parameters:
node
- the owner of this property.- Throws:
XMLStreamException
- parsing error.
-
fixedname
Parse the plain name label without attributes.- Parameters:
node
- the owner of this name property.- Throws:
XMLStreamException
- parsing error.
-
parameter
Parse an optional parameter tag text.- Parameters:
node
- the owner of this parameter.- Throws:
XMLStreamException
- parsing error.
-
type
Parse the type tag of TA or LSC template.- Parameters:
node
- the owner of this tag.- Throws:
XMLStreamException
- parsing error.
-
mode
Parse the mode tag.- Parameters:
node
- the owner of this tag.- Throws:
XMLStreamException
- parsing error.
-
role
Parse the role tag.- Parameters:
node
- the owner of this tag.- Throws:
XMLStreamException
- parsing error.
-
labels
Parse the label tag: kind, x, y, color and inner text.- Parameters:
node
- the owner of this tag.- Throws:
XMLStreamException
-
label
Parse the LSC label tag.- Parameters:
element
- the owner of this tag.- Throws:
XMLStreamException
- parsing error.
-
temperature
Parse the temperature tag of a condition- Parameters:
node
- the owner of this tag.- Throws:
XMLStreamException
- parsing error.
-
committed
Parse optional committed tag.- Parameters:
location
- the owner of this tag.- Throws:
XMLStreamException
- parsing error.
-
urgent
Parse optional urgent tag.- Parameters:
location
- the owner of this tag.- Throws:
XMLStreamException
- parsing error.
-
init
Parse optional init tag.- Parameters:
template
- the owner of this tag.- Throws:
XMLStreamException
- parsing error.
-
locations
Parse all subsequent location tag(s) if any.- Parameters:
template
- the owner of those tags.- Throws:
XMLStreamException
- parsing error.
-
branchpoints
Parse the branchpoint tag: x, y, color and id attributes.- Parameters:
template
- the owner of this tag.- Throws:
XMLStreamException
- parsing error.
-
source
Parse the source (location/branchpoint) tag: ref attribute.- Returns:
- location the referenced object, or null if not found.
- Throws:
XMLStreamException
- parsing error.
-
target
Parse the target (location/branchpoint) tag: ref attribute.- Returns:
- location the referenced object, or null if not found.
- Throws:
XMLStreamException
- parsing error.
-
nails
Parse the nail tag(s) if any: x, y attributes.- Parameters:
edge
- the owner of those tags.- Throws:
XMLStreamException
- parsing error.
-
edges
Parse the edge tag(s) if any: controllable, color, label(s) and nail(s).- Parameters:
template
- the owner of these tags.- Throws:
XMLStreamException
-
templates
Parse the template tag(s) if any: name, parameter, declaration, locations, branchpoints, initial location and edges.- Parameters:
document
- the owner of these tags.- Throws:
XMLStreamException
-
lscTemplates
Parse the LSC tag(s) if any: name, parameter, type, mode, role, declaration, locations, instances, prechart, messages, conditions, updates.- Parameters:
document
- - The model document- Throws:
XMLStreamException
- parsing error.
-
prechart
Parse the prechart data, tag 'prechart'- Parameters:
template
- - The template object- Throws:
XMLStreamException
- parsing error.
-
yLocation
Set the y coordinate of the location in lscElement.- Parameters:
element
- - The lscElementproperty
- - The property string- Throws:
XMLStreamException
- parsing error.
-
getYLocation
Get the y coordinate data of the location, tag 'lsclocation'- Returns:
- The y coordinate value
- Throws:
XMLStreamException
-
yloccoord
Parse the y coordinate data of the location, tag 'yloccoord'- Parameters:
template
- - The lsc template- Throws:
XMLStreamException
-
instances
Parse the instance data, tag 'instance'. Added the value into the integer array list for the instances -> 'instances'- Parameters:
template
- - The LSC template- Throws:
XMLStreamException
- parsing error.
-
messages
Parse the messages data, tag 'message'- Parameters:
template
- - The LSC template- Throws:
XMLStreamException
- parsing error.
-
conditions
Parse the conditions data, tag 'condition'- Parameters:
template
- - The LSC template- Throws:
XMLStreamException
- parsing error.
-
updates
Parse the updates data, tag 'update'- Parameters:
template
- - The LSC template- Throws:
XMLStreamException
- parsing error.
-
anchors
Get the anchor instances for a condition- Parameters:
element
- - the condition object- Returns:
- anchors - The array list of the instance line
- Throws:
XMLStreamException
- parsing error.
-
anchor
Get the update anchor instance- Parameters:
element
- - The updata object- Returns:
- instance - the Instance line object
- Throws:
XMLStreamException
- parsing error.
-
messageSource
Parse the message source data, tag 'source'- Returns:
- instance - The instance line object
- Throws:
XMLStreamException
- parsing error.
-
messageTarget
Parse the message target data, tag 'target'- Returns:
- instance - The instance line object
- Throws:
XMLStreamException
- parsing error.
-
instantiation
Parse optional instantiation tag.- Parameters:
document
- - The model document- Throws:
XMLStreamException
- parsing error.
-
system
Parse optional system tag.- Parameters:
document
- - The model document- Throws:
XMLStreamException
- parsing error.
-
queries
Parse 'queries' tag with inner 'query' tags containing 'formula' and 'comment' tags.- Parameters:
document
- the owner of this tag.- Throws:
XMLStreamException
- parsing error.
-