import java.io.IOException; import java.nio.file.Path; /* An instance of an implementing class represents a document, which is ** a sequence of lines of text indexed by line numbers. */ interface Document { // observer // -------- /* Returns the number of lines of text in this document. */ int numLines(); /* Returns the line of text identified by the given line number, ** or null if lineNum is not a valid line number.. */ String getLine(int lineNum); /* Displays the lines of this document in the specified range ** of line numbers. */ void display(int startLine, int endLine); /* Displays all the lines in this document. */ void display(); // mutators // -------- /* Inserts into this document a new line containing the given text. ** That new line's number is the one specified. */ void insertLine(int lineNum, String text); /* Replaces, by the given text, the line of text identified by the ** given line number. */ void replaceLine(int lineNum, String text); /* Deletes the line of text identified by the given line number. */ void deleteLine(int lineNum); // Input/Output // ------------ /* Writes this document into the file whose path/name is given. */ void writeToFile(Path path) throws IOException; }