Package com.inet.jortho
Class DictionaryFactory
- java.lang.Object
-
- com.inet.jortho.DictionaryFactory
-
class DictionaryFactory extends java.lang.ObjectWith the DictionaryFactory you can create / load a Dictionary. A Dictionary is list of word with a API for searching. The list is saved internal as a tree.- See Also:
Dictionary
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classDictionaryFactory.NodeA node in the search tree.
-
Field Summary
Fields Modifier and Type Field Description private DictionaryFactory.Noderootprivate intsizeprivate char[]tree
-
Constructor Summary
Constructors Constructor Description DictionaryFactory()Empty Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.String word)Add a word to the tree.(package private) voidcheckSize(int newSize)Check the size of the array and resize it if needed.Dictionarycreate()Create from the data in this factory a Dictionary object.voidloadWordList(java.net.URL filename)Load the directory from a compressed list of words with UTF8 encoding.voidloadWords(java.util.Iterator<java.lang.String> words)
-
-
-
Field Detail
-
root
private final DictionaryFactory.Node root
-
tree
private char[] tree
-
size
private int size
-
-
Method Detail
-
loadWordList
public void loadWordList(java.net.URL filename) throws java.io.IOExceptionLoad the directory from a compressed list of words with UTF8 encoding. The words must be delimited with newlines. This method can be called multiple times.- Parameters:
filename- the name of the file- Throws:
java.io.IOException- If an I/O error occurs.java.lang.NullPointerException- If filename is null.
-
loadWords
public void loadWords(java.util.Iterator<java.lang.String> words)
-
add
public void add(java.lang.String word)
Add a word to the tree. If it already exist then it has no effect.- Parameters:
word- the new word.
-
create
public Dictionary create()
Create from the data in this factory a Dictionary object. If there are no word added then the Dictionary is empty. The Dictionary need fewer memory as the DictionaryFactory.- Returns:
- a Dictionary object.
-
checkSize
final void checkSize(int newSize)
Check the size of the array and resize it if needed.- Parameters:
newSize- the required size
-
-