Package org.passay.dictionary
Class WordListDictionary
- java.lang.Object
-
- org.passay.dictionary.WordListDictionary
-
- All Implemented Interfaces:
Dictionary
public class WordListDictionary extends Object implements Dictionary
Provides fast searching for dictionary words using a word list. It's critical that the word list provided to this dictionary be sorted according to the natural ordering ofString
.- Author:
- Middleware Services
-
-
Constructor Summary
Constructors Constructor Description WordListDictionary(WordList wl)
Creates a new dictionary instance from the suppliedWordList
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description WordList
getWordList()
Returns the word list used for searching.static void
main(String[] args)
Provides command line access to this word list dictionary.boolean
search(String word)
Returns whether the supplied word exists in the dictionary.long
size()
Returns the number of words in this dictionaryString
toString()
-
-
-
Field Detail
-
wordList
protected final WordList wordList
list used for searching.
-
-
Constructor Detail
-
WordListDictionary
public WordListDictionary(WordList wl)
Creates a new dictionary instance from the suppliedWordList
.- Parameters:
wl
- list of words sorted according toWordList.getComparator()
.NOTE Failure to provide a sorted word list will produce incorrect results.
-
-
Method Detail
-
getWordList
public WordList getWordList()
Returns the word list used for searching.- Returns:
- word list
-
size
public long size()
Description copied from interface:Dictionary
Returns the number of words in this dictionary- Specified by:
size
in interfaceDictionary
- Returns:
- total number of words to search
-
search
public boolean search(String word)
Description copied from interface:Dictionary
Returns whether the supplied word exists in the dictionary.- Specified by:
search
in interfaceDictionary
- Parameters:
word
- to search for- Returns:
- whether word was found
-
-