edu.vt.middleware.dictionary
Class WordLists

java.lang.Object
  extended by edu.vt.middleware.dictionary.WordLists

public final class WordLists
extends java.lang.Object

Utility class for common operations on word lists.

Version:
$Revision: 1509 $
Author:
Middleware Services

Field Summary
static java.util.Comparator<java.lang.String> CASE_INSENSITIVE_COMPARATOR
          Case insensitive comparator.
static java.util.Comparator<java.lang.String> CASE_SENSITIVE_COMPARATOR
          Case sensitive comparator.
static int NOT_FOUND
          Index returned when word not found by binary search.
 
Method Summary
static int binarySearch(WordList wordList, java.lang.String word)
          Performs a binary search of the given word list for the given word.
static ArrayWordList createFromReader(java.io.Reader[] readers)
          Creates a case-sensitive ArrayWordList by reading the contents of the given readers.
static ArrayWordList createFromReader(java.io.Reader[] readers, boolean caseSensitive)
          Creates an ArrayWordList by reading the contents of the given readers.
static ArrayWordList createFromReader(java.io.Reader[] readers, boolean caseSensitive, ArraySorter sorter)
          Creates an ArrayWordList by reading the contents of the given file with support for sorting file contents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CASE_SENSITIVE_COMPARATOR

public static final java.util.Comparator<java.lang.String> CASE_SENSITIVE_COMPARATOR
Case sensitive comparator.


CASE_INSENSITIVE_COMPARATOR

public static final java.util.Comparator<java.lang.String> CASE_INSENSITIVE_COMPARATOR
Case insensitive comparator.


NOT_FOUND

public static final int NOT_FOUND
Index returned when word not found by binary search.

See Also:
Constant Field Values
Method Detail

binarySearch

public static int binarySearch(WordList wordList,
                               java.lang.String word)
Performs a binary search of the given word list for the given word.

Parameters:
wordList - Word list to search
word - Word to search for.
Returns:
Index of given word in list or a negative number if not found.

createFromReader

public static ArrayWordList createFromReader(java.io.Reader[] readers)
                                      throws java.io.IOException
Creates a case-sensitive ArrayWordList by reading the contents of the given readers.

Parameters:
readers - Array of readers.
Returns:
Word list read from the given readers.
Throws:
java.io.IOException - if an error occurs reading from a reader

createFromReader

public static ArrayWordList createFromReader(java.io.Reader[] readers,
                                             boolean caseSensitive)
                                      throws java.io.IOException
Creates an ArrayWordList by reading the contents of the given readers.

Parameters:
readers - Array of readers.
caseSensitive - Set to true to create case-sensitive word list (default), false otherwise.
Returns:
Word list read from the given readers.
Throws:
java.io.IOException - if an error occurs reading from a reader

createFromReader

public static ArrayWordList createFromReader(java.io.Reader[] readers,
                                             boolean caseSensitive,
                                             ArraySorter sorter)
                                      throws java.io.IOException
Creates an ArrayWordList by reading the contents of the given file with support for sorting file contents.

Parameters:
readers - Array of readers.
caseSensitive - Set to true to create case-sensitive word list (default), false otherwise.
sorter - To sort the input array with
Returns:
Word list read from given readers.
Throws:
java.io.IOException - if an error occurs reading from a reader


Copyright © 2003-2010 Virginia Tech. All Rights Reserved.