@Beta
public class TextObject
extends java.lang.Object
implements java.lang.CharSequence, java.lang.Appendable
LanguageProfiles,
as well as to pass it in to LanguageDetector.detect(java.lang.CharSequence).
To get one, use a TextObjectFactory (through a TextObjectFactoryBuilder).
Example use:
//create the factory once:
TextObjectFactory textObjectFactory = new TextObjectFactoryBuilder()
.withTextFilter(UrlTextFilter.getInstance())
.build();
//then create as many text objects as you like:
TextObject inputText = textObjectFactory.create().append("deutsche Text").append(" ").append("blah blah");
All append() methods go through the textFilter.
Equals/hashCode are not implemented as of now on purpose. You may want to call toString() and compare that.| Modifier and Type | Field and Description |
|---|---|
private int |
maxTextLength |
private @NotNull java.lang.StringBuilder |
stringBuilder |
private @NotNull TextFilter |
textFilter |
| Constructor and Description |
|---|
TextObject(@NotNull TextFilter textFilter,
int maxTextLength) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Appendable |
append(char c) |
TextObject |
append(java.lang.CharSequence text)
Append the target text for language detection.
|
java.lang.Appendable |
append(java.lang.CharSequence csq,
int start,
int end) |
TextObject |
append(java.io.Reader reader)
Append the target text for language detection.
|
char |
charAt(int index) |
int |
length() |
java.lang.CharSequence |
subSequence(int start,
int end) |
@NotNull java.lang.String |
toString() |
@NotNull private final @NotNull TextFilter textFilter
@NotNull private final @NotNull java.lang.StringBuilder stringBuilder
private final int maxTextLength
public TextObject(@NotNull
@NotNull TextFilter textFilter,
int maxTextLength)
maxTextLength - 0 for no limitpublic TextObject append(java.io.Reader reader) throws java.io.IOException
reader - the input reader (BufferedReader as usual)java.io.IOException - Can't read the reader.public TextObject append(java.lang.CharSequence text)
append in interface java.lang.Appendabletext - the target text to appendpublic java.lang.Appendable append(java.lang.CharSequence csq,
int start,
int end)
throws java.io.IOException
append in interface java.lang.Appendablejava.io.IOExceptionpublic java.lang.Appendable append(char c)
throws java.io.IOException
append in interface java.lang.Appendablejava.io.IOExceptionpublic int length()
length in interface java.lang.CharSequencepublic char charAt(int index)
charAt in interface java.lang.CharSequencepublic java.lang.CharSequence subSequence(int start,
int end)
subSequence in interface java.lang.CharSequence@NotNull public @NotNull java.lang.String toString()
toString in interface java.lang.CharSequencetoString in class java.lang.Object