com.togethersoft.openapi.util.ui
Class KeyStrokeFormat

java.lang.Object
  |
  +--java.text.Format
        |
        +--com.togethersoft.openapi.util.ui.KeyStrokeFormat

public class KeyStrokeFormat
extends Format

This class is suited to format and parse Strings which represent KeyStrokes - a key being typed
on the keyboard. It contains both a char code for the key and a modifier
(alt, shift, ctrl, meta, or a combination). This class is a singleton.

Author:
TogetherSoft
Since: Together 4.0

Field Summary
 private final static StringCODE_PREFIX
           
 private final static StringMODIFIER_SUFFIX
           
 private static KeyStrokeFormatmyInstance
           

Method Summary
 private static intfindFirst(String chars, String where, int startIndex)
           
 StringBufferformat(Object obj, StringBuffer toAppendTo, FieldPosition pos)
          Formats Object to StringBuffer.
 StringBufferformat(KeyStroke stroke, StringBuffer toAppendTo, FieldPosition pos)
          Formats Object to StringBuffer.
 static KeyStrokefromString(String s)
          Formats String to KeyStroke.
 static KeyStrokeFormatgetInstance()
          Returns the only instance of this KeyStrokeFormat.
 ObjectparseObject(String source, ParsePosition status)
          Parses a string to produce a KeyStroke.
 static StringtoString(KeyStroke stroke)
          Formats KeyStroke to String.

Methods inherited from class java.text.Format
format, parseObject, clone

Methods inherited from class java.lang.Object
getClass, hashCode, equals, toString, notify, notifyAll, wait, wait, wait, finalize

Field Detail

CODE_PREFIX

private final static String CODE_PREFIX

MODIFIER_SUFFIX

private final static String MODIFIER_SUFFIX

myInstance

private static KeyStrokeFormat myInstance
Method Detail

findFirst

private static int findFirst(String chars, String where, int startIndex)

format

public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
Formats Object to StringBuffer.
Parameters:
obj Object to be formatted
toAppendTo StringBuffer to which formatted Object is to be appended
pos
Returns: StringBuffer which contains formatted Object
Throws:
IllegalArgumentException if given Object is not an instance of KeyStroke

format

public StringBuffer format(KeyStroke stroke, StringBuffer toAppendTo, FieldPosition pos)
Formats Object to StringBuffer.
Parameters:
stroke KeyStroke to be formatted
toAppendTo StringBuffer to which formatted Object is to be appended
pos
Returns: StringBuffer which contains formatted Object
Throws:
IllegalArgumentException if given KeyStroke contains unknown modifiers

fromString

public static KeyStroke fromString(String s)
Formats String to KeyStroke.
Parameters:
s String to be formatted
Returns: if given String can be formatted returns KeyStroke, otherwise returns null

getInstance

public static KeyStrokeFormat getInstance()
Returns the only instance of this KeyStrokeFormat.

parseObject

public Object parseObject(String source, ParsePosition status)
Parses a string to produce a KeyStroke.
Parameters:
source String to be parsed
status Specifies position in string from which parsing will be started;
before calling, set status.index to the offset you want to start parsing at in the source.

toString

public static String toString(KeyStroke stroke)
Formats KeyStroke to String.
Parameters:
stroke KeyStroke to be formatted

Association Links

to Class com.togethersoft.openapi.util.ui.KeyStrokeFormat

to Class java.lang.String

to Class java.lang.String