|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--bill.apps.wordutil.WordList
This class holds the list of words to search for. In order to speed up searches it also maintains a list of all the possible 2-x character combinations which can be used to start a word. When creating words, this list can be checked to see whether we should continue along this path.
Constructor Summary | |
WordList(String fileName)
Creator. |
|
WordList(String fileName,
int charNum)
Creator. |
Method Summary | |
boolean |
addWord(String word)
Adds a word to the word list. |
boolean |
containsChar(String word)
Checks if the first x characters are used in any words I know. |
boolean |
containsWord(String word)
Checks is a word is contained in the word list. |
void |
dumpWords()
Dumps all the words in the word set to standard out as plain text. |
void |
dumpWords(PrintStream stream)
Dumps all the words in the word set to the specified stream as plain text. |
void |
dumpWords(String fileName)
Dumps all the words in the word set to the specified file name as plain text. |
String |
getFileName()
Getter for the name of the file associated with this word set. |
int |
getNumberOfWords()
Determines the number of words that are contained in the word list. |
void |
initialize()
Initializes the class instance by validating the input file and reading its contents. |
boolean |
removeWord(String word)
Removes a word from the word list. |
void |
saveWords()
Saves the word list to a file. |
void |
setFileName(String newName)
Setter for the name of the file associated with this word set. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WordList(String fileName) throws FileNotFoundException, IOException, WordGamesException
fileName
- Name of the file words are stored in.FileNotFoundException
- Indicates the file name passed in does
not exist or cannot be accessed.IOException
- File was found but an error occurred while reading it.WordGamesException
- Thrown when the specified file name is not
null
and cannot be successfully read. Typically caused by
a corrupt file.public WordList(String fileName, int charNum) throws FileNotFoundException, IOException, WordGamesException
fileName
- Name of the file words are stored in.charNum
- Number of starting character lists to create.FileNotFoundException
- Indicates the file name passed in does
not exist or cannot be accessed.IOException
- File was found but an error occurred while reading it.WordGamesException
- Thrown when the specified file name is not
null
and cannot be successfully read.Method Detail |
public String getFileName()
public void setFileName(String newName)
newName
- The new associated file name.public int getNumberOfWords()
public void saveWords() throws WordGamesException
public boolean addWord(String word)
word
- Word to be added.true
if the word is added, false
otherwise.public boolean removeWord(String word)
word
- Word to be removed.true
if the word is removed, false
otherwise.public boolean containsWord(String word)
word
- Word to be look for.true
if the word is found in the word list,
false
otherwise.public boolean containsChar(String word)
word
- Characters of word to be look for.true
if the characters are found in the
x character list, false
otherwise.public void initialize() throws FileNotFoundException, IOException, WordGamesException
FileNotFoundException
- Indicates the file name passed in does
not exist or cannot be accessed.IOException
- File was found but an error occurred while reading it.WordGamesException
- A processing error was encountered while
reading the word list file, typically caused by a corrupt file.public void dumpWords()
public void dumpWords(String fileName) throws FileNotFoundException
fileName
- The name of the file to write the word set to.FileNotFoundException
- Thrown if the file exists but is a directory
rather than a regular file, does not exist but cannot be created, or
cannot be opened for any other reasonpublic void dumpWords(PrintStream stream)
stream
- The stream to write the word set to.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |