seq);
-
- /**
- * 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 {@code Esc [ A}, and if the
- * pattern recognized this as {@code ArrowUp}, then this field has
- * a value like {@code new KeyStroke(KeyType.ArrowUp)}
- * - partialMatch
-
- * {@code 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 {@code 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.
- */
- class Matching {
- public final KeyStroke fullMatch;
- public final boolean partialMatch;
-
- /**
- * Re-usable result for "not yet" half-matches
- */
- public static final Matching NOT_YET = new Matching( true, null );
-
- /**
- * Convenience constructor for exact matches
- *
- * @param fullMatch the KeyStroke that matched the sequence
- */
- public Matching(KeyStroke fullMatch) {
- this(false,fullMatch);
- }
- /**
- * General constructor
- * For mismatches rather use {@code 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.
- *
- * @param partialMatch true if further characters could lead to a match
- * @param fullMatch The perfectly matching KeyStroke
- */
- public Matching(boolean partialMatch, KeyStroke fullMatch) {
- this.partialMatch = partialMatch;
- this.fullMatch = fullMatch;
- }
-
- @Override
- public String toString() {
- return "Matching{" + "partialMatch=" + partialMatch + ", fullMatch=" + fullMatch + '}';
- }
- }
-}