Class CharacterPattern.Matching

  • Enclosing interface:
    CharacterPattern

    public static class CharacterPattern.Matching
    extends java.lang.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 Detail

      • fullMatch

        public final KeyStroke fullMatch
      • partialMatch

        public final boolean partialMatch
    • Constructor Detail

      • 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 Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object