FileDocCategorySizeDatePackage
SymbolInputMode.javaAPI DocphoneME MR2 API (J2ME)24397Wed May 02 18:00:20 BST 2007com.sun.midp.chameleon.input

SymbolInputMode

public class SymbolInputMode extends Object implements InputMode
An InputMode instance which allows to select the particular symbol from the table of predefined symbols.

Fields Summary
protected int
lastKey
A holder for the keyCode which was last processed
protected InputModeMediator
mediator
The InputModeMediator for the current input session
protected final SymbolTable
st
Symbol table
protected static final char[]
symbolTableChars
The number of symbol_table is designed to be 29 for 5x6 matrix, starting the selection at 12. But if you have more, the total must be under 36 for 6x6 matrix.
private static final boolean[]
isMap
this mode is not set as default. So the map is initialoized by false
Constructors Summary
Methods Summary
public voidbeginInput(InputModeMediator mediator, java.lang.String inputSubset, int constraints)
This method will be called before any input keys are passed to this InputMode to allow the InputMode to perform any needed initialization. A reference to the InputModeMediator which is currently managing the relationship between this InputMode and the input session is passed in. This reference can be used by this InputMode to commit text input as well as end the input session with this InputMode. The reference is only valid until this InputMode's endInput() method is called.

param
constraints text input constraints. The semantics of the constraints value are defined in the TextField API.
param
mediator the InputModeMediator which is negotiating the relationship between this InputMode and the input session
param
inputSubset current input subset

        validateState(false);
        this.mediator = mediator;
    
protected booleancommitPendingChar()
Commit pending char

return
true if the char has been committed otherwise false

        boolean committed = false;
        if (lastKey != KEYCODE_NONE) {
            committed = true;
            mediator.commit(String.valueOf((char)lastKey));
        }
        lastKey = -1;
        return committed;
    
protected voidcompleteInputMode(boolean commit)
Complete current input mode

param
commit true if the symbol has to be committed otherwise false

        if (commit) {
            commitPendingChar();
        }
        mediator.inputModeCompleted();
    
public voidendInput()
Mark the end of this InputMode's processing. The only possible call to this InputMode after a call to endInput() is a call to beginInput() to begin a new input session.

        validateState(true);
        mediator = null;
    
public java.lang.StringgetCommandName()
Returns the command name which will represent this InputMode to the user

return
the locale-appropriate command name to represent this InputMode to the user

        return getName();
    
public javax.microedition.lcdui.DisplayablegetDisplayable()
Symbol Input mode is represented by Symbol table implemented as canvas

return
SymbolTable

        return st;
    
public boolean[][]getIsConstraintsMap()
Returns the map specifying this input mode is proper one for the particular pair of input subset and constraint. The form of the map is |ANY|EMAILADDR|NUMERIC|PHONENUMBER|URL|DECIMAL| --------------------------------------------------------------------- IS_FULLWIDTH_DIGITS |t|f| t|f | t|f | t|f |t|f| t|f | IS_FULLWIDTH_LATIN |t|f| t|f | t|f | t|f |t|f| t|f | IS_HALFWIDTH_KATAKANA |t|f| t|f | t|f | t|f |t|f| t|f | IS_HANJA |t|f| t|f | t|f | t|f |t|f| t|f | IS_KANJI |t|f| t|f | t|f | t|f |t|f| t|f | IS_LATIN |t|f| t|f | t|f | t|f |t|f| t|f | IS_LATIN_DIGITS |t|f| t|f | t|f | t|f |t|f| t|f | IS_SIMPLIFIED_HANZI |t|f| t|f | t|f | t|f |t|f| t|f | IS_TRADITIONAL_HANZI |t|f| t|f | t|f | t|f |t|f| t|f | MIDP_UPPERCASE_LATIN |t|f| t|f | t|f | t|f |t|f| t|f | MIDP_LOWERCASE_LATIN |t|f| t|f | t|f | t|f |t|f| t|f | NULL |t|f| t|f | t|f | t|f |t|f| t|f |

return
input subset x constraint map


                                                                                                                                                                                                                                                                                                                                                                                                                                        
       
        return isMap;
    
public java.lang.String[]getMatchList()
Gets the possible string matches

return
returns the set of options.

        return new String[0];
    
public java.lang.StringgetName()
Returns the display name which will represent this InputMode to the user, such as in a selection list or the softbutton bar.

return
the locale-appropriate name to represent this InputMode to the user

        return Resource.getString(ResourceConstants.LCDUI_TF_SYMBOLS);
    
public java.lang.StringgetNextMatch()
Return the next possible match for the key input processed thus far by this InputMode. A call to this method should be preceeded by a check of hasMoreMatches(). If the InputMode has more available matches for the given input, this method will return them one by one.

return
a String representing the next available match to the key input thus far

        return null;
    
public chargetPendingChar()
return the pending char used to bypass the asynchronous commit mechanism e.g. to immediately commit a char before moving the cursor

return
return the pending char

        return lastKey == KEYCODE_NONE ? 0 : (char)lastKey;
    
public booleanhasDisplayable()
Returns true if input mode is using its own displayable, false ifinput mode does not require the speial displayable for its representation. For Symbol mode is represented by Symbol table canvas, so it returns true

return
true if input mode is using its own displayable, otherwise false

        return true;
    
public booleanhasMoreMatches()
True, if after processing a key, there is more than one possible match to the input. If this method returns true, the getNextMatch() method can be called to return the value.

return
true if after processing a key, there is more than the one possible match to the given input

        return false;
    
public static booleanisSymbol(char c)
Check if the char is the symbol from the symbol table

param
c char
return
true if this char exists in the symbol table otherwise false.

        for (int i = 0; i < symbolTableChars.length; i++) {
            if (symbolTableChars[i] == c) {
                return true;
            }
        }
        return false;
    
public intprocessKey(int keyCode, boolean longPress)
Process the given key code as input. This method will return true if the key was processed successfully, false otherwise.

param
keyCode the keycode of the key which was input
param
longPress return true if it's long key press otherwise false
return
true if the key was processed by this InputMode, false otherwise.

        return KEYCODE_NONE;
    
public booleansupportsConstraints(int constraints)
This method is called to determine if this InputMode supports the given text input constraints. The semantics of the constraints value are defined in the javax.microedition.lcdui.TextField API. If this InputMode returns false, this InputMode must not be used to process key input for the selected text component.

param
constraints text input constraints. The semantics of the constraints value are defined in the TextField API.
return
true if this InputMode supports the given text component constraints, as defined in the MIDP TextField API


     
        symbolTableChars =
            Resource.getString(ResourceConstants.LCDUI_TF_SYMBOLS_TABLE).
            toCharArray();
    
        switch (constraints & TextField.CONSTRAINT_MASK) {
            case TextField.NUMERIC:
            case TextField.DECIMAL:
            case TextField.PHONENUMBER:
                return false;
            default:
                return true;
        }
    
protected voidvalidateState(boolean activeOperation)
This method will validate the state of this InputMode. If this is a check for an "active" operation, the TextInputMediator must be non-null or else this method will throw an IllegalStateException. If this is a check for an "inactive" operation, then the TextInputMediator should be null.

param
activeOperation true if any operation is active otherwise false.

        if (activeOperation && mediator == null) {
            throw new IllegalStateException(
            "Illegal operation on an input session already in progress");
        } else if (!activeOperation && mediator != null) {
            throw new IllegalStateException(
            "Illegal operation on an input session which is not in progress");
        }