- java.lang.Object
-
- com.googlecode.lanterna.input.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.googlecode.lanterna.input.CharacterPattern
CharacterPattern.Matching
-
-
Constructor Summary
Constructors Constructor Description BasicCharacterPattern(KeyStroke result, char... pattern)
Creates a new BasicCharacterPattern that matches a particular sequence of characters into aKeyStroke
-
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 internallyKeyStroke
getResult()
Returns the keystroke that this pattern results inint
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.
-
-
-
Field Detail
-
result
private final KeyStroke result
-
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 aKeyStroke
- Parameters:
result
-KeyStroke
that this pattern will translate topattern
- Sequence of characters that translates into theKeyStroke
-
-
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 interfaceCharacterPattern
- Parameters:
seq
- of characters to check- Returns:
- see
Matching
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-