/* * Created on Mar 31, 2005 */ package SimpleSpeller; import java.util.List; /** Class which encapsulates a complete document which a user is * preparing. Concrete implementations of this interface must have * one constructor as follows: * public MyDocumentClass(ISpellChecker spellChecker); */ public interface IDocument { /** Opens a document. The requested document replaces any other * currently open document. * * @param aDocument a string containing the entire document being opened. * @return true iff the open operation was completed successfully. */ public boolean open(String aDocument); /** Get a list of all misspelled words in the document. * A "word" for this purpose is defined to be a sequence of word characters * bounded by non-word characters, or by the beginning or end of the * document. "Word characters" are letters (upper and lower), digits * 0-9, and and the underscore _. * For example in the following string: "Eye kan spel 4mula 4 u." * The words are "Eye", "kan", "spel", "4mula", "4", "u". * * @return a list of words (in their original forms) which were * rejected by the spell checker. The list may be empty but not null. * The words in the list should appear the same number of times * and in the same order as they appear * in the original document. */ public List checkSpelling(); /** Display the entire document on the system console. * No more than * 60 characters should be printed on one line of output. * Any linefeeds embedded in the text are respected (i.e., they cause * a linefeed to occur). * Lines should only be broken after a space character or linefeed. * (Exception: if there is a sequence of characters longer than 60 * without spaces or linefeeds, it is allowed to be on a line * by itself as long as necessary). * The display should be compact, without unnecessary blank lines * and without lines that are unnecessarily short (for example, it * would not be acceptable to display one word per line!) */ public void print(); }