|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--org.xml.sax.helpers.DefaultHandler
|
+--com.cafesoft.core.xml.DefaultXmlHandler
DefaultXmlHandler provides general XML handling facilities.
It implements methods for resolving DTD Entities and reporting XML parsing
warnings, errors, and fatal errors. In particular, methods within the
following interfaces are overridden:
The ErrorHandler implementation writes XML parsing exceptions to a Cafesoft Logger.
| Field Summary | |
protected boolean |
debug
A flag used to enable/disable DEBUG-level messages. |
protected String[] |
dtdPathArray
The array of directory paths that are searched for DTD files. |
protected Logger |
logger
The Logger to which messages are logged. |
| Constructor Summary | |
DefaultXmlHandler(String[] dtdPathArray,
Logger logger)
Create a new DefaultXmlHandler. |
|
DefaultXmlHandler(String[] dtdPathArray,
Logger logger,
String context)
Create a new DefaultXmlHandler. |
|
| Method Summary | |
void |
addSAXParseExceptionListener(SAXParseExceptionListener listener)
Add a SAXParseExceptionListener. |
void |
error(SAXParseException exception)
Receive notification of a recoverable error. |
void |
fatalError(SAXParseException exception)
Receive notification of a non-recoverable error. |
protected void |
fireException(SAXParseException exception,
int level)
Fire a SAXParseException to all registered listeners |
void |
removeSAXParseExceptionListener(SAXParseExceptionListener listener)
Add a SAXParseExceptionListener. |
InputSource |
resolveEntity(String publicId,
String systemId)
Resolve an Entity. |
boolean |
setDebug(boolean enable)
Enable or disable debugging. |
void |
warning(SAXParseException exception)
Receive notification of a warning. |
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Logger logger
protected String[] dtdPathArray
protected boolean debug
| Constructor Detail |
public DefaultXmlHandler(String[] dtdPathArray,
Logger logger)
dtdPathArray - a String array of directory paths to be searched for
DTD files via the EntityResolver interface. The paths are searched in
order.logger - the Logger to which messages are to be logged
public DefaultXmlHandler(String[] dtdPathArray,
Logger logger,
String context)
dtdPathArray - a String array of directory paths to be searched
for DTD files via the EntityResolver interface. The paths are
searched in order.logger - the Logger to which messages are to be logged.context - a tag used to report the context within which a
ErrorHandler method is invoked. For example, the name of the
file being parsed.| Method Detail |
public boolean setDebug(boolean enable)
enable - if true, enable debugging, else disable debugging.
public void addSAXParseExceptionListener(SAXParseExceptionListener listener)
listener - the SAXParseExceptionListenerpublic void removeSAXParseExceptionListener(SAXParseExceptionListener listener)
listener - the SAXParseExceptionListener
public InputSource resolveEntity(String publicId,
String systemId)
throws SAXException
resolveEntity in interface EntityResolverresolveEntity in class DefaultHandlerpublicId - the public identifier for the entity.systemId - the system identifier for the entity.
SAXException - if a problem resolving the Entity.
public void warning(SAXParseException exception)
throws SAXException
SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML 1.0 recommendation. The default behaviour is to take no action.
The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end.
Filters may use this method to report other, non-XML warnings as well.
warning in interface ErrorHandlerwarning in class DefaultHandlerexception - the warning information encapsulated in a SAX parse
exception.
SAXException - any SAX exception, possibly wrapping another
exception.SAXParseException
public void error(SAXParseException exception)
throws SAXException
This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the violation of a validity constraint. The default behaviour is to take no action.
The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end. If the application cannot do so, then the parser should report a fatal error even if the XML 1.0 recommendation does not require it to do so.
Filters may use this method to report other, non-XML errors as well.
error in interface ErrorHandlererror in class DefaultHandlerexception - the error information encapsulated in a SAX parse
exception.
SAXException - any SAX exception, possibly wrapping another
exception.SAXParseException
public void fatalError(SAXParseException exception)
throws SAXException
This corresponds to the definition of "fatal error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a parser would use this callback to report the violation of a well-formedness constraint.
The application must assume that the document is unusable after the parser has invoked this method, and should continue (if at all) only for the sake of collecting addition error messages: in fact, SAX parsers are free to stop reporting any other events once this method has been invoked.
fatalError in interface ErrorHandlerfatalError in class DefaultHandlerexception - the warning information encapsulated in a SAX parse
exception.
SAXException - any SAX exception, possibly wrapping another
exception.SAXParseException
protected void fireException(SAXParseException exception,
int level)
exception - the SAXParseException to send to the listenerslevel - the level of exception: WARNING, ERROR, or FATAL.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||