Package org.passay.dictionary
Class WordListDictionary
java.lang.Object
org.passay.dictionary.WordListDictionary
- All Implemented Interfaces:
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 of
String.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the word list used for searching.static voidProvides command line access to this word list dictionary.booleansearch(CharSequence word) Returns whether the supplied word exists in the dictionary.longsize()Returns the number of words in this dictionarytoString()
-
Field Details
-
wordList
list used for searching.
-
-
Constructor Details
-
WordListDictionary
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 Details
-
getWordList
Returns the word list used for searching.- Returns:
- word list
-
size
public long size()Description copied from interface:DictionaryReturns the number of words in this dictionary- Specified by:
sizein interfaceDictionary- Returns:
- total number of words to search
-
search
Description copied from interface:DictionaryReturns whether the supplied word exists in the dictionary.- Specified by:
searchin interfaceDictionary- Parameters:
word- to search for- Returns:
- whether word was found
-
toString
-
main
Provides command line access to this word list dictionary.- Parameters:
args- command line arguments- Throws:
Exception- if an error occurs
-