Methods Summary |
---|
protected char[] | getCharOptions(int lastKey)Gets the possible matches for the key code
char[] chars = null;
switch (lastKey) {
case Canvas.KEY_NUM0:
chars = keyMap[0];
break;
case Canvas.KEY_NUM1:
chars = keyMap[1];
break;
case Canvas.KEY_NUM2:
chars = keyMap[2];
break;
case Canvas.KEY_NUM3:
chars = keyMap[3];
break;
case Canvas.KEY_NUM4:
chars = keyMap[4];
break;
case Canvas.KEY_NUM5:
chars = keyMap[5];
break;
case Canvas.KEY_NUM6:
chars = keyMap[6];
break;
case Canvas.KEY_NUM7:
chars = keyMap[7];
break;
case Canvas.KEY_NUM8:
chars = keyMap[8];
break;
case Canvas.KEY_NUM9:
chars = keyMap[9];
break;
case Canvas.KEY_POUND:
chars = keyMap[10];
break;
case Canvas.KEY_STAR:
break;
default:
// This can actually happen if the Timer went off without
// a pending key, which can sometimes happen.
break;
}
return chars;
|
private java.lang.String[] | getList()Get the list of matches. The list is cached until the word is decreased/
increased by the user.
if (list == null && buffer.length() > 0) {
char[] next = getCharOptions(buffer.charAt(buffer.length() - 1));
list = new String[next.length];
String base = new String();
if (states.size() > 0) {
base = (String)(states.elementAt(states.size() - 1));
}
for (int j = 0; j < next.length; j++) {
list[j] = base + next[j];
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"[getList] next = " + list[j]);
}
}
}
return list;
|
private char[][] | getMapByLine(java.lang.String line)Converts the string to key map. The rows are separated each from other
by '$'. The characters inside of one row follow each to other without
any separator.
char[] chars = line.toCharArray();
int rows = 1;
for (int i = chars.length - 1; i >= 0; i--) {
if (chars[i] == '$") rows++;
}
char[][] map = new char[rows][];
for (int start = 0, j = 0; start < chars.length; j++) {
int end = -1;
for (int k = start; k < chars.length && end == -1; k++) {
if (chars[k] == '$") {
end = k;
}
}
// if '$' is not found that means the end of string is reached
if (end == -1) end = chars.length;
map[j] = new char[end - start];
System.arraycopy(chars, start, map[j], 0, map[j].length);
start = end + 1;
}
return map;
|
public boolean | hasNext()Returns true if the iteration has more elements. (In other words,
returns true if next would return an
element rather than throwing an exception.)
boolean ret = false;
String[] ls = getList();
if (ls != null && ls.length > 0) {
ret = selected < ls.length;
}
return ret;
|
public java.lang.String | next()Returns the next element in the iteration.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"[iter.nextCompletionOption] >>");
}
String ret = null;
ret = getList()[selected++];
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"[iter.next] : " + ret);
}
return ret;
|
public void | nextLevel(int keyCode)Adds a key to current completion string
String[] ls = getList();
if (ls != null && ls.length > 0) {
states.addElement(ls[selected > 0 ? selected - 1 : 0]);
}
buffer.append((char)keyCode);
selected = 0;
list = null;
|
public void | prevLevel()Backspace on key in current completion string.
if (states.size() > 0) {
states.removeElementAt(states.size() - 1);
}
if (buffer.length() > 0) {
buffer.deleteCharAt(buffer.length() - 1);
}
selected = 0;
list = null;
|
public void | reset()Clear completion state
if (buffer.length() > 0) {
buffer.delete(0, buffer.length());
}
states.removeAllElements();
selected = 0;
list = null;
|
public void | resetNext()Reverts to first possible completion.
If next() has been called uptil hasNext() returns false, then after
calling reviewCompletionOptions(), calling next() will return
the 1st completion
selected = 0;
|