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 XMLEventeventprotected Map<String,InstanceLine>instancesprotected Map<String,AbstractLocation>locationsprotected XMLEventReaderreader
-
Constructor Summary
Constructors Constructor Description XMLReader(InputStream s)Constructor
-
Method Summary
Modifier and Type Method Description protected InstanceLineanchor(Update element)Get the update anchor instanceprotected ArrayList<InstanceLine>anchors(Condition element)Get the anchor instances for a conditionprotected booleanbegin(String tag)Read until the beginning of a given tag.protected voidbranchpoints(Template template)Parse the branchpoint tag: x, y, color and id attributes.protected voidcommitted(Location location)Parse optional committed tag.protected voidconditions(LscTemplate template)Parse the conditions data, tag 'condition'protected voiddeclaration(Node node)Parse the 'declaration' text.protected voidedges(Template template)Parse the edge tag(s) if any: controllable, color, label(s) and nail(s).protected voidfixedname(Node node)Parse the plain name label without attributes.protected StringgetAttribute(String name)Get the attribute stringprotected ColorgetColor(String attribute)Get the color valueprotected IntegergetCoordinate(String attribute)get coordinate valueprotected IntegergetYLocation()Get the y coordinate data of the location, tag 'lsclocation'protected voidinit(Template template)Parse optional init tag.protected voidinstances(LscTemplate template)Parse the instance data, tag 'instance'.protected voidinstantiation(Document document)Parse optional instantiation tag.protected voidlabel(LscElement element)Parse the LSC label tag.protected voidlabels(Node node)Parse the label tag: kind, x, y, color and inner text.protected voidlocations(Template template)Parse all subsequent location tag(s) if any.protected voidlscTemplates(Document document)Parse the LSC tag(s) if any: name, parameter, type, mode, role, declaration, locations, instances, prechart, messages, conditions, updates.protected voidmessages(LscTemplate template)Parse the messages data, tag 'message'protected InstanceLinemessageSource()Parse the message source data, tag 'source'protected InstanceLinemessageTarget()Parse the message target data, tag 'target'protected voidmode(AbstractTemplate node)Parse the mode tag.protected voidnails(Edge edge)Parse the nail tag(s) if any: x, y attributes.protected voidname(Node node)Parse the name label data: name, x, y and color.protected voidnext()The next read eventprotected voidparameter(AbstractTemplate node)Parse an optional parameter tag text.Documentparse(Element prototype)Parse the document.protected voidprechart(LscTemplate template)Parse the prechart data, tag 'prechart'protected voidproject(Document document)Parse the document starting with 'project' or 'nta', through templates, instantiation, system declaration and queries.protected voidqueries(Document document)Parse 'queries' tag with inner 'query' tags containing 'formula' and 'comment' tags.protected StringreadText()Read the text inside a tag.protected voidrole(AbstractTemplate node)Parse the role tag.static voidsetXMLResolver(XMLResolver value)Set a custom XMLResolver to be used with XMLEventReader.protected AbstractLocationsource()Parse the source (location/branchpoint) tag: ref attribute.protected voidsystem(Document document)Parse optional system tag.protected AbstractLocationtarget()Parse the target (location/branchpoint) tag: ref attribute.protected voidtemperature(Node node)Parse the temperature tag of a conditionprotected voidtemplates(Document document)Parse the template tag(s) if any: name, parameter, declaration, locations, branchpoints, initial location and edges.protected voidtype(AbstractTemplate node)Parse the type tag of TA or LSC template.protected voidupdates(LscTemplate template)Parse the updates data, tag 'update'protected voidurgent(Location location)Parse optional urgent tag.protected voidyLocation(LscElement element, String property)Set the y coordinate of the location in lscElement.protected voidyloccoord(LscTemplate template)Parse the y coordinate data of the location, tag 'yloccoord'
-
-
-
Field Detail
-
reader
protected XMLEventReader reader
-
event
protected XMLEvent event
-
locations
protected Map<String,AbstractLocation> locations
-
instances
protected Map<String,InstanceLine> instances
-
-
Constructor Detail
-
XMLReader
public XMLReader(InputStream s) throws XMLStreamException
Constructor- Parameters:
s- - The input stream- Throws:
XMLStreamException
-
-
Method Detail
-
setXMLResolver
public static void setXMLResolver(XMLResolver value)
Set a custom XMLResolver to be used with XMLEventReader.- Parameters:
value- resolver.
-
parse
public Document parse(Element prototype) throws XMLStreamException
Parse the document.- Parameters:
prototype- default properties for the model document.- Returns:
- the model document.
- Throws:
XMLStreamException- parsing error.
-
next
protected void next() throws XMLStreamExceptionThe next read event- Throws:
XMLStreamException- parse exception.
-
begin
protected boolean begin(String tag) throws XMLStreamException
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
protected String readText() throws XMLStreamException
Read the text inside a tag.- Returns:
- s the content string
- Throws:
XMLStreamException- parsing error
-
getAttribute
protected String getAttribute(String name)
Get the attribute string- Parameters:
name- - The attribute name- Returns:
- The attribute string
-
getCoordinate
protected Integer getCoordinate(String attribute)
get coordinate value- Parameters:
attribute- - The attribute name- Returns:
- The value
-
getColor
protected Color getColor(String attribute)
Get the color value- Parameters:
attribute- - The attribute name- Returns:
- - The color
-
project
protected void project(Document document) throws XMLStreamException
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
protected void declaration(Node node) throws XMLStreamException
Parse the 'declaration' text.- Parameters:
node- parent TA or LSC template.- Throws:
XMLStreamException- parsing error
-
name
protected void name(Node node) throws XMLStreamException
Parse the name label data: name, x, y and color.- Parameters:
node- the owner of this property.- Throws:
XMLStreamException- parsing error.
-
fixedname
protected void fixedname(Node node) throws XMLStreamException
Parse the plain name label without attributes.- Parameters:
node- the owner of this name property.- Throws:
XMLStreamException- parsing error.
-
parameter
protected void parameter(AbstractTemplate node) throws XMLStreamException
Parse an optional parameter tag text.- Parameters:
node- the owner of this parameter.- Throws:
XMLStreamException- parsing error.
-
type
protected void type(AbstractTemplate node) throws XMLStreamException
Parse the type tag of TA or LSC template.- Parameters:
node- the owner of this tag.- Throws:
XMLStreamException- parsing error.
-
mode
protected void mode(AbstractTemplate node) throws XMLStreamException
Parse the mode tag.- Parameters:
node- the owner of this tag.- Throws:
XMLStreamException- parsing error.
-
role
protected void role(AbstractTemplate node) throws XMLStreamException
Parse the role tag.- Parameters:
node- the owner of this tag.- Throws:
XMLStreamException- parsing error.
-
labels
protected void labels(Node node) throws XMLStreamException
Parse the label tag: kind, x, y, color and inner text.- Parameters:
node- the owner of this tag.- Throws:
XMLStreamException
-
label
protected void label(LscElement element) throws XMLStreamException
Parse the LSC label tag.- Parameters:
element- the owner of this tag.- Throws:
XMLStreamException- parsing error.
-
temperature
protected void temperature(Node node) throws XMLStreamException
Parse the temperature tag of a condition- Parameters:
node- the owner of this tag.- Throws:
XMLStreamException- parsing error.
-
committed
protected void committed(Location location) throws XMLStreamException
Parse optional committed tag.- Parameters:
location- the owner of this tag.- Throws:
XMLStreamException- parsing error.
-
urgent
protected void urgent(Location location) throws XMLStreamException
Parse optional urgent tag.- Parameters:
location- the owner of this tag.- Throws:
XMLStreamException- parsing error.
-
init
protected void init(Template template) throws XMLStreamException
Parse optional init tag.- Parameters:
template- the owner of this tag.- Throws:
XMLStreamException- parsing error.
-
locations
protected void locations(Template template) throws XMLStreamException
Parse all subsequent location tag(s) if any.- Parameters:
template- the owner of those tags.- Throws:
XMLStreamException- parsing error.
-
branchpoints
protected void branchpoints(Template template) throws XMLStreamException
Parse the branchpoint tag: x, y, color and id attributes.- Parameters:
template- the owner of this tag.- Throws:
XMLStreamException- parsing error.
-
source
protected AbstractLocation source() throws XMLStreamException
Parse the source (location/branchpoint) tag: ref attribute.- Returns:
- location the referenced object, or null if not found.
- Throws:
XMLStreamException- parsing error.
-
target
protected AbstractLocation target() throws XMLStreamException
Parse the target (location/branchpoint) tag: ref attribute.- Returns:
- location the referenced object, or null if not found.
- Throws:
XMLStreamException- parsing error.
-
nails
protected void nails(Edge edge) throws XMLStreamException
Parse the nail tag(s) if any: x, y attributes.- Parameters:
edge- the owner of those tags.- Throws:
XMLStreamException- parsing error.
-
edges
protected void edges(Template template) throws XMLStreamException
Parse the edge tag(s) if any: controllable, color, label(s) and nail(s).- Parameters:
template- the owner of these tags.- Throws:
XMLStreamException
-
templates
protected void templates(Document document) throws XMLStreamException
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
protected void lscTemplates(Document document) throws XMLStreamException
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
protected void prechart(LscTemplate template) throws XMLStreamException
Parse the prechart data, tag 'prechart'- Parameters:
template- - The template object- Throws:
XMLStreamException- parsing error.
-
yLocation
protected void yLocation(LscElement element, String property) throws XMLStreamException
Set the y coordinate of the location in lscElement.- Parameters:
element- - The lscElementproperty- - The property string- Throws:
XMLStreamException- parsing error.
-
getYLocation
protected Integer getYLocation() throws XMLStreamException
Get the y coordinate data of the location, tag 'lsclocation'- Returns:
- The y coordinate value
- Throws:
XMLStreamException
-
yloccoord
protected void yloccoord(LscTemplate template) throws XMLStreamException
Parse the y coordinate data of the location, tag 'yloccoord'- Parameters:
template- - The lsc template- Throws:
XMLStreamException
-
instances
protected void instances(LscTemplate template) throws XMLStreamException
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
protected void messages(LscTemplate template) throws XMLStreamException
Parse the messages data, tag 'message'- Parameters:
template- - The LSC template- Throws:
XMLStreamException- parsing error.
-
conditions
protected void conditions(LscTemplate template) throws XMLStreamException
Parse the conditions data, tag 'condition'- Parameters:
template- - The LSC template- Throws:
XMLStreamException- parsing error.
-
updates
protected void updates(LscTemplate template) throws XMLStreamException
Parse the updates data, tag 'update'- Parameters:
template- - The LSC template- Throws:
XMLStreamException- parsing error.
-
anchors
protected ArrayList<InstanceLine> anchors(Condition element) throws XMLStreamException
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
protected InstanceLine anchor(Update element) throws XMLStreamException
Get the update anchor instance- Parameters:
element- - The updata object- Returns:
- instance - the Instance line object
- Throws:
XMLStreamException- parsing error.
-
messageSource
protected InstanceLine messageSource() throws XMLStreamException
Parse the message source data, tag 'source'- Returns:
- instance - The instance line object
- Throws:
XMLStreamException- parsing error.
-
messageTarget
protected InstanceLine messageTarget() throws XMLStreamException
Parse the message target data, tag 'target'- Returns:
- instance - The instance line object
- Throws:
XMLStreamException- parsing error.
-
instantiation
protected void instantiation(Document document) throws XMLStreamException
Parse optional instantiation tag.- Parameters:
document- - The model document- Throws:
XMLStreamException- parsing error.
-
system
protected void system(Document document) throws XMLStreamException
Parse optional system tag.- Parameters:
document- - The model document- Throws:
XMLStreamException- parsing error.
-
queries
protected void queries(Document document) throws XMLStreamException
Parse 'queries' tag with inner 'query' tags containing 'formula' and 'comment' tags.- Parameters:
document- the owner of this tag.- Throws:
XMLStreamException- parsing error.
-
-