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.Locatorlocatorprotected intvalidationErrorCount 
- 
Constructor Summary
Constructors Constructor Description KMLContentHandler()Default constructor which takes a "location" string (may be null) and aMessageRouterobject. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)Callback to indicate that characters have been found.protected voidclearChars()Resets the characters collected.voidendDocument()What to do when the end of document is encountered.voidendElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)Callback to indicate the end of an XML element.java.lang.StringgenerateErrorMessage(java.lang.String message)Formats an error message supplied by the user.protected java.lang.StringgetCharacters()Returns the last text area that was encountered.protected intgetCurrentLineNumber()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 filevoidincrementValidationErrorCount()Increment the number of validation errors.protected voidinternalError(java.lang.String message)Throws an internal SAXException error formatted with the supplied error message.voidresetData()Reset the data variables to initial status.voidsetDocumentLocator(org.xml.sax.Locator locator)Callback method to record the document locator.voidsetPath(java.util.Map<java.lang.String,java.lang.String> pathin)voidstartDocument()voidstartElement(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 voidvalidationError(java.lang.String message)Reports a validation error. 
 - 
 
- 
- 
Constructor Detail
- 
KMLContentHandler
public KMLContentHandler()
Default constructor which takes a "location" string (may be null) and aMessageRouterobject.- Parameters:
 sourceLocation- The location of the source being parsed.msgRouter- TheMessageRouterobject 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 theErrorHandlerobject (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:
 setDocumentLocatorin interfaceorg.xml.sax.ContentHandler- Overrides:
 setDocumentLocatorin classorg.xml.sax.helpers.DefaultHandler- Parameters:
 locator- TheLocatorobject created by the XML Reader.
 
- 
startDocument
public void startDocument() throws org.xml.sax.SAXException- Specified by:
 startDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
 startDocumentin 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.SAXExceptionCallback invoked when a new element is encountered.- Specified by:
 startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
 startElementin 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.SAXExceptionCallback to indicate that characters have been found.- Specified by:
 charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
 charactersin 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.SAXExceptionCallback to indicate the end of an XML element.- Specified by:
 endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
 endElementin 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.SAXExceptionWhat 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:
 endDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
 endDocumentin 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.SAXExceptionThrows 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.
 
 - 
 
 -