Class BasicCharacterPattern

java.lang.Object
com.googlecode.lanterna.input.BasicCharacterPattern
All Implemented Interfaces:
CharacterPattern

public class BasicCharacterPattern extends 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.
  • Field Details

    • result

      private final KeyStroke result
    • pattern

      private final char[] pattern
  • Constructor Details

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

    • 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

      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(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object