Class AbstractModelReader.SAXModelHandler

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
    Enclosing class:
    AbstractModelReader

    private class AbstractModelReader.SAXModelHandler
    extends org.xml.sax.helpers.DefaultHandler
    The SAX2 callback implementation used for parsing the model xml files.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean isInclude
      Flag to track includes.
      private java.util.Stack openComments
      Open comments.
      private java.net.URL resource
      The resource URL.
      private int state
      The current state.
    • Constructor Summary

      Constructors 
      Constructor Description
      SAXModelHandler​(java.net.URL resource, boolean isInclude)
      Creates a new SAX handler for parsing the model.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void endElement​(java.lang.String uri, java.lang.String localName, java.lang.String qName)
      Receive notification of the end of an element.
      private int getState()
      Returns the current state.
      private void setState​(int state)
      Sets the current state.
      void startElement​(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
      Receive notification of the start of an element.
      private void startObjectElement​(java.lang.String qName, org.xml.sax.Attributes attributes)
      Handles the start of an element within an object definition.
      private void startRootElement​(java.lang.String qName, org.xml.sax.Attributes attributes)
      Handles the include or object tag.
      • Methods inherited from class org.xml.sax.helpers.DefaultHandler

        characters, endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
      • Methods inherited from class java.lang.Object

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

      • resource

        private java.net.URL resource
        The resource URL.
      • state

        private int state
        The current state.
      • openComments

        private java.util.Stack openComments
        Open comments.
      • isInclude

        private boolean isInclude
        Flag to track includes.
    • Constructor Detail

      • SAXModelHandler

        public SAXModelHandler​(java.net.URL resource,
                               boolean isInclude)
        Creates a new SAX handler for parsing the model.
        Parameters:
        resource - the resource URL.
        isInclude - an include?
    • Method Detail

      • startElement

        public void startElement​(java.lang.String uri,
                                 java.lang.String localName,
                                 java.lang.String qName,
                                 org.xml.sax.Attributes attributes)
                          throws org.xml.sax.SAXException
        Receive notification of the start of an element.
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
        localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
        qName - The qualified name (with prefix), or the empty string if qualified names are not available.
        attributes - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
        Throws:
        org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
        See Also:
        ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
      • endElement

        public void endElement​(java.lang.String uri,
                               java.lang.String localName,
                               java.lang.String qName)
                        throws org.xml.sax.SAXException
        Receive notification of the end of an element.
        Specified by:
        endElement in interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
        localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
        qName - The qualified name (with prefix), or the empty string if qualified names are not available.
        Throws:
        org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
        See Also:
        ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
      • startObjectElement

        private void startObjectElement​(java.lang.String qName,
                                        org.xml.sax.Attributes attributes)
                                 throws ObjectDescriptionException
        Handles the start of an element within an object definition.
        Parameters:
        qName - The qualified name (with prefix), or the empty string if qualified names are not available.
        attributes - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
        Throws:
        ObjectDescriptionException - if an error occured while handling this tag
      • startRootElement

        private void startRootElement​(java.lang.String qName,
                                      org.xml.sax.Attributes attributes)
                               throws org.xml.sax.SAXException,
                                      ObjectDescriptionException
        Handles the include or object tag.
        Parameters:
        qName - The qualified name (with prefix), or the empty string if qualified names are not available.
        attributes - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
        Throws:
        org.xml.sax.SAXException - if an parser error occured
        ObjectDescriptionException - if an object model related error occured.
      • getState

        private int getState()
        Returns the current state.
        Returns:
        the state.
      • setState

        private void setState​(int state)
        Sets the current state.
        Parameters:
        state - the state.