Class ArrayWordList

java.lang.Object
org.passay.dictionary.AbstractWordList
org.passay.dictionary.ArrayWordList
All Implemented Interfaces:
WordList

public class ArrayWordList extends AbstractWordList
Provides a WordList 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.
  • Field Details

    • words

      protected final String[] words
      file containing words.
  • Constructor Details

    • 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 with AbstractWordList.getComparator(), which respects the case sensitivity of the word list.
      Throws:
      IllegalArgumentException - If array is null or contains any null entries.
  • Method Details

    • 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.
    • toString

      public String toString()
      Overrides:
      toString in class Object