java.lang.Object | ||
↳ | org.xml.sax.helpers.DefaultHandler | |
↳ | com.microstrategy.utils.xml.DefaultContentHandler |
![]() |
This class is used as a default base class for an XML ContentHandler. It provides the following features on top of DefaultHandler:
setDocumentLocator(Locator)
method). It exposes a getCurrentLineNumber()
method to return this information.
generateErrorMessage(String)
.
validationError(String)
method is used to report an error
condition that indicates invalid XML. The supplied message is formatted,
the validation error count is incremented and the resulting message is sent
to the supplied MessageRouter
.
internalError(String)
formats an error message and packages it into a
thrown org.xml.sax.SAXException. Parsing terminates at the point
of an internal error.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
protected Locator | locator | ||||||||||
protected MessageRouter | messageRouter | ||||||||||
protected String | sourceLocation | ||||||||||
protected int | validationErrorCount | ||||||||||
protected XMLReader | xmlReader |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DefaultContentHandler(String sourceLocation, MessageRouter msgRouter)
Default constructor which takes a "location" string (may be null) and a
MessageRouter object. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
characters(char[] ch, int start, int length)
Callback to indicate that characters have been found.
| ||||||||||
void |
endDocument()
What to do when the end of document is encountered.
| ||||||||||
void |
endElement(String uri, String localName, String qName)
Callback to indicate the end of an XML element.
| ||||||||||
String |
generateErrorMessage(String message)
Formats an error message supplied by the user.
| ||||||||||
void |
ignorableWhitespace(char[] ch, int start, int length)
Callback when ignorable whitespace has been encountered in an XML
document.
| ||||||||||
void |
incrementValidationErrorCount()
Increment the number of validation errors.
| ||||||||||
void |
resetData()
Resets all data structures used in the previous parse operation.
| ||||||||||
void |
setDocumentLocator(Locator locator)
Callback method to record the document locator.
| ||||||||||
void |
setMessageRouter(MessageRouter messageRouter)
Specifies the Message Router to use for this parse operation.
| ||||||||||
void |
setSourceLocation(String sourceLocation)
Specifies the location of the source text being parsed.
| ||||||||||
void |
setXMLReader(XMLReader xmlReader)
Sets the XML Reader which is being used to parse the XML text.
| ||||||||||
void |
startElement(String uri, String localName, String qName, Attributes attributes)
Callback invoked when a new element is encountered.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
clearChars()
Resets the characters collected.
| ||||||||||
String |
getCharacters()
Returns the last text area that was encountered.
| ||||||||||
int |
getCurrentLineNumber()
Returns the current line number (if we can determine it) or -1.
| ||||||||||
void |
internalError(String message)
Throws an internal SAXException error formatted with the supplied error
message.
| ||||||||||
void |
validationError(String message)
Reports a validation error.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Default constructor which takes a "location" string (may be null) and a
MessageRouter
object.
sourceLocation | The location of the source being parsed. |
---|---|
msgRouter | The MessageRouter object to use for reporting
errors, warnings.
|
Callback to indicate that characters have been found.
ch | The character array. |
---|---|
start | The starting index of the character encountered. |
length | The number of characters seen in this particular callback. |
SAXException | If the characters encountered were unexpected or some other internal error. |
---|
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.
SAXException | If validation errors have occurred. |
---|
Callback to indicate the end of an XML element.
uri | The URI of the element. |
---|---|
localName | The local name of the element. |
qName | The qualified name of the element. |
SAXException | If an unexpected element was encountered. |
---|
Formats an error message supplied by the user. The error message includes file name and line number information.
message | The underlying message to display |
---|
Callback when ignorable whitespace has been encountered in an XML document.
ch | The character array. |
---|---|
start | The starting index of the character encountered. |
length | The number of characters seen in this particular callback. |
SAXException | If the characters encountered were unexpected or some other internal error. |
---|
Increment the number of validation errors. This is only to be used by the org.xml.sax.ErrorHandler object (which reports DTD validation errors).
Resets all data structures used in the previous parse operation. This
enables the same instance to be used repeatedly for different XML
parse operations. After invoking the caller should call the setMessageRouter(MessageRouter)
and setSourceLocation(String)
methods to establish the new context.
Callback method to record the document locator.
locator | The Locator object created by the XML Reader. |
---|
Specifies the Message Router to use for this parse operation.
messageRouter | The Message Router to use for this parse operation. |
---|
Specifies the location of the source text being parsed.
sourceLocation | The source location of the text being parsed. |
---|
Sets the XML Reader which is being used to parse the XML text.
xmlReader | The XML Reader which is being used to parse the XML text. |
---|
Callback invoked when a new element is encountered.
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. |
SAXException | If an unexpected element appears in the configuration file. |
---|
Resets the characters collected. This is normally done when a new element is started.
Returns the last text area that was encountered. This includes all characters encountered between the most previous startElement and invocation of endElement.
Returns the current line number (if we can determine it) or -1.
Throws an internal SAXException error formatted with the supplied error message.
message | The message that contains the internal error. |
---|
SAXException | This is used to get out of the current SAX parsing call. |
---|
Reports a validation error. The supplied string is formatted and logged
(as an error) with the associated MessageRouter
.
message | The validation error message (used in a call to generateErrorMessage(String) ).
|
---|