Interface Callback
- All Known Implementing Classes:
DebugCallbackDecorator
,DefaultCallback
,LinkExtractor
,TextExtractor
This interface is very loosely inspired to the SAX2 interface. However, it strives to be simple, and to be StringFree™.
By contract, all implementations of this interface are bound to be reusable: by calling
startDocument()
, a callback can be used again. It must be safe to call
startDocument()
any number of times.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Callback[]
Deprecated.A singleton empty callback array. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Deprecated.Receive notification of the content of a CDATA section.boolean
characters
(char[] text, int offset, int length, boolean flowBroken) Deprecated.Receive notification of character data inside an element.void
configure
(BulletParser parser) Deprecated.Configure the parser for usage with this callback.void
Deprecated.Receive notification of the end of the document.boolean
endElement
(Element element) Deprecated.Receive notification of the end of an element.void
Deprecated.Receive notification of the beginning of the document.boolean
startElement
(Element element, Map<Attribute, MutableString> attrMap) Deprecated.Receive notification of the start of an element.
-
Field Details
-
EMPTY_CALLBACK_ARRAY
Deprecated.A singleton empty callback array.
-
-
Method Details
-
configure
Deprecated.Configure the parser for usage with this 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.
-
startDocument
void startDocument()Deprecated.Receive notification of the beginning of the document.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.
-
startElement
Deprecated.Receive notification of the start of an element.For simple elements, this is the only notification that the callback will ever receive.
- Parameters:
element
- the element whose opening tag was found.attrMap
- a map fromAttribute
s toMutableString
s.- Returns:
- true to keep the parser parsing, false to stop it.
-
endElement
Deprecated.Receive notification of the end of an element. Warning: unless specific decorators are used, in general a callback will just receive notifications for elements whose closing tag appears explicitly in the document.This method will never be called for element without closing tags, even if such a tag is found.
- Parameters:
element
- the element whose closing tag was found.- Returns:
- true to keep the parser parsing, false to stop it.
-
characters
boolean characters(char[] text, int offset, int length, boolean flowBroken) Deprecated.Receive notification of character data inside an element.You must not write into
text
, as it could be passed around to many callbacks.flowBroken
will be true iff the flow was broken beforetext
. This feature makes it possible to extract quickly the text in a document without looking at the elements.- Parameters:
text
- an array containing the character data.offset
- the start position in the array.length
- the number of characters to read from the array.flowBroken
- whether the flow is broken at the start oftext
.- Returns:
- true to keep the parser parsing, false to stop it.
-
cdata
Deprecated.Receive notification of the content of a CDATA section.CDATA sections in an HTML document are the result of meeting a
STYLE
orSCRIPT
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.- Parameters:
element
- the element enclosing the CDATA section, ornull
if the CDATA section was created with explicit markup.text
- an array containing the character data.offset
- the start position in the array.length
- the number of characters to read from the array.- Returns:
- true to keep the parser parsing, false to stop it.
-
endDocument
void endDocument()Deprecated.Receive notification of the end of the document.
-