edu.vt.middleware.dictionary
Class WordListDictionary

java.lang.Object
  extended by edu.vt.middleware.dictionary.WordListDictionary
All Implemented Interfaces:
Dictionary

public class WordListDictionary
extends java.lang.Object
implements Dictionary

WordListDictionary provides fast searching for dictionary words using a WordList. It's critical that the word list provided to this dictionary be sorted according to the natural ordering of String.

Version:
$Revision: 1252 $ $Date: 2010-04-16 17:24:23 -0400 (Fri, 16 Apr 2010) $
Author:
Middleware Services

Field Summary
protected  WordList wordList
          list used for searching.
 
Constructor Summary
WordListDictionary(WordList wl)
          Creates a new dictionary instance from the given WordList.
 
Method Summary
 WordList getWordList()
          Returns the word list to used for searching.
static void main(java.lang.String[] args)
          This provides command line access to this WordListDictionary.
 boolean search(java.lang.String word)
          Returns whether the supplied word exists in the dictionary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wordList

protected WordList wordList
list used for searching.

Constructor Detail

WordListDictionary

public WordListDictionary(WordList wl)
Creates a new dictionary instance from the given WordList.

Parameters:
wl - List of words sorted according to WordList.getComparator().

NOTE Failure to provide a sorted word list will produce incorrect results.

Method Detail

getWordList

public WordList getWordList()
Returns the word list to used for searching.

Returns:
WordList

search

public boolean search(java.lang.String word)
Returns whether the supplied word exists in the dictionary.

Specified by:
search in interface Dictionary
Parameters:
word - String to search for
Returns:
boolean - whether word was found

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
This provides command line access to this WordListDictionary.

Parameters:
args - String[]
Throws:
java.lang.Exception - if an error occurs


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