Class XMLReader


  • public class XMLReader
    extends java.lang.Object
    The class for xml file read
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.xml.stream.events.XMLEvent event  
      protected java.util.Map<java.lang.String,​InstanceLine> instances  
      protected java.util.Map<java.lang.String,​AbstractLocation> locations  
      protected javax.xml.stream.XMLEventReader reader  
    • Constructor Summary

      Constructors 
      Constructor Description
      XMLReader​(java.io.InputStream s)
      Constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected InstanceLine anchor​(Update element)
      Get the update anchor instance
      protected java.util.ArrayList<InstanceLine> anchors​(Condition element)
      Get the anchor instances for a condition
      protected boolean begin​(java.lang.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 java.lang.String getAttribute​(java.lang.String name)
      Get the attribute string
      protected java.awt.Color getColor​(java.lang.String attribute)
      Get the color value
      protected java.lang.Integer getCoordinate​(java.lang.String attribute)
      get coordinate value
      protected java.lang.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 event
      protected 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 java.lang.String readText()
      Read the text inside a tag.
      protected void role​(AbstractTemplate node)
      Parse the role tag.
      static void setXMLResolver​(javax.xml.stream.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 condition
      protected 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, java.lang.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'
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • reader

        protected javax.xml.stream.XMLEventReader reader
      • event

        protected javax.xml.stream.events.XMLEvent event
      • locations

        protected java.util.Map<java.lang.String,​AbstractLocation> locations
      • instances

        protected java.util.Map<java.lang.String,​InstanceLine> instances
    • Constructor Detail

      • XMLReader

        public XMLReader​(java.io.InputStream s)
                  throws javax.xml.stream.XMLStreamException
        Constructor
        Parameters:
        s - - The input stream
        Throws:
        javax.xml.stream.XMLStreamException
    • Method Detail

      • setXMLResolver

        public static void setXMLResolver​(javax.xml.stream.XMLResolver value)
        Set a custom XMLResolver to be used with XMLEventReader.
        Parameters:
        value - resolver.
      • parse

        public Document parse​(Element prototype)
                       throws javax.xml.stream.XMLStreamException
        Parse the document.
        Parameters:
        prototype - default properties for the model document.
        Returns:
        the model document.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • next

        protected void next()
                     throws javax.xml.stream.XMLStreamException
        The next read event
        Throws:
        javax.xml.stream.XMLStreamException - parse exception.
      • begin

        protected boolean begin​(java.lang.String tag)
                         throws javax.xml.stream.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:
        javax.xml.stream.XMLStreamException - parsing error
      • readText

        protected java.lang.String readText()
                                     throws javax.xml.stream.XMLStreamException
        Read the text inside a tag.
        Returns:
        s the content string
        Throws:
        javax.xml.stream.XMLStreamException - parsing error
      • getAttribute

        protected java.lang.String getAttribute​(java.lang.String name)
        Get the attribute string
        Parameters:
        name - - The attribute name
        Returns:
        The attribute string
      • getCoordinate

        protected java.lang.Integer getCoordinate​(java.lang.String attribute)
        get coordinate value
        Parameters:
        attribute - - The attribute name
        Returns:
        The value
      • getColor

        protected java.awt.Color getColor​(java.lang.String attribute)
        Get the color value
        Parameters:
        attribute - - The attribute name
        Returns:
        - The color
      • project

        protected void project​(Document document)
                        throws javax.xml.stream.XMLStreamException
        Parse the document starting with 'project' or 'nta', through templates, instantiation, system declaration and queries.
        Parameters:
        document - - AST for the model document
        Throws:
        javax.xml.stream.XMLStreamException - parsing error
      • declaration

        protected void declaration​(Node node)
                            throws javax.xml.stream.XMLStreamException
        Parse the 'declaration' text.
        Parameters:
        node - parent TA or LSC template.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error
      • name

        protected void name​(Node node)
                     throws javax.xml.stream.XMLStreamException
        Parse the name label data: name, x, y and color.
        Parameters:
        node - the owner of this property.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • fixedname

        protected void fixedname​(Node node)
                          throws javax.xml.stream.XMLStreamException
        Parse the plain name label without attributes.
        Parameters:
        node - the owner of this name property.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • parameter

        protected void parameter​(AbstractTemplate node)
                          throws javax.xml.stream.XMLStreamException
        Parse an optional parameter tag text.
        Parameters:
        node - the owner of this parameter.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • type

        protected void type​(AbstractTemplate node)
                     throws javax.xml.stream.XMLStreamException
        Parse the type tag of TA or LSC template.
        Parameters:
        node - the owner of this tag.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • mode

        protected void mode​(AbstractTemplate node)
                     throws javax.xml.stream.XMLStreamException
        Parse the mode tag.
        Parameters:
        node - the owner of this tag.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • role

        protected void role​(AbstractTemplate node)
                     throws javax.xml.stream.XMLStreamException
        Parse the role tag.
        Parameters:
        node - the owner of this tag.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • labels

        protected void labels​(Node node)
                       throws javax.xml.stream.XMLStreamException
        Parse the label tag: kind, x, y, color and inner text.
        Parameters:
        node - the owner of this tag.
        Throws:
        javax.xml.stream.XMLStreamException
      • label

        protected void label​(LscElement element)
                      throws javax.xml.stream.XMLStreamException
        Parse the LSC label tag.
        Parameters:
        element - the owner of this tag.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • temperature

        protected void temperature​(Node node)
                            throws javax.xml.stream.XMLStreamException
        Parse the temperature tag of a condition
        Parameters:
        node - the owner of this tag.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • committed

        protected void committed​(Location location)
                          throws javax.xml.stream.XMLStreamException
        Parse optional committed tag.
        Parameters:
        location - the owner of this tag.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • urgent

        protected void urgent​(Location location)
                       throws javax.xml.stream.XMLStreamException
        Parse optional urgent tag.
        Parameters:
        location - the owner of this tag.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • init

        protected void init​(Template template)
                     throws javax.xml.stream.XMLStreamException
        Parse optional init tag.
        Parameters:
        template - the owner of this tag.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • locations

        protected void locations​(Template template)
                          throws javax.xml.stream.XMLStreamException
        Parse all subsequent location tag(s) if any.
        Parameters:
        template - the owner of those tags.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • branchpoints

        protected void branchpoints​(Template template)
                             throws javax.xml.stream.XMLStreamException
        Parse the branchpoint tag: x, y, color and id attributes.
        Parameters:
        template - the owner of this tag.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • source

        protected AbstractLocation source()
                                   throws javax.xml.stream.XMLStreamException
        Parse the source (location/branchpoint) tag: ref attribute.
        Returns:
        location the referenced object, or null if not found.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • target

        protected AbstractLocation target()
                                   throws javax.xml.stream.XMLStreamException
        Parse the target (location/branchpoint) tag: ref attribute.
        Returns:
        location the referenced object, or null if not found.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • nails

        protected void nails​(Edge edge)
                      throws javax.xml.stream.XMLStreamException
        Parse the nail tag(s) if any: x, y attributes.
        Parameters:
        edge - the owner of those tags.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • edges

        protected void edges​(Template template)
                      throws javax.xml.stream.XMLStreamException
        Parse the edge tag(s) if any: controllable, color, label(s) and nail(s).
        Parameters:
        template - the owner of these tags.
        Throws:
        javax.xml.stream.XMLStreamException
      • templates

        protected void templates​(Document document)
                          throws javax.xml.stream.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:
        javax.xml.stream.XMLStreamException
      • lscTemplates

        protected void lscTemplates​(Document document)
                             throws javax.xml.stream.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:
        javax.xml.stream.XMLStreamException - parsing error.
      • prechart

        protected void prechart​(LscTemplate template)
                         throws javax.xml.stream.XMLStreamException
        Parse the prechart data, tag 'prechart'
        Parameters:
        template - - The template object
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • yLocation

        protected void yLocation​(LscElement element,
                                 java.lang.String property)
                          throws javax.xml.stream.XMLStreamException
        Set the y coordinate of the location in lscElement.
        Parameters:
        element - - The lscElement
        property - - The property string
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • getYLocation

        protected java.lang.Integer getYLocation()
                                          throws javax.xml.stream.XMLStreamException
        Get the y coordinate data of the location, tag 'lsclocation'
        Returns:
        The y coordinate value
        Throws:
        javax.xml.stream.XMLStreamException
      • yloccoord

        protected void yloccoord​(LscTemplate template)
                          throws javax.xml.stream.XMLStreamException
        Parse the y coordinate data of the location, tag 'yloccoord'
        Parameters:
        template - - The lsc template
        Throws:
        javax.xml.stream.XMLStreamException
      • instances

        protected void instances​(LscTemplate template)
                          throws javax.xml.stream.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:
        javax.xml.stream.XMLStreamException - parsing error.
      • messages

        protected void messages​(LscTemplate template)
                         throws javax.xml.stream.XMLStreamException
        Parse the messages data, tag 'message'
        Parameters:
        template - - The LSC template
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • conditions

        protected void conditions​(LscTemplate template)
                           throws javax.xml.stream.XMLStreamException
        Parse the conditions data, tag 'condition'
        Parameters:
        template - - The LSC template
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • updates

        protected void updates​(LscTemplate template)
                        throws javax.xml.stream.XMLStreamException
        Parse the updates data, tag 'update'
        Parameters:
        template - - The LSC template
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • anchors

        protected java.util.ArrayList<InstanceLine> anchors​(Condition element)
                                                     throws javax.xml.stream.XMLStreamException
        Get the anchor instances for a condition
        Parameters:
        element - - the condition object
        Returns:
        anchors - The array list of the instance line
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • anchor

        protected InstanceLine anchor​(Update element)
                               throws javax.xml.stream.XMLStreamException
        Get the update anchor instance
        Parameters:
        element - - The updata object
        Returns:
        instance - the Instance line object
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • messageSource

        protected InstanceLine messageSource()
                                      throws javax.xml.stream.XMLStreamException
        Parse the message source data, tag 'source'
        Returns:
        instance - The instance line object
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • messageTarget

        protected InstanceLine messageTarget()
                                      throws javax.xml.stream.XMLStreamException
        Parse the message target data, tag 'target'
        Returns:
        instance - The instance line object
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • instantiation

        protected void instantiation​(Document document)
                              throws javax.xml.stream.XMLStreamException
        Parse optional instantiation tag.
        Parameters:
        document - - The model document
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • system

        protected void system​(Document document)
                       throws javax.xml.stream.XMLStreamException
        Parse optional system tag.
        Parameters:
        document - - The model document
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.
      • queries

        protected void queries​(Document document)
                        throws javax.xml.stream.XMLStreamException
        Parse 'queries' tag with inner 'query' tags containing 'formula' and 'comment' tags.
        Parameters:
        document - the owner of this tag.
        Throws:
        javax.xml.stream.XMLStreamException - parsing error.