org.swixml.converters

Class KeyStrokeConverter

Implemented Interfaces:
Converter

public class KeyStrokeConverter
extends java.lang.Object
implements Converter

A Converter that turns a Strings in the form of a filename into an KeyStroke objects.
   Valild syntax includes:
   
 

Version:
$Revision: 1.1 $
Authors:
Wolf Paulus
Eric Lafargue
See Also:
javax.swing.KeyStroke.getKeyStroke(java.lang.String), ConverterLibrary

Field Summary

static Class
TEMPLATE
converter's return type

Method Summary

static Object
conv(Class type, Attribute attr, Localizer localizer)
Converts a String into an KeyStroke.
Object
convert(Class type, Attribute attr, Localizer localizer)
Converts a String into an KeyStroke through a Resource lookup
Class
convertsTo()
A Converters conversTo method informs about the Class type the converter is returning when its convert method is called

Field Details

TEMPLATE

public static final Class TEMPLATE
converter's return type

Method Details

conv

public static Object conv(Class type,
                          Attribute attr,
                          Localizer localizer)
Converts a String into an KeyStroke. Parses a string and returns a KeyStroke. The string must have the following syntax:
    <modifiers>* (<typedID> | <pressedReleasedID>)

    modifiers := shift | control | ctrl | meta | alt | button1 | button2 | button3
    typedID := typed <typedKey>
    typedKey := string of length 1 giving Unicode character.
    pressedReleasedID := (pressed | released) key
    key := KeyEvent key code name, i.e. the name following "VK_".
 
If typed, pressed or released is not specified, pressed is assumed. Here are some examples:
     "INSERT" => getKeyStroke(KeyEvent.VK_INSERT, 0);
     "control DELETE" => getKeyStroke(KeyEvent.VK_DELETE, InputEvent.CTRL_MASK);
     "alt shift X" => getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK);
     "alt shift released X" => getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK, true);
     "typed a" => getKeyStroke('a');
 
In order to maintain backward-compatibility, specifying a null String, or a String which is formatted incorrectly, returns null.
Parameters:
type - Class not used
attr - Attribute attribute provides the value to be converted
localizer - Localizer allow the use of resource lookups
Returns:
Object - a KeyStroke object for that String, or null if the specified String is null, or is formatted incorrectly

convert

public Object convert(Class type,
                      Attribute attr,
                      Localizer localizer)
Converts a String into an KeyStroke through a Resource lookup
Specified by:
convert in interface Converter
Parameters:
type - Class not used
attr - Attribute attribute provides the value to be converted
localizer - Localizer allow the use of resource lookups
Returns:
Object - a KeyStroke

convertsTo

public Class convertsTo()
A Converters conversTo method informs about the Class type the converter is returning when its convert method is called
Specified by:
convertsTo in interface Converter
Returns:
Class - the Class the converter is returning when its convert method is called

Copyright B) 2002 - 2005 - Wolf Paulus - CarlsbadCubes.com . All rights reserved.