public class AnnotatedTextBuilder extends Object
It's up to you to split the input into parts that are plain text and parts that are markup.
For example, text with XML markup like
Here is <b>some text</b>
needs to be prepared like this:
new AnnotatedTextBuilder() .addText("Here is ").addMarkup("<b>").addText("some text").addMarkup("</b>") .build()
Constructor and Description |
---|
AnnotatedTextBuilder() |
Modifier and Type | Method and Description |
---|---|
void |
add(TextPart part) |
AnnotatedTextBuilder |
addGlobalMetaData(AnnotatedText.MetaDataKey key,
String value)
Add global meta data like document title or receiver name (when writing an email).
|
AnnotatedTextBuilder |
addGlobalMetaData(String key,
String value)
Add any global meta data about the document to be checked.
|
AnnotatedTextBuilder |
addMarkup(String markup)
Add a markup text snippet like
<b attr='something'> or <div> . |
AnnotatedTextBuilder |
addMarkup(String markup,
String interpretAs)
Add a markup text snippet like
<b attr='something'> or <div> . |
AnnotatedTextBuilder |
addText(String text)
Add a plain text snippet, to be checked by LanguageTool when using
JLanguageTool.check(AnnotatedText) . |
AnnotatedText |
build()
Create the annotated text to be passed into
JLanguageTool.check(AnnotatedText) . |
public AnnotatedTextBuilder addGlobalMetaData(AnnotatedText.MetaDataKey key, String value)
public AnnotatedTextBuilder addGlobalMetaData(String key, String value)
addGlobalMetaData(AnnotatedText.MetaDataKey, String)
.public AnnotatedTextBuilder addText(String text)
JLanguageTool.check(AnnotatedText)
.public AnnotatedTextBuilder addMarkup(String markup)
<b attr='something'>
or <div>
. These
parts will be ignored by LanguageTool when using JLanguageTool.check(AnnotatedText)
.public AnnotatedTextBuilder addMarkup(String markup, String interpretAs)
<b attr='something'>
or <div>
. These
parts will be ignored by LanguageTool when using JLanguageTool.check(AnnotatedText)
.interpretAs
- A string that will be used by the checker instead of the markup. This is usually
whitespace, e.g. \n\n
for <p>
public void add(TextPart part)
public AnnotatedText build()
JLanguageTool.check(AnnotatedText)
.