FileDocCategorySizeDatePackage
InputMethodHandler.javaAPI DocJ2ME MIDP 2.06005Thu Nov 07 12:02:22 GMT 2002com.sun.midp.lcdui

InputMethodHandler

public abstract class InputMethodHandler extends Object
The InputMethod handler.

Fields Summary
public static final int
KEYCODE_NONE
A special no-op key.
public static final int
KEYCODE_CLEAR
Key code for deleting
public static final int
KEYCODE_CLEARALL
Key code for deleting all text
public static final int
KEYCODE_SIGNCHANGE
Key code if the '#' key is pressed in NUMERIC or DECIMAL
public static final int
KEYCODE_SHIFT
Key code if the '#' key is pressed in NUMERIC or DECIMAL
private static InputMethodHandler
thisIM
handle for the current input method handler.
Constructors Summary
Methods Summary
public abstract booleanclearInputMethodClient(InputMethodClient imc)
Clears the current input handler if it matches the specified one. Any pending keys are first sent to the client.

param
imc the client that was set to receive callbacks
return
true if the current client was cleared, false otherwise

public abstract voidendComposition(boolean discard)
End the on-going composition. Any keys that are pending are conditionally sent to the client.

param
discard true to discard any pending keys

public abstract voidflush()
Removes any pending key presses

public static com.sun.midp.lcdui.InputMethodHandlergetInputMethodHandler()
get the input method handler.

return
the current input method handler.

                    
        
        if (thisIM != null) {
            return thisIM;
        }
        thisIM = getInputMethodHandlerImpl();
        return thisIM;
    
private static com.sun.midp.lcdui.InputMethodHandlergetInputMethodHandlerImpl()
get the input handler class.

return
handle to input method handlet.

        try {
            String n =
		Configuration.getProperty(
                    "com.sun.midp.lcdui.inputMethodHandler");
            if (n != null) {
                Class c = Class.forName(n);
                return (InputMethodHandler) c.newInstance();
            }
            String loc = Configuration.getProperty("microedition.locale");
            if (loc != null) {
                /* 
                 * This only check for the first '-' in the locale, and
                 * convert to '_' for Class.forName() to work.
                 */
                int hyphen;
                if ((hyphen = loc.indexOf('-")) != -1) {
                    StringBuffer tmploc = new StringBuffer(loc);
		    tmploc.setCharAt(hyphen, '_");
		    loc = tmploc.toString();
                }

                String cls
                    = "com.sun.midp.lcdui.i18n.DefaultInputMethodHandler_";
                while (true) {
                    try {
                        Class c = Class.forName(cls + loc);
                        return (InputMethodHandler) c.newInstance();
                    } catch (Throwable t) {}
                    int pos = loc.lastIndexOf('_");
                    if (pos == -1) {
                        break;
                    } else {
                        loc = loc.substring(0, pos);
                    }
                }
            }
            Class c = 
                Class.forName("com.sun.midp.lcdui.DefaultInputMethodHandler");
            return (InputMethodHandler) c.newInstance();
        } catch (Throwable t) {            
            System.out.println(t);          
	    throw new Error("Textbox input method was not initialized.");
        }
    
public booleanisSymbol(char c)
Determine whether the character is considered a symbol

param
c character to test
return
true if the character is considered a symbol, false otherwise

 
        return false;
    
public abstract intkeyPressed(int keyCode)
Called when a key is pressed.

param
keyCode The key code of the key that was pressed
return
the key code of the actual key that was input. This may depend on the keymap in use. -1 if no immediate decision could be made, in which case a call back may occur in the future.

public abstract intkeyReleased(int keyCode)
Called when a key is released.

param
keyCode The key code of the key that was released
return
the key code of the key released

public abstract intkeyRepeated(int keyCode)
Called when a key is repeated.

param
keyCode The key code of the key that was repeated
return
the key code of the key repeated

public abstract intkeyTyped(char c)
Called when a key is repeated.

param
c The key code of the key that was repeated
return
the key code of the actual key that was input. This may depend on the keymap in use. -1 if no immediate decision could be made, in which case a call back may occur in the future.

public abstract booleansetConstraints(int constraints)
set the constraints, modifiers, and other data structures that depend on them.

param
constraints constraints to set. See TextField for values
return
true if the constraints were set, false otherwise

public abstract voidsetInputMethodClient(InputMethodClient imc)
Set the InputMethodClient object to the InputMethod.

param
imc save the current input method client.

public abstract java.lang.String[]supportedInputModes()
Return the supported input modes.

return
array of strings of supported input modes.