|
GXPARSE hosted by | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ca.gorman.xml.parse.AbstractListener<T>
public abstract class AbstractListener<T extends Parser>
Provides Listener
methods that do nothing.
Constructor Summary | |
---|---|
protected |
AbstractListener()
|
Method Summary | ||
---|---|---|
void |
attributeDecl(T parser,
String eName,
String aName,
String type,
String valueDefault,
String value)
Report an attribute type declaration. |
|
void |
cdata(T parser,
CurrentMarkedSection cdata)
Receive a CDATA marked section. |
|
void |
characters(T parser,
CharSequence charSequence)
Receive notification of characters. |
|
void |
comment(T parser,
CharSequence charSequence)
Report an XML comment anywhere in the document. |
|
void |
doDocument(T parser,
CurrentDocument document)
Receive a request to handle a document that is being
parsed. |
|
void |
doDtd(T parser,
CurrentDtd dtd)
Receive a request to handle a DTD that is being
being parsed. |
|
void |
doElement(T parser,
CurrentElement element)
Receive a request to handle a element that is
being parsed. |
|
void |
doEntity(T parser,
CurrentEntity entity)
Process an entity, including the entity content. |
|
void |
elementDecl(T parser,
String name,
String model)
Report an element type declaration. |
|
void |
endPrefixMapping(T parser,
String prefix)
End the scope of a prefix-URI mapping (still under development, design may change). |
|
void |
error(T parser,
String description,
Location location,
Exception exception)
Receive notification of a recoverable error. |
|
void |
externalEntityDecl(T parser,
String name,
String publicId,
String systemId)
Report a parsed external entity declaration. |
|
void |
fatalError(T parser,
String description,
Location location,
Exception exception)
Receive notification of a non-recoverable error. |
|
Input |
getExternalSubset(T parser,
String name,
String baseURI)
Allows applications to replace a missing external subset. |
|
void |
ignorableWhitespace(T parser,
CharSequence charSequence)
Receive notification of ignorable whitespace characters. |
|
void |
internalEntityDecl(T parser,
String name,
String value)
Report an internal entity declaration. |
|
static
|
newInstance()
|
|
void |
notationDecl(T parser,
String name,
String publicId,
String systemId)
Receive notification of a notation declaration event. |
|
void |
processingInstruction(T parser,
String target,
String data)
Receive notification of a processing instruction. |
|
Input |
resolveEntity(T parser,
String name,
String publicId,
String baseURI,
String systemId)
Allow the application to resolve external entities. |
|
void |
skippedEntity(T parser,
String name)
Receive notification of a skipped entity. |
|
void |
startPrefixMapping(T parser,
String prefix,
String uri)
Begin the scope of a prefix-URI Namespace mapping (still under development, design may change). |
|
void |
unparsedEntityDecl(T parser,
String name,
String publicId,
String systemId,
String notationName)
Receive notification of an unparsed entity declaration event. |
|
void |
warning(T parser,
String description,
Location location,
Exception exception)
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 |
---|
protected AbstractListener()
Method Detail |
---|
public static <T extends Parser> AbstractListener<T> newInstance()
public void doDocument(T parser, CurrentDocument document) throws ListenerException, IOException
Listener
Receive a request to handle a document
that is being
parsed. The method is invoked just before the parser begins parsing.
The method must invoke
content handler
exactly once to parse the content of the document. Consequently, this
method has control only before and after the actual parsing operation.
doDocument
in interface Listener<T extends Parser>
parser
- The Parser
that invoked this methoddocument
- CurrentDocument
instance
with a content handler
to parse the centent of the
document.
ListenerException
IOException
public void startPrefixMapping(T parser, String prefix, String uri) throws ListenerException, IOException
PrefixListener
Begin the scope of a prefix-URI Namespace mapping (still under development, design may change).
startPrefixMapping
in interface PrefixListener<T extends Parser>
parser
- The Parser
that invoked this methodprefix
- The Namespace prefix being declared.uri
- The Namespace URI the prefix is mapped to.
ListenerException
IOException
public void endPrefixMapping(T parser, String prefix) throws ListenerException, IOException
PrefixListener
End the scope of a prefix-URI mapping (still under development, design may change).
endPrefixMapping
in interface PrefixListener<T extends Parser>
parser
- The Parser
that invoked this methodprefix
- The prefix that was being mapped.
ListenerException
IOException
public void doElement(T parser, CurrentElement element) throws ListenerException, IOException
ElementListener
Receive a request to handle a element
that is
being parsed. The method is invoked just after the parser has parsed
the start tag, and must invoke a
content handler
exactly once to parse the content of the element. Consequently, this
method has control only before and after the element content is parsed.
The start tag information remains available during the entire scope of
the method, via methods in CurrentElement
.
When several elements are nested, the current element will be at the
top of an element stack. The parent element, and successive ancestors
back to the document element, can be obtained by invoking
getParent
. The element data
(including attributes) of every element remains available as long as
that element is on the element stack.
All content processing is done from the parser by invocation of
Listener
methods. For example, subordinate elements
are delivered via new invocations of
doElement
and character input
is delivered via the
characters
method.
The precise effect of those methods (e.g. direction of characters to a
Writer or to a StringBuffer) can be controlled by changing the state
of the application upon entry to the doElement
and
restoring the previous application state just prior to exit.
When multiple invocations of this method are active, the invocation
of the method for each parent element is suspended, pending return
from the content handler
that was
invoked by that method. Since all Listener
methods
are invoked in the application thread, and the parser thread is
properly serialized with the application thread, all programming in the
application thread can be done as if there were only one active thread.
It is only necessary to be aware of the sequence of execution, as in the
following example of a parent element and a child element that contains
only PDCATA:
parent method
and
invoke content handler
in
parent method. One element (final The parent) is on the element
stack.
content handler
in parent method
child method
and
invoke content handler
in child method. Two elements (parent and child) are on the
element stack.
content handler
in child method
character
handler
. Two elements (parent and child) are on the element stack.
doElement
in interface ElementListener<T extends Parser>
parser
- The Parser
that invoked this methodelement
- CurrentElement
instance with a
content handler
to parse the centent of the element.
ListenerException
- when the exception has been thrown from a
Listener
method.
IOException
- when an input or output error occurspublic void characters(T parser, CharSequence charSequence) throws ListenerException, IOException
CharacterListener
Receive notification of characters.
In some implementations, charSequence
may reference data
that is not resident in memory. In such cases, the amount of data may
be large enough to cause the CharSequence.toString()
method
to throw OutOfMemoryError
.
characters
in interface CharacterListener<T extends Parser>
parser
- The Parser
that invoked this methodcharSequence
- A CharSequence
containing the
character data from the XML document.
ListenerException
IOException
public void ignorableWhitespace(T parser, CharSequence charSequence) throws ListenerException, IOException
CharacterListener
Receive notification of ignorable whitespace characters.
In some implementations, charSequence
may reference data
that is not resident in memory. In such cases, the amount of data may
be large enough to cause the CharSequence.toString()
method
to throw OutOfMemoryError
.
ignorableWhitespace
in interface CharacterListener<T extends Parser>
parser
- The Parser
that invoked this methodcharSequence
- A CharSequence
containing the
whitespace from the XML document.
ListenerException
IOException
public void processingInstruction(T parser, String target, String data) throws ListenerException, IOException
Listener
Receive notification of a processing instruction.
processingInstruction
in interface Listener<T extends Parser>
parser
- The Parser
that invoked this methodtarget
- The processing instruction target.data
- The processing instruction data, or null if
none was supplied. The data does not include any
whitespace separating it from the target.
ListenerException
IOException
public void skippedEntity(T parser, String name) throws ListenerException, IOException
SkippedEntityListener
Receive notification of a skipped entity.
skippedEntity
in interface SkippedEntityListener<T extends Parser>
parser
- The Parser
that invoked this methodname
- The name of the skipped entity. If it is a
parameter entity, the name will begin with '%', and if
it is the external DTD subset, it will be the string
"[dtd]".
ListenerException
IOException
public void notationDecl(T parser, String name, String publicId, String systemId) throws ListenerException, IOException
DtdListener
Receive notification of a notation declaration event.
notationDecl
in interface DtdListener<T extends Parser>
parser
- The Parser
that invoked this methodname
- The notation name.publicId
- The notation's public identifier, or null if
none was given.systemId
- The notation's system identifier, or null if
none was given.
ListenerException
IOException
public void unparsedEntityDecl(T parser, String name, String publicId, String systemId, String notationName) throws ListenerException, IOException
DtdListener
Receive notification of an unparsed entity declaration event.
unparsedEntityDecl
in interface DtdListener<T extends Parser>
parser
- The Parser
that invoked this methodname
- The unparsed entity's name.publicId
- The entity's public identifier, or null if none
was given.systemId
- The entity's system identifier.notationName
- The name of the associated notation.
ListenerException
IOException
public void elementDecl(T parser, String name, String model) throws ListenerException, IOException
DtdListener
Report an element type declaration.
elementDecl
in interface DtdListener<T extends Parser>
parser
- The Parser
that invoked this methodname
- The element type name.model
- The content model as a normalized string.
ListenerException
IOException
public void attributeDecl(T parser, String eName, String aName, String type, String valueDefault, String value) throws ListenerException, IOException
DtdListener
Report an attribute type declaration.
attributeDecl
in interface DtdListener<T extends Parser>
parser
- The Parser
that invoked this methodeName
- The name of the associated element.aName
- The name of the attribute.type
- A string representing the attribute type.valueDefault
- A string representing the attribute default
("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
none of these applies.value
- A string representing the attribute's default value,
or null if there is none.
ListenerException
IOException
public void internalEntityDecl(T parser, String name, String value) throws ListenerException, IOException
DtdListener
Report an internal entity declaration.
internalEntityDecl
in interface DtdListener<T extends Parser>
parser
- The Parser
that invoked this methodname
- The name of the entity. If it is a parameter
entity, the name will begin with '%'.value
- The replacement text of the entity.
ListenerException
IOException
public void externalEntityDecl(T parser, String name, String publicId, String systemId) throws ListenerException, IOException
DtdListener
Report a parsed external entity declaration.
externalEntityDecl
in interface DtdListener<T extends Parser>
parser
- The Parser
that invoked this methodname
- The name of the entity. If it is a parameter
entity, the name will begin with '%'.publicId
- The declared public identifier of the entity, or
null if none was declared.systemId
- The declared system identifier of the entity.
ListenerException
IOException
public Input getExternalSubset(T parser, String name, String baseURI) throws ListenerException, IOException
Listener
Allows applications to replace a missing external subset.
This method is invoked when there is a DOCTYPE declaration that does not
define an external subset. Returning an Input
that
provides wan external subset has the same effect as if the document text
had originally included the external subset.
This method is also invoked when the root element has been encountered,
but no DOCTYPE declaration has been seen. Returning an
Input
that provides an external subset has the same effect
as if a DOCTYPE declaration with an external subset had preceded the
root element.
Warning: Returning an external subset modifies the input document. By providing definitions for general entities, it can make a malformed document appear to be well formed.
getExternalSubset
in interface Listener<T extends Parser>
parser
- The Parser
that invoked this methodname
- Identifies the document root element. This name comes
from a DOCTYPE declaration (where available) or from
the actual root elementbaseURI
- The absolute URI of the document, or null if the URI
was not given to the parser
ListenerException
IOException
public Input resolveEntity(T parser, String name, String publicId, String baseURI, String systemId) throws ListenerException, IOException
Listener
Allow the application to resolve external entities.
resolveEntity
in interface Listener<T extends Parser>
parser
- The Parser
that invoked this methodname
- Either "[dtd]" for the external subset, or a name
starting with "%" to indicate a parameter entity, or
else the name of a general entitypublicId
- The public identifier of the external entity being
referenced, or null if none was suppliedbaseURI
- The absolute URI against which a relative systemID
would be resolved, or null if none was suppliedsystemId
- The absolute or relative URI that identifies the
external entity being referenced.
ListenerException
IOException
public void warning(T parser, String description, Location location, Exception exception) throws ListenerException, IOException
MessageListener
Receive notification of a warning.
warning
in interface MessageListener<T extends Parser>
parser
- The Parser
that invoked this
methoddescription
- A summary of the warning information (may be an
empty String).location
- Information about the location in the inputexception
- Additional information from the underlying
parser. The information will depend on the
Parser
implementation. The
parameter may be null, and the underlying
parser may not have actually thrown an
exception.
ListenerException
IOException
public void error(T parser, String description, Location location, Exception exception) throws ListenerException, IOException
MessageListener
Receive notification of a recoverable error.
error
in interface MessageListener<T extends Parser>
parser
- The Parser
that invoked this
methoddescription
- A summary of the warning information (may be an
empty String).location
- Information about the location in the inputexception
- Additional information from the underlying
parser. The information will depend on the
Parser
implementation. The
parameter may be null, and the underlying
parser may not have actually thrown an
exception.
ListenerException
IOException
public void fatalError(T parser, String description, Location location, Exception exception) throws ListenerException, IOException
MessageListener
Receive notification of a non-recoverable error.
fatalError
in interface MessageListener<T extends Parser>
parser
- The Parser
that invoked this
methoddescription
- A summary of the warning information (may be an
empty String).location
- Information about the location in the inputexception
- Additional information from the underlying
parser. The information will depend on the
Parser
implementation. The
parameter may be null, and the underlying
parser may not have actually thrown an
exception.
ListenerException
IOException
public void cdata(T parser, CurrentMarkedSection cdata) throws ListenerException, IOException
Listener
Receive a CDATA marked section.
The method is invoked at the beginning of the CDATA section. The method
must invoke
content handler
exactly once to parse the CDATA section. Consequently, this
method has control only before and after the parser reads the CDATA
section
cdata
in interface Listener<T extends Parser>
parser
- The Parser
that invoked this methodcdata
- CurrentMarkedSection
instance with a
content handler
to parse the centent of the entity.
ListenerException
IOException
public void doDtd(T parser, CurrentDtd dtd) throws ListenerException, IOException
DtdListener
Receive a request to handle a DTD
that is being
being parsed. The method is invoked at the start of parsing the DTD and
mustinvoke a
content handler
exactly once to parse the content of the DTD. Consequently, the
method has control only before and after the parsing of the DTD.
doDtd
in interface DtdListener<T extends Parser>
parser
- The Parser
that invoked this methoddtd
- CurrentDtd
instance with a
content handler
to parse the centent of the DTD.
ListenerException
IOException
public void doEntity(T parser, CurrentEntity entity) throws ListenerException, IOException
EntityListener
Process an entity, including the entity content. Parameter entities have '%' prepended to their names, general entities do not.
This method is entered at the beginning of the entity, when the actual
data is not yet available. The content is processed when the method
calls back (via ParseContent)
to the parser. Upon return from the callback, all of the entity has
been processed by other Listener methods. For additional information
about this method, see the
ElementListener.doElement
method, which operates in a very similar
way.
The primary use of this method is to give special handling to some entities, which will be recognized by the name.
doEntity
in interface EntityListener<T extends Parser>
parser
- The Parser
that invoked this methodentity
- CurrentEntity
instance with a
content handler
to parse the centent of the entity.
ListenerException
IOException
public void comment(T parser, CharSequence charSequence) throws ListenerException, IOException
Listener
Report an XML comment anywhere in the document.
In some implementations, charSequence
may reference data
that is not resident in memory. In such cases, the amount of data may
be large enough to cause the CharSequence.toString()
method
to throw OutOfMemoryError
.
comment
in interface Listener<T extends Parser>
parser
- The Parser
that invoked this methodcharSequence
- A CharSequence containing the characters in the
comment.
ListenerException
IOException
|
GXPARSE download | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |