|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.microstar.xml.HandlerBase
public class HandlerBase
Convenience base class for AElfred handlers.
This base class implements the XmlHandler interface with
(mostly empty) default handlers. You are not required to use this,
but if you need to handle only a few events, you might find
it convenient to extend this class rather than implementing
the entire interface. This example overrides only the
charData
method, using the defaults for the others:
import com.microstar.xml.HandlerBase; public class MyHandler extends HandlerBase { public void charData (char ch[], int start, int length) { System.out.println("Data: " + new String (ch, start, length)); } }
This class is optional, but if you use it, you must also
include the XmlException
class.
Do not extend this if you are using SAX; extend
org.xml.sax.HandlerBase
instead.
XmlHandler
,
XmlException
Constructor Summary | |
---|---|
HandlerBase()
|
Method Summary | |
---|---|
void |
attribute(java.lang.String aname,
java.lang.String value,
boolean isSpecified)
Handle an attribute assignment. |
void |
charData(char[] ch,
int start,
int length)
Handle character data. |
void |
doctypeDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Handle a document type declaration. |
void |
endDocument()
Handle the end of the document. |
void |
endElement(java.lang.String elname)
Handle the end of an element. |
void |
endExternalEntity(java.lang.String systemId)
Handle the end of an external entity. |
void |
error(java.lang.String message,
java.lang.String systemId,
int line,
int column)
Throw an exception for a fatal error. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Handle ignorable whitespace. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Handle a processing instruction. |
java.lang.Object |
resolveEntity(java.lang.String publicId,
java.lang.String systemId)
Resolve an external entity. |
void |
startDocument()
Handle the start of the document. |
void |
startElement(java.lang.String elname)
Handle the start of an element. |
void |
startExternalEntity(java.lang.String systemId)
Handle the start of an external entity. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HandlerBase()
Method Detail |
---|
public void startDocument() throws java.lang.Exception
The default implementation does nothing.
startDocument
in interface XmlHandler
java.lang.Exception
- Derived methods may throw exceptions.XmlHandler.startDocument()
public void endDocument() throws java.lang.Exception
The default implementation does nothing.
endDocument
in interface XmlHandler
java.lang.Exception
- Derived methods may throw exceptions.XmlHandler.endDocument()
public java.lang.Object resolveEntity(java.lang.String publicId, java.lang.String systemId) throws java.lang.Exception
The default implementation simply returns the supplied system identifier.
resolveEntity
in interface XmlHandler
publicId
- The public identifier, or null if none was supplied.systemId
- The system identifier.
java.lang.Exception
- Derived methods may throw exceptions.XmlHandler.resolveEntity(java.lang.String, java.lang.String)
public void startExternalEntity(java.lang.String systemId) throws java.lang.Exception
The default implementation does nothing.
startExternalEntity
in interface XmlHandler
systemId
- The URI of the external entity that is starting.
java.lang.Exception
- Derived methods may throw exceptions.XmlHandler.startExternalEntity(java.lang.String)
public void endExternalEntity(java.lang.String systemId) throws java.lang.Exception
The default implementation does nothing.
endExternalEntity
in interface XmlHandler
systemId
- The URI of the external entity that is ending.
java.lang.Exception
- Derived methods may throw exceptions.XmlHandler.endExternalEntity(java.lang.String)
public void doctypeDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws java.lang.Exception
The default implementation does nothing.
doctypeDecl
in interface XmlHandler
name
- The document type name.publicId
- The public identifier, or null if unspecified.systemId
- The system identifier, or null if unspecified.
java.lang.Exception
- Derived methods may throw exceptions.XmlHandler.doctypeDecl(java.lang.String, java.lang.String, java.lang.String)
public void attribute(java.lang.String aname, java.lang.String value, boolean isSpecified) throws java.lang.Exception
The default implementation does nothing.
attribute
in interface XmlHandler
aname
- The name of the attribute.value
- The value of the attribute, or null if the attribute
is #IMPLIED
.isSpecified
- True if the value was specified, false if it
was defaulted from the DTD.
java.lang.Exception
- Derived methods may throw exceptions.XmlHandler.attribute(java.lang.String, java.lang.String, boolean)
public void startElement(java.lang.String elname) throws java.lang.Exception
The default implementation does nothing.
startElement
in interface XmlHandler
elname
- The element type name.
java.lang.Exception
- Derived methods may throw exceptions.XmlHandler.startElement(java.lang.String)
public void endElement(java.lang.String elname) throws java.lang.Exception
The default implementation does nothing.
endElement
in interface XmlHandler
elname
- The element type name.
java.lang.Exception
- Derived methods may throw exceptions.XmlHandler.endElement(java.lang.String)
public void charData(char[] ch, int start, int length) throws java.lang.Exception
The default implementation does nothing.
charData
in interface XmlHandler
ch
- The character data.start
- The starting position in the array.length
- The number of characters available.
java.lang.Exception
- Derived methods may throw exceptions.XmlHandler.charData(char[], int, int)
public void ignorableWhitespace(char[] ch, int start, int length) throws java.lang.Exception
The default implementation does nothing.
ignorableWhitespace
in interface XmlHandler
ch
- The literal whitespace characters.start
- The starting position in the array.length
- The number of whitespace characters available.
java.lang.Exception
- Derived methods may throw exceptions.XmlHandler.ignorableWhitespace(char[], int, int)
public void processingInstruction(java.lang.String target, java.lang.String data) throws java.lang.Exception
The default implementation does nothing.
processingInstruction
in interface XmlHandler
target
- The target (the name at the start of the PI).data
- The data, if any (the rest of the PI).
java.lang.Exception
- Derived methods may throw exceptions.XmlHandler.processingInstruction(java.lang.String, java.lang.String)
public void error(java.lang.String message, java.lang.String systemId, int line, int column) throws XmlException, java.lang.Exception
The default implementation throws XmlException
.
error
in interface XmlHandler
message
- The error message.systemId
- The system identifier of the entity that
contains the error.line
- The approximate line number of the error.column
- The approximate column number of the error.
XmlException
- A specific parsing error.
java.lang.Exception
- Derived methods may throw exceptions.XmlHandler.error(java.lang.String, java.lang.String, int, int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |