public interface TextSourceEncounter
TextSources when they should parse their content.
Sources should use location(Location) to update the location of
things before calling methods such as startParagraph(),
text(CharSequence, Location) and endParagraph().
Sources may set attributes on tokens emitted via setAttribute(TokenProperty, Object)
and clearAttribute(TokenProperty).
| Modifier and Type | Method and Description |
|---|---|
void |
clearAttribute(TokenProperty<?> attribute)
Clear an attribute.
|
void |
done()
Indicate that we are done parsing.
|
void |
endParagraph()
End current paragraph-level content.
|
boolean |
inParagraph()
Check if we are currently in a paragraph.
|
Locale |
locale()
Get the locale we are building the tree for.
|
Location |
location()
Get the currently set location.
|
void |
location(Location location)
Set the location of the next event.
|
<T> void |
setAttribute(TokenProperty<T> attribute,
T value)
Set an attribute at the current location.
|
void |
startParagraph()
Start new paragraph-level content.
|
void |
text(CharSequence text,
Location end)
Add some text.
|
Locale locale()
Location location()
void location(Location location)
location - boolean inParagraph()
void startParagraph()
void endParagraph()
void done()
void text(CharSequence text, Location end)
LanguageParser and split into
sentences and tokens such as words, symbols and whitespace.
All of the text in a paragraph does not need to be added at once, it is possible to add it in chunks. For example a HTML parser will decode entities and will want update the source location as it does this.
text - the text to addend - the location at which the text ends<T> void setAttribute(TokenProperty<T> attribute, T value)
attribute - value - void clearAttribute(TokenProperty<?> attribute)
attribute - Copyright © 2018. All rights reserved.