Class KeyStrokeMappingsParser
KeyStrokeMapping
s by parsing a text file.
Mappings for the following characters:
- Backspace
- Delete
- Enter
- Escape
- Tab
The following is an example of a mapping file:
a, A, NO_MASK A, A, SHIFT_MASK COMMA, COMMA, NO_MASKEach line represents a character-keystroke mapping where each value is separated by a comma.
The first value represents the character to map. For example 'a' or 'A'. Since each field is separated by a comma, to map the ',' character we need to specify the text "COMMA."
The second value represents the key code, which should be the name of a key code from
without the prefix "VK_". For example, if the key code is KeyEvent
we just need to
specify "COMMA".
KeyEvent.VK_COMMA
The third value represents any modifiers to use, which should be the name of a modifier from
. For example, if the modifier to use is InputEvent
we
need to specify "SHIFT_MASK". If no modifiers are necessary, we just specify "NO_MASK".
InputEvent.SHIFT_MASK
- Since:
- 1.2
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static char
private InputStream
fileAsStream
(File file) private InputStream
fileAsStream
(String file) private static int
private static String
(package private) KeyStrokeMapping
mappingFrom
(String line) private static int
private static ParsingException
Creates a
containing all the character-keystroke mappings specified in the given file.KeyStrokeMappingProvider
private KeyStrokeMappingProvider
parse
(InputStream input) Creates a
containing all the character-keystroke mappings specified in the file with the given name.KeyStrokeMappingProvider
private static String[]
private void
private void
-
Field Details
-
SPECIAL_MAPPINGS
-
-
Constructor Details
-
KeyStrokeMappingsParser
public KeyStrokeMappingsParser()
-
-
Method Details
-
parse
Creates a
containing all the character-keystroke mappings specified in the file with the given name.KeyStrokeMappingProvider
Note: This attempts to read the file using
.ClassLoader.getResourceAsStream(String)
- Parameters:
file
- the name of the file to parse.- Returns:
- the created
KeyStrokeMappingProvider
. - Throws:
NullPointerException
- if the given name isnull
.IllegalArgumentException
- if the given name is empty.ParsingException
- if any error occurs during parsing.- See Also:
-
validate
-
fileAsStream
-
parse
Creates a
containing all the character-keystroke mappings specified in the given file.KeyStrokeMappingProvider
- Parameters:
file
- the file to parse.- Returns:
- the created
KeyStrokeMappingProvider
. - Throws:
NullPointerException
- if the given file isnull
.IllegalArgumentException
- if the given file does not represent an existing file.ParsingException
- if any error occurs during parsing.
-
validate
-
fileAsStream
-
parse
- Throws:
IOException
-
mappingFrom
-
split
-
notConformingWithPatternError
-
characterFrom
-
keyCodeFrom
-
keyCodeNameFrom
-
modifiersFrom
-