org.xml.sax.helpers
Class DefaultHandler

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public synchronized class DefaultHandler
extends java.lang.Object
implements EntityResolver, DTDHandler, ContentHandler, ErrorHandler


Constructor Summary
DefaultHandler()
           
 
Method Summary
 void characters(char[], int, int)
           
 void endDocument()
           
 void endElement(java.lang.String, java.lang.String, java.lang.String)
           
 void endPrefixMapping(java.lang.String)
           
 void error(SAXParseException)
          Receive notification of a recoverable error.
 void fatalError(SAXParseException)
          Receive notification of a non-recoverable error.
 void ignorableWhitespace(char[], int, int)
           
 void notationDecl(java.lang.String, java.lang.String, java.lang.String)
          Receive notification of a notation declaration event.
 void processingInstruction(java.lang.String, java.lang.String)
           
 InputSource resolveEntity(java.lang.String, java.lang.String)
          Allow the application to resolve external entities.
 void setDocumentLocator(Locator)
           
 void skippedEntity(java.lang.String)
           
 void startDocument()
           
 void startElement(java.lang.String, java.lang.String, java.lang.String, Attributes)
           
 void startPrefixMapping(java.lang.String, java.lang.String)
           
 void unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
          Receive notification of an unparsed entity declaration event.
 void warning(SAXParseException)
          Receive notification of a warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultHandler

public DefaultHandler()
Method Detail

resolveEntity

public InputSource resolveEntity(java.lang.String,
                                 java.lang.String)
                          throws SAXException
Description copied from interface: EntityResolver
Allow the application to resolve external entities.

The Parser will call this method before opening any external entity except the top-level document entity (including the external DTD subset, external entities referenced within the DTD, and external entities referenced within the document element): the application may request that the parser resolve the entity itself, that it use an alternative URI, or that it use an entirely different input source.

Application writers can use this method to redirect external system identifiers to secure and/or local URIs, to look up public identifiers in a catalogue, or to read an entity from a database or other input source (including, for example, a dialog box).

If the system identifier is a URL, the SAX parser must resolve it fully before reporting it to the application.

Specified by:
resolveEntity in interface EntityResolver
Parameters:
- The public identifier of the external entity being referenced, or null if none was supplied.
- The system identifier of the external entity being referenced.
Returns:
An InputSource object describing the new input source, or null to request that the parser open a regular URI connection to the system identifier.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
InputSource

notationDecl

public void notationDecl(java.lang.String,
                         java.lang.String,
                         java.lang.String)
                  throws SAXException
Description copied from interface: DTDHandler
Receive notification of a notation declaration event.

It is up to the application to record the notation for later reference, if necessary.

If a system identifier is present, and it is a URL, the SAX parser must resolve it fully before passing it to the application.

Specified by:
notationDecl in interface DTDHandler
Parameters:
- The notation name.
- The notation's public identifier, or null if none was given.
- The notation's system identifier, or null if none was given.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String), AttributeList

unparsedEntityDecl

public void unparsedEntityDecl(java.lang.String,
                               java.lang.String,
                               java.lang.String,
                               java.lang.String)
                        throws SAXException
Description copied from interface: DTDHandler
Receive notification of an unparsed entity declaration event.

Note that the notation name corresponds to a notation reported by the notationDecl() event. It is up to the application to record the entity for later reference, if necessary.

If the system identifier is a URL, the parser must resolve it fully before passing it to the application.

Specified by:
unparsedEntityDecl in interface DTDHandler
Parameters:
- The unparsed entity's name.
- The entity's public identifier, or null if none was given.
- The entity's system identifier (it must always have one).
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
DTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String), AttributeList

setDocumentLocator

public void setDocumentLocator(Locator)
Specified by:
setDocumentLocator in interface ContentHandler

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
SAXException

startPrefixMapping

public void startPrefixMapping(java.lang.String,
                               java.lang.String)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
SAXException

endPrefixMapping

public void endPrefixMapping(java.lang.String)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
SAXException

startElement

public void startElement(java.lang.String,
                         java.lang.String,
                         java.lang.String,
                         Attributes)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
SAXException

endElement

public void endElement(java.lang.String,
                       java.lang.String,
                       java.lang.String)
                throws SAXException
Specified by:
endElement in interface ContentHandler
SAXException

characters

public void characters(char[],
                       int,
                       int)
                throws SAXException
Specified by:
characters in interface ContentHandler
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[],
                                int,
                                int)
                         throws SAXException
Specified by:
ignorableWhitespace in interface ContentHandler
SAXException

processingInstruction

public void processingInstruction(java.lang.String,
                                  java.lang.String)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
SAXException

skippedEntity

public void skippedEntity(java.lang.String)
                   throws SAXException
Specified by:
skippedEntity in interface ContentHandler
SAXException

warning

public void warning(SAXParseException)
             throws SAXException
Description copied from interface: ErrorHandler
Receive notification of a warning.

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.

Specified by:
warning in interface ErrorHandler
Parameters:
- The warning information encapsulated in a SAX parse exception.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
SAXParseException

error

public void error(SAXParseException)
           throws SAXException
Description copied from interface: ErrorHandler
Receive notification of a recoverable error.

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.

Specified by:
error in interface ErrorHandler
Parameters:
- The error information encapsulated in a SAX parse exception.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
SAXParseException

fatalError

public void fatalError(SAXParseException)
                throws SAXException
Description copied from interface: ErrorHandler
Receive notification of a non-recoverable error.

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.

Specified by:
fatalError in interface ErrorHandler
Parameters:
- The error information encapsulated in a SAX parse exception.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
SAXParseException