Class KMLContentHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- com.microstrategy.web.app.maps.kml.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
-
-
Field Summary
Fields Modifier and Type Field Description protected org.xml.sax.Locator
locator
protected int
validationErrorCount
-
Constructor Summary
Constructors Constructor Description KMLContentHandler()
Default constructor which takes a "location" string (may be null) and aMessageRouter
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 filevoid
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.
-
-
-
Constructor Detail
-
KMLContentHandler
public KMLContentHandler()
Default constructor which takes a "location" string (may be null) and aMessageRouter
object.- Parameters:
sourceLocation
- The location of the source being parsed.msgRouter
- TheMessageRouter
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 theErrorHandler
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 interfaceorg.xml.sax.ContentHandler
- Overrides:
setDocumentLocator
in classorg.xml.sax.helpers.DefaultHandler
- Parameters:
locator
- TheLocator
object created by the XML Reader.
-
startDocument
public void startDocument() throws org.xml.sax.SAXException
- Specified by:
startDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startDocument
in classorg.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 interfaceorg.xml.sax.ContentHandler
- Overrides:
startElement
in classorg.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 interfaceorg.xml.sax.ContentHandler
- Overrides:
characters
in classorg.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 interfaceorg.xml.sax.ContentHandler
- Overrides:
endElement
in classorg.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 interfaceorg.xml.sax.ContentHandler
- Overrides:
endDocument
in classorg.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 associatedMessageRouter
.- Parameters:
message
- The validation error message (used in a call togenerateErrorMessage(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.
-
-