Class CharacterPattern.Matching

java.lang.Object
com.googlecode.lanterna.input.CharacterPattern.Matching
Enclosing interface:
CharacterPattern

public static class CharacterPattern.Matching extends Object
This immutable class describes a matching result. It wraps two items, partialMatch and fullMatch.
fullMatch
The resulting KeyStroke if the pattern matched, otherwise null.
Example: if the tested sequence is Esc [ A, and if the pattern recognized this as ArrowUp, then this field has a value like new KeyStroke(KeyType.ArrowUp)
partialMatch
true, if appending appropriate characters at the end of the sequence can produce a match.
Example: if the tested sequence is "Esc [", and the Pattern would match "Esc [ A", then this field would be set to true.
In principle, a sequence can match one KeyStroke, but also say that if another character is available, then a different KeyStroke might result. This can happen, if (e.g.) a single CharacterPattern-instance matches both the Escape key and a longer Escape-sequence.
  • Field Details

    • fullMatch

      public final KeyStroke fullMatch
    • partialMatch

      public final boolean partialMatch
    • NOT_YET

      public static final CharacterPattern.Matching NOT_YET
      Re-usable result for "not yet" half-matches
  • Constructor Details

    • Matching

      public Matching(KeyStroke fullMatch)
      Convenience constructor for exact matches
      Parameters:
      fullMatch - the KeyStroke that matched the sequence
    • Matching

      public Matching(boolean partialMatch, KeyStroke fullMatch)
      General constructor

      For mismatches rather use null and for "not yet" matches use NOT_YET. Use this constructor, where a sequence may yield both fullMatch and partialMatch or for merging result Matchings of multiple patterns.

      Parameters:
      partialMatch - true if further characters could lead to a match
      fullMatch - The perfectly matching KeyStroke
  • Method Details