public class DefaultCallback extends Object implements Callback
Callbacks can inherit from this class and forget about methods they are not interested in.
This class has a protected constructor. If you need an instance of this class, use
getInstance()
.
EMPTY_CALLBACK_ARRAY
Modifier | Constructor and Description |
---|---|
protected |
DefaultCallback() |
Modifier and Type | Method and Description |
---|---|
boolean |
cdata(Element elementUnused,
char[] textUnused,
int offsetUnused,
int lengthUnused)
Receive notification of the content of a CDATA section.
|
boolean |
characters(char[] textUnused,
int offsetUnused,
int lengthUnused,
boolean flowBrokenUnused)
Receive notification of character data inside an element.
|
void |
configure(BulletParser parserUnused)
Configure the parser for usage with this callback.
|
void |
endDocument()
Receive notification of the end of the document.
|
boolean |
endElement(Element elementUnused)
Receive notification of the end of an element.
|
static DefaultCallback |
getInstance()
Returns the singleton instance of the default callback.
|
void |
startDocument()
Receive notification of the beginning of the document.
|
boolean |
startElement(Element elementUnused,
Map<Attribute,MutableString> attrMapUnused)
Receive notification of the start of an element.
|
public static DefaultCallback getInstance()
public void configure(BulletParser parserUnused)
Callback
When a callback is registered with a parser, it needs to set up the parser so that all data required by the callback is actually parsed. The configuration must be a monotone process—you can only set properties and add attribute types to be parsed.
public void startDocument()
Callback
The callback must use this method to reset its internal state so that it can be resued. It must be safe to invoke this method several times.
startDocument
in interface Callback
public boolean startElement(Element elementUnused, Map<Attribute,MutableString> attrMapUnused)
Callback
For simple elements, this is the only notification that the callback will ever receive.
startElement
in interface Callback
elementUnused
- the element whose opening tag was found.attrMapUnused
- a map from Attribute
s to MutableString
s.public boolean endElement(Element elementUnused)
Callback
This method will never be called for element without closing tags, even if such a tag is found.
endElement
in interface Callback
elementUnused
- the element whose closing tag was found.public boolean characters(char[] textUnused, int offsetUnused, int lengthUnused, boolean flowBrokenUnused)
Callback
You must not write into text
, as it could be passed
around to many callbacks.
flowBroken
will be true iff
the flow was broken before text
. This feature makes it possible
to extract quickly the text in a document without looking at the elements.
characters
in interface Callback
textUnused
- an array containing the character data.offsetUnused
- the start position in the array.lengthUnused
- the number of characters to read from the array.flowBrokenUnused
- whether the flow is broken at the start of text
.public boolean cdata(Element elementUnused, char[] textUnused, int offsetUnused, int lengthUnused)
Callback
CDATA sections in an HTML document are the result of meeting a STYLE or SCRIPT element. In that case, the element will be passed as first argument.
You must not write into text
, as it could be passed
around to many callbacks.
cdata
in interface Callback
elementUnused
- the element enclosing the CDATA section, or null
if the
CDATA section was created with explicit markup.textUnused
- an array containing the character data.offsetUnused
- the start position in the array.lengthUnused
- the number of characters to read from the array.public void endDocument()
Callback
endDocument
in interface Callback
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.