Package org.languagetool.rules.patterns
Class Substrings
java.lang.Object
org.languagetool.rules.patterns.Substrings
A list of strings that are expected to occur in a larger string in the given order,
with optional requirements for them to start/end the text.
This class is used to avoid more expensive regular expression matching where possible.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int(package private) final booleanWhether the last ofsubstringsmust occur at the matched fragment end(package private) final booleanWhether the first ofsubstringsmust occur at the matched fragment start(package private) final String[] -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)Substrings(boolean mustStart, boolean mustEnd, String[] substrings) privateSubstrings(boolean mustStart, boolean mustEnd, String[] substrings, int minLength) -
Method Summary
Modifier and TypeMethodDescription(package private) SubstringscheckCanReplaceRegex(String regexp) (package private) Substringsconcat(Substrings another) private booleancontainsSubstrings(String text, boolean caseSensitive, int textPos, int firstSubstringIndex) (package private) intCheck whethertextcontains all required substrings and returns the index of the first of them, or -1 if the text doesn't contain these substrings.private static intprivate static intprivate static intindexOfIgnoreCase(String text, String substring, int from) (package private) booleantoString()
-
Field Details
-
substrings
-
minLength
private final int minLength -
mustStart
final boolean mustStartWhether the first ofsubstringsmust occur at the matched fragment start -
mustEnd
final boolean mustEndWhether the last ofsubstringsmust occur at the matched fragment end
-
-
Constructor Details
-
Substrings
Substrings(boolean mustStart, boolean mustEnd, String[] substrings) -
Substrings
-
-
Method Details
-
checkCanReplaceRegex
- Returns:
- a version of this
Substringsobject whosematches(java.lang.String, boolean)could completely replace the given regexp, ornullif that's not feasible.
-
toString
-
concat
-
find
Check whethertextcontains all required substrings and returns the index of the first of them, or -1 if the text doesn't contain these substrings. -
matches
- Returns:
- whether the given text contains all the required substrings
-
containsSubstrings
private boolean containsSubstrings(String text, boolean caseSensitive, int textPos, int firstSubstringIndex) -
indexOf
-
indexOfIgnoreCase
-
findNext
-