Package org.passay.dictionary
Class ArrayWordList
- java.lang.Object
-
- org.passay.dictionary.AbstractWordList
-
- org.passay.dictionary.ArrayWordList
-
- All Implemented Interfaces:
WordList
public class ArrayWordList extends AbstractWordList
Provides aWordList
backed by a string array. Since the entire word list is stored in memory java heap settings may need to be modified in order to store large word lists.- Author:
- Middleware Services
-
-
Field Summary
Fields Modifier and Type Field Description protected String[]
words
file containing words.-
Fields inherited from class org.passay.dictionary.AbstractWordList
comparator
-
-
Constructor Summary
Constructors Constructor Description ArrayWordList(String[] array)
Creates a new case-sensitive word list backed by the given array.ArrayWordList(String[] array, boolean caseSensitive)
Creates a new word list backed by the given array.ArrayWordList(String[] array, boolean caseSensitive, ArraySorter sorter)
Creates a new word list backed by the given array with optional sorting of the input string array.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
get(int index)
Returns the word at the given 0-based index.int
size()
Returns the number of words in the list.String
toString()
-
Methods inherited from class org.passay.dictionary.AbstractWordList
checkIsString, checkRange, getComparator, iterator, medianIterator
-
-
-
-
Field Detail
-
words
protected String[] words
file containing words.
-
-
Constructor Detail
-
ArrayWordList
public ArrayWordList(String[] array)
Creates a new case-sensitive word list backed by the given array.- Parameters:
array
- Array of words.- Throws:
IllegalArgumentException
- If array is null or contains any null entries.
-
ArrayWordList
public ArrayWordList(String[] array, boolean caseSensitive)
Creates a new word list backed by the given array.- Parameters:
array
- Array of words.caseSensitive
- Set to true to create case-sensitive word list, false otherwise.- Throws:
IllegalArgumentException
- If array is null or contains any null entries.
-
ArrayWordList
public ArrayWordList(String[] array, boolean caseSensitive, ArraySorter sorter)
Creates a new word list backed by the given array with optional sorting of the input string array.- Parameters:
array
- Array of words.caseSensitive
- Set to true to create case-sensitive word list, false otherwise.sorter
- To sort the input array with. The sort routine is consistent withAbstractWordList.getComparator()
, which respects the case sensitivity of the word list.- Throws:
IllegalArgumentException
- If array is null or contains any null entries.
-
-
Method Detail
-
get
public String get(int index)
Description copied from interface:WordList
Returns the word at the given 0-based index.- Parameters:
index
- 0-based index.- Returns:
- word at given index.
-
size
public int size()
Description copied from interface:WordList
Returns the number of words in the list.- Returns:
- total number of words in list.
-
-