Class KMLContentHandler

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

    public class KMLContentHandler
    extends org.xml.sax.helpers.DefaultHandler
    • Constructor Summary

      Constructors 
      Constructor Description
      KMLContentHandler()
      Default constructor which takes a "location" string (may be null) and a MessageRouter object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void characters​(char[] ch, int start, int length)
      Callback to indicate that characters have been found.
      protected void clearChars()
      Resets the characters collected.
      void endDocument()
      What to do when the end of document is encountered.
      void endElement​(java.lang.String uri, java.lang.String localName, java.lang.String qName)
      Callback to indicate the end of an XML element.
      java.lang.String generateErrorMessage​(java.lang.String message)
      Formats an error message supplied by the user.
      protected java.lang.String getCharacters()
      Returns the last text area that was encountered.
      protected int getCurrentLineNumber()
      Returns the current line number (if we can determine it) or -1.
      java.util.ArrayList<KMLObject> getMapObjects()
      Get the array of map objects from parsed KML file
      void incrementValidationErrorCount()
      Increment the number of validation errors.
      protected void internalError​(java.lang.String message)
      Throws an internal SAXException error formatted with the supplied error message.
      void resetData()
      Reset the data variables to initial status.
      void setDocumentLocator​(org.xml.sax.Locator locator)
      Callback method to record the document locator.
      void setPath​(java.util.Map<java.lang.String,​java.lang.String> pathin)  
      void startDocument()  
      void startElement​(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
      Callback invoked when a new element is encountered.
      protected void validationError​(java.lang.String message)
      Reports a validation error.
      • Methods inherited from class org.xml.sax.helpers.DefaultHandler

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

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

      • locator

        protected org.xml.sax.Locator locator
      • validationErrorCount

        protected int validationErrorCount
    • Constructor Detail

      • KMLContentHandler

        public KMLContentHandler()
        Default constructor which takes a "location" string (may be null) and a MessageRouter object.
        Parameters:
        sourceLocation - The location of the source being parsed.
        msgRouter - The MessageRouter object to use for reporting errors, warnings.
    • Method Detail

      • generateErrorMessage

        public java.lang.String generateErrorMessage​(java.lang.String message)
        Formats an error message supplied by the user. The error message includes file name and line number information.
        Parameters:
        message - The underlying message to display
        Returns:
        A String containing the full, displayable error message.
      • setPath

        public void setPath​(java.util.Map<java.lang.String,​java.lang.String> pathin)
      • resetData

        public void resetData()
        Reset the data variables to initial status.
      • incrementValidationErrorCount

        public void incrementValidationErrorCount()
        Increment the number of validation errors. This is only to be used by the ErrorHandler object (which reports DTD validation errors).
      • getMapObjects

        public java.util.ArrayList<KMLObject> getMapObjects()
        Get the array of map objects from parsed KML file
        Returns:
        The array list object of KMLObject
      • setDocumentLocator

        public void setDocumentLocator​(org.xml.sax.Locator locator)
        Callback method to record the document locator.
        Specified by:
        setDocumentLocator in interface org.xml.sax.ContentHandler
        Overrides:
        setDocumentLocator in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        locator - The Locator object created by the XML Reader.
      • startDocument

        public void startDocument()
                           throws org.xml.sax.SAXException
        Specified by:
        startDocument in interface org.xml.sax.ContentHandler
        Overrides:
        startDocument in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • 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
        Callback invoked when a new element is encountered.
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        uri - The URI of the element.
        localName - The local name of the element.
        qName - The qualified name of the element.
        attributes - The attributes associated with the element.
        Throws:
        org.xml.sax.SAXException - If an unexpected element appears in the configuration file.
      • characters

        public void characters​(char[] ch,
                               int start,
                               int length)
                        throws org.xml.sax.SAXException
        Callback to indicate that characters have been found.
        Specified by:
        characters in interface org.xml.sax.ContentHandler
        Overrides:
        characters in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        ch - The character array.
        start - The starting index of the character encountered.
        length - The number of characters seen in this particular callback.
        Throws:
        org.xml.sax.SAXException - If the characters encountered were unexpected or some other internal error.
      • endElement

        public void endElement​(java.lang.String uri,
                               java.lang.String localName,
                               java.lang.String qName)
                        throws org.xml.sax.SAXException
        Callback to indicate the end of an XML element.
        Specified by:
        endElement in interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        uri - The URI of the element.
        localName - The local name of the element.
        qName - The qualified name of the element.
        Throws:
        org.xml.sax.SAXException - If an unexpected element was encountered.
      • endDocument

        public void endDocument()
                         throws org.xml.sax.SAXException
        What to do when the end of document is encountered. By default, it will check whether any validation errors have occurred. If so, it throws an exception.
        Specified by:
        endDocument in interface org.xml.sax.ContentHandler
        Overrides:
        endDocument in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException - If validation errors have occurred.
      • getCharacters

        protected java.lang.String getCharacters()
        Returns the last text area that was encountered. This includes all characters encountered between the most previous startElement and invocation of endElement.
        Returns:
        The String representation of last text (character) area encountered.
      • clearChars

        protected void clearChars()
        Resets the characters collected. This is normally done when a new element is started.
        Since:
        MicroStrategy Web 9.0.0
      • getCurrentLineNumber

        protected int getCurrentLineNumber()
        Returns the current line number (if we can determine it) or -1.
        Returns:
        The current line number that we are at in the input stream.
      • validationError

        protected void validationError​(java.lang.String message)
        Reports a validation error. The supplied string is formatted and logged (as an error) with the associated MessageRouter.
        Parameters:
        message - The validation error message (used in a call to generateErrorMessage(String)).
      • internalError

        protected void internalError​(java.lang.String message)
                              throws org.xml.sax.SAXException
        Throws an internal SAXException error formatted with the supplied error message.
        Parameters:
        message - The message that contains the internal error.
        Throws:
        org.xml.sax.SAXException - This is used to get out of the current SAX parsing call.