com.cometway.text
Interface ITextBuffer

All Known Implementing Classes:
StringTextBuffer

public interface ITextBuffer

This interface defines an interface for reading and manipulating a buffer of text.


Method Summary
 void addTextBufferListener(ITextBufferListener l)
          Adds an ITextBufferListener to this object to receive notifications of changes which take place when the text buffer is changed.
 void append(java.lang.String str)
          Appends the specified string to the end of this object and calls the textChanged method of its listeners with the range of the appended text.
 void delete(int fromIndex, int toIndex)
          Removes the specified range of text from this object and calls the textChanged method of its listeners with the location of the removed text.
 TextRange findText(int fromIndex, ITextFinder textFinder)
          Returns the next text range in the text buffer found by the specified text finder starting at the specified index.
 int getLength()
          Returns the size of the text buffer managed by this object.
 java.lang.String getText()
          Returns a string representing the contents of the text buffer.
 java.lang.String getText(int fromIndex, int toIndex)
          Returns a string representing the contents of the text buffer contained within the specified range.
 int indexOf(char ch, int fromIndex)
          Returns the index of the first occurence of the specified character starting at the specified location and continuing to the end of the buffer.
 void insertText(java.lang.String str, int atIndex)
          Inserts a string into the text buffer at the specified location and calls the textChanged method of its listeners with the location of the inserted text.
 int prevIndexOf(char ch, int fromIndex)
          Returns the index of the previous occurence of the specified character starting at the specified location and continuing to the end of the buffer.
 void removeTextBufferListener(ITextBufferListener l)
          Removes an ITextBufferListener from this object.
 void setText(java.lang.String str)
          Sets the value of this text buffer to the specified String.
 

Method Detail

addTextBufferListener

void addTextBufferListener(ITextBufferListener l)
Adds an ITextBufferListener to this object to receive notifications of changes which take place when the text buffer is changed.

Parameters:
l - a reference to an object which implements ITextBufferListener.

append

void append(java.lang.String str)
Appends the specified string to the end of this object and calls the textChanged method of its listeners with the range of the appended text.

Parameters:
str - a reference to a String.

delete

void delete(int fromIndex,
            int toIndex)
Removes the specified range of text from this object and calls the textChanged method of its listeners with the location of the removed text. The fromIndex and toIndex parameters may be specified in any order.

Parameters:
fromIndex - the starting index from where text will be removed.
toIndex - the ending index to where text will be removed.

findText

TextRange findText(int fromIndex,
                   ITextFinder textFinder)
Returns the next text range in the text buffer found by the specified text finder starting at the specified index.

Parameters:
fromIndex - the starting index from where search will begin.
textFinder - a reference to an object implementing ITextFinder.
Returns:
a reference to a TextRange if a matching range was found; null otherwise.

getLength

int getLength()
Returns the size of the text buffer managed by this object.

Returns:
the length of the text buffer.

getText

java.lang.String getText()
Returns a string representing the contents of the text buffer.

Returns:
a reference to a String.

getText

java.lang.String getText(int fromIndex,
                         int toIndex)
Returns a string representing the contents of the text buffer contained within the specified range. The fromIndex and toIndex parameters may be specified in any order.

Parameters:
fromIndex - the starting index from where text will be taken.
toIndex - the ending index to where text will be taken.
Returns:
a reference to a String.

indexOf

int indexOf(char ch,
            int fromIndex)
Returns the index of the first occurence of the specified character starting at the specified location and continuing to the end of the buffer.

Parameters:
ch - the character to match.
fromIndex - the starting index from where the search will begin.
Returns:
the index of the next matching character, or -1 if no match was found.

insertText

void insertText(java.lang.String str,
                int atIndex)
Inserts a string into the text buffer at the specified location and calls the textChanged method of its listeners with the location of the inserted text.

Parameters:
str - a reference to a String.
atIndex - the index of the location where the text should be inserted.

prevIndexOf

int prevIndexOf(char ch,
                int fromIndex)
Returns the index of the previous occurence of the specified character starting at the specified location and continuing to the end of the buffer.

Parameters:
ch - the character to match.
fromIndex - the starting index from where the search will begin.
Returns:
the index of the next matching character, or -1 if no match was found.

removeTextBufferListener

void removeTextBufferListener(ITextBufferListener l)
Removes an ITextBufferListener from this object.

Parameters:
l - a reference to an object which implements ITextBufferListener.

setText

void setText(java.lang.String str)
Sets the value of this text buffer to the specified String.

Parameters:
str - a reference to a String.