/* * Created on Mar 31, 2005 */ package WordPro2Document; 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 * @param spellChecker a non-null spellChecker * @param docviewer 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 MyDocumentClass(ISpellChecker spellChecker, * DocumentViewer docviewer); */ 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; * if null, the old document is still replaced (by null). * @return true iff the open operation was completed successfully; * return null only if the input is null. */ public boolean open(String aDocument); /** Opens a document, by prompting the user to choose a file. * (HINT: use a method from FileUtilities373). * The requested document replaces any other * currently open document. In case the open fails, the old current * document is nevertheless replaced (by null). * * @return true iff the open operation was completed successfully. */ public boolean open(); /** 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(); /** Get the text of the document, in a form which the document deems * suitable for display. It may or may not be the same as the original * stored text. * @return the document text, as this class wishes it to be seen; or * null if there is no current document. */ public String getText(); }