edu.rice.cs.util.text
Interface EditDocumentInterface

All Known Subinterfaces:
ConsoleDocumentInterface
All Known Implementing Classes:
AbstractDJDocument, ConsoleDocument, DefinitionsDocument, InteractionsDJDocument, InteractionsDocument, SwingDocument, SWTDocumentAdapter

public interface EditDocumentInterface

A GUI toolkit agnostic interface for a console document. The anticipated implementations are wrappers around documents generated by Swing, SWT (Eclipse), or other toolkits. This interface also provides a mechanism for restricting edits based on a conditional object, unless a separate method is called to force the edit.

Version:
$Id: EditDocumentInterface.java 4587 2008-07-17 15:43:57Z rcartwright $

Method Summary
 void append(String str, String style)
          Appends a string to this in the given named style, if the edit condition allows it.
 void forceInsertText(int offs, String str, String style)
          Inserts a string into the document at the given offset and style, regardless of the edit condition.
 void forceRemoveText(int offs, int len)
          Removes a portion of the document, regardless of the edit condition.
 String getDefaultStyle()
          Gets the String identifying the default style for this document if one exists; null otherwise.
 String getDocText(int offs, int len)
          Returns a portion of the document.
 DocumentEditCondition getEditCondition()
          Gets the object which can determine whether an insert or remove edit should be applied, based on the inputs.
 int getLength()
          Returns the length of the document.
 Pageable getPageable()
          Returns the Pageable object for printing.
 void insertText(int offs, String str, String style)
          Inserts a string into the document at the given offset and the given named style, if the edit condition allows it.
 void print()
          Prints the given console document
 void removeText(int offs, int len)
          Removes a portion of the document, if the edit condition allows it.
 void setEditCondition(DocumentEditCondition condition)
          Provides an object which can determine whether an insert or remove edit should be applied, based on the inputs.
 

Method Detail

getEditCondition

DocumentEditCondition getEditCondition()
Gets the object which can determine whether an insert or remove edit should be applied, based on the inputs.

Returns:
an Object to determine legality of inputs

setEditCondition

void setEditCondition(DocumentEditCondition condition)
Provides an object which can determine whether an insert or remove edit should be applied, based on the inputs.

Parameters:
condition - Object to determine legality of inputs

insertText

void insertText(int offs,
                String str,
                String style)
Inserts a string into the document at the given offset and the given named style, if the edit condition allows it.

Parameters:
offs - Offset into the document
str - String to be inserted
style - Name of the style to use. Must have been added using addStyle.
Throws:
EditDocumentException - if the offset is illegal

forceInsertText

void forceInsertText(int offs,
                     String str,
                     String style)
Inserts a string into the document at the given offset and style, regardless of the edit condition.

Parameters:
offs - Offset into the document
str - String to be inserted
style - Name of the style to use. Must have been added using addStyle.
Throws:
EditDocumentException - if the offset is illegal

removeText

void removeText(int offs,
                int len)
Removes a portion of the document, if the edit condition allows it.

Parameters:
offs - Offset to start deleting from
len - Number of characters to remove
Throws:
EditDocumentException - if the offset or length are illegal

forceRemoveText

void forceRemoveText(int offs,
                     int len)
Removes a portion of the document, regardless of the edit condition.

Parameters:
offs - Offset to start deleting from
len - Number of characters to remove
Throws:
EditDocumentException - if the offset or length are illegal

getLength

int getLength()
Returns the length of the document.


getDocText

String getDocText(int offs,
                  int len)
Returns a portion of the document. Differs from getText in AbstractDocumentInterface by throwing EditDocumentException instead of BadLocationException. (Why bother? It avoids referencing a Swing class.)

Parameters:
offs - First offset of the desired text
len - Number of characters to return
Throws:
EditDocumentException - if the offset or length are illegal

append

void append(String str,
            String style)
Appends a string to this in the given named style, if the edit condition allows it.

Parameters:
str - String to be inserted
style - Name of the style to use. Must have been added using addStyle.
Throws:
EditDocumentException - if the offset is illegal

getDefaultStyle

String getDefaultStyle()
Gets the String identifying the default style for this document if one exists; null otherwise.


getPageable

Pageable getPageable()
                     throws IllegalStateException
Returns the Pageable object for printing.

Returns:
A Pageable representing this document.
Throws:
IllegalStateException

print

void print()
           throws PrinterException
Prints the given console document

Throws:
PrinterException