01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package com.sun.midp.chameleon.input;
28:
29: /**
30: * Interface for predictive text processing
31: *
32: * This class is responsible for initializing the Dictionary
33: * Two APIs are required,
34: * addWord : An interface to add a word to current dictionary (if supported)
35: * iterator: Get a iterator object with the following methods
36: * iterator.next() : get next possible completion string
37: * iterator.hasNext() : check if another possible completion exists
38: * iterator.nextLevel(int key) : add a char to the current completion
39: * iterator.provLevel() : backspace last char from current completion
40: * iterator.reset() : clear current completion
41: * iteratr.resetNext() : revert to first possible completion string
42: *
43: * Example of using the predictive text API:
44: *
45: * PTDictionary dictionary;
46: * PTIterator iter=dictionary.iterator();
47: * iter.nextLevel('2');
48: * iter.nextLevel('2');
49: * iter.nextLevel('2');
50: * while(iter.hasNext()) {
51: * String completion=iter.next();
52: * System.out.println(completion);
53: * //will print "aca" (short of "academy") "cab" (short of "cabin"),
54: * // "acc" (short of "accelerate") etc.
55: * }
56: *
57: */
58: public interface PTDictionary {
59: /**
60: * get a iterator to the predictive text library
61: *
62: * @return a predictive text Iterator
63: */
64:
65: public PTIterator iterator();
66:
67: /**
68: * add a new word to the dictionary
69: *
70: * @param word new word to add to dictionary
71: * @return true if new word was added, false otherwise
72: */
73:
74: public boolean addWord(String word);
75: }
|