/* * Created on Mar 30, 2005 */ package WordPro2Speller; /** Interface for a class which determines whether words are spelled correctly. * * Concrete implementations should have a public constructor as follows: * @param dictionaryWords The strings in the array should be non-null and non-empty after * normalization. The normalized forms of the words are considered * to be all and only the correct-spelled words in existence. * @param spviewer a viewer, which may be null. Methods which * refer to the viewer should do something reasonable (i.e., not * blow up) with the viewer is null. * public MySpellChecker(String[] dictionaryWords, * SpellerViewer spviewer); */ public interface ISpellChecker { /** Opens a spelling dictionary, by prompting the user to choose a file. * In the file, each line is considered to be one correctly spelled word. * For example, if the file contains the lines * elvish * Elvis Presley * eventually * * then there are three correct "words". * (HINT: use a method from FileUtilities373). * The requested dictionary replaces any other * currently open dictionary. * * @return true iff the open operation was completed successfully. */ public boolean open(); /** Convert a string to a normal form, in which any leading and trailing * spaces are stripped out, and any uppercase letters are converted * to lowercase; everything else in the string is unchanged. * @param originalWord any string * @return a normalized string (which may be empty); a null string is * returned if the original string was null. */ String normalize(String originalWord); /** Determine if a word (normalized) matches some (normalized) word * in the dictionary. * @param word a string, which may be empty but not null. * @return true iff the word (normalized) is an exact match * to some word in the dictionary. */ boolean isCorrectlySpelled(String word); }