Class BasicCharacterPattern

  • All Implemented Interfaces:
    CharacterPattern

    public class BasicCharacterPattern
    extends java.lang.Object
    implements CharacterPattern
    Very simple pattern that matches the input stream against a pre-defined list of characters. For the pattern to match, the list of characters must match exactly what's coming in on the input stream.
    • Constructor Summary

      Constructors 
      Constructor Description
      BasicCharacterPattern​(KeyStroke result, char... pattern)
      Creates a new BasicCharacterPattern that matches a particular sequence of characters into a KeyStroke
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      char[] getPattern()
      Returns the characters that makes up this pattern, as an array that is a copy of the array used internally
      KeyStroke getResult()
      Returns the keystroke that this pattern results in
      int hashCode()  
      CharacterPattern.Matching match​(java.util.List<java.lang.Character> seq)
      Given a list of characters, determine whether it exactly matches any known KeyStroke, and whether a longer sequence can possibly match.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • pattern

        private final char[] pattern
    • Constructor Detail

      • BasicCharacterPattern

        public BasicCharacterPattern​(KeyStroke result,
                                     char... pattern)
        Creates a new BasicCharacterPattern that matches a particular sequence of characters into a KeyStroke
        Parameters:
        result - KeyStroke that this pattern will translate to
        pattern - Sequence of characters that translates into the KeyStroke
    • Method Detail

      • getPattern

        public char[] getPattern()
        Returns the characters that makes up this pattern, as an array that is a copy of the array used internally
        Returns:
        Array of characters that defines this pattern
      • getResult

        public KeyStroke getResult()
        Returns the keystroke that this pattern results in
        Returns:
        The keystoke this pattern will return if it matches
      • match

        public CharacterPattern.Matching match​(java.util.List<java.lang.Character> seq)
        Description copied from interface: CharacterPattern
        Given a list of characters, determine whether it exactly matches any known KeyStroke, and whether a longer sequence can possibly match.
        Specified by:
        match in interface CharacterPattern
        Parameters:
        seq - of characters to check
        Returns:
        see Matching
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object