| com.sun.midp.chameleon.input.PTDictionary
All known Subclasses: com.sun.midp.chameleon.input.PTDictionaryImpl,
PTDictionary | public interface PTDictionary (Code) | | Interface for predictive text processing
This class is responsible for initializing the Dictionary
Two APIs are required,
addWord : An interface to add a word to current dictionary (if supported)
iterator: Get a iterator object with the following methods
iterator.next() : get next possible completion string
iterator.hasNext() : check if another possible completion exists
iterator.nextLevel(int key) : add a char to the current completion
iterator.provLevel() : backspace last char from current completion
iterator.reset() : clear current completion
iteratr.resetNext() : revert to first possible completion string
Example of using the predictive text API:
PTDictionary dictionary;
PTIterator iter=dictionary.iterator();
iter.nextLevel('2');
iter.nextLevel('2');
iter.nextLevel('2');
while(iter.hasNext()) {
String completion=iter.next();
System.out.println(completion);
//will print "aca" (short of "academy") "cab" (short of "cabin"),
// "acc" (short of "accelerate") etc.
}
|
addWord | public boolean addWord(String word)(Code) | | add a new word to the dictionary
Parameters: word - new word to add to dictionary true if new word was added, false otherwise |
iterator | public PTIterator iterator()(Code) | | get a iterator to the predictive text library
a predictive text Iterator |
|
|