Interface PatternElement

All Known Implementing Classes:
ChoiceGroup, CompoundElement, ExpressionElement, OptionalGroup, RegexGroup, TextElement

public interface PatternElement
The superclass of all elements of a pattern.
  • Method Details

    • match

      int match(String s, int index, MatchContext context)
      Attempts to match the PatternElement to a string at a specified index. About the index, make sure to never increment the index by some arbitrary value when returning
      Parameters:
      s - the string to match this PatternElement against
      index - the index of the string at which this PatternElement should be matched
      Returns:
      the index at which the matching should continue afterwards if successful. Otherwise, -1
    • flatten

      static List<PatternElement> flatten(PatternElement element)
    • getKeywords

      static List<String> getKeywords(PatternElement element)
      This method should return all text components that will always be present, no matter how the pattern is used.
      Parameters:
      element - the element
      Returns:
      the always-present text elements of this pattern
    • getPossibleInputs

      static List<PatternElement> getPossibleInputs(List<PatternElement> elements)