Class Substrings

java.lang.Object
org.languagetool.rules.patterns.Substrings

class Substrings extends Object
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 Details

    • substrings

      final String[] substrings
    • minLength

      private final int minLength
    • mustStart

      final boolean mustStart
      Whether the first of substrings must occur at the matched fragment start
    • mustEnd

      final boolean mustEnd
      Whether the last of substrings must occur at the matched fragment end
  • Constructor Details

    • Substrings

      Substrings(boolean mustStart, boolean mustEnd, String[] substrings)
    • Substrings

      private Substrings(boolean mustStart, boolean mustEnd, String[] substrings, int minLength)
  • Method Details

    • checkCanReplaceRegex

      @Nullable Substrings checkCanReplaceRegex(String regexp)
      Returns:
      a version of this Substrings object whose matches(java.lang.String, boolean) could completely replace the given regexp, or null if that's not feasible.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • concat

      Substrings concat(Substrings another)
    • find

      int find(String text, boolean caseSensitive)
      Check whether text contains all required substrings and returns the index of the first of them, or -1 if the text doesn't contain these substrings.
    • matches

      boolean matches(String text, boolean caseSensitive)
      Returns:
      whether the given text contains all the required substrings
    • containsSubstrings

      private boolean containsSubstrings(String text, boolean caseSensitive, int textPos, int firstSubstringIndex)
    • indexOf

      private static int indexOf(String text, String substring, boolean caseSensitive, int from)
    • indexOfIgnoreCase

      private static int indexOfIgnoreCase(String text, String substring, int from)
    • findNext

      private static int findNext(String text, int from, char up, char low)