Interface PatternElement
- All Known Implementing Classes:
ChoiceGroup, CompoundElement, ExpressionElement, OptionalGroup, RegexGroup, TextElement
public interface PatternElement
The superclass of all elements of a pattern.
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<PatternElement> flatten(PatternElement element) getKeywords(PatternElement element) This method should return all text components that will always be present, no matter how the pattern is used.static List<PatternElement> getPossibleInputs(List<PatternElement> elements) intmatch(String s, int index, MatchContext context) Attempts to match thePatternElementto a string at a specified index.
-
Method Details
-
match
Attempts to match thePatternElementto 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 againstindex- 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
-
getKeywords
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
-