com.cometway.text
Class TextRange

java.lang.Object
  extended by com.cometway.text.TextRange

public class TextRange
extends java.lang.Object

A representation of a range of text in an ITextBuffer.


Constructor Summary
TextRange()
          Creates an empty TextRange.
TextRange(ITextBuffer b)
          Creates a TextRange with the given ITextBuffer.
TextRange(ITextBuffer b, int fromIndex, int toIndex)
          Creates a TextRange with the given ITextBuffer and the start and end positions of the range.
TextRange(TextPointer from, TextPointer to)
          Creates a TextRange with the given two TextPointers.
 
Method Summary
 void delete()
          Deletes the range of text in the ITextBuffer associated with this TextRange.
 void dispose()
          Disposes this TextRange.
 boolean equals(java.lang.Object obj)
          overrides Object.equals()
protected  void finalize()
           
 int getEnd()
           
 TextPointer getEndPointer()
           
 int getLength()
           
 int getStart()
           
 TextPointer getStartPointer()
           
 java.lang.String getText()
           
 ITextBuffer getTextBuffer()
           
 void offset(int relativeStart, int relativeEnd)
          Offsets the current range by offsetting the TextPointers pointing to the beginning and end of the range.
 void setEnd(int end)
          Sets the end position of this TextRange.
 void setEndPointer(TextPointer p)
          Sets the end position of this TextRange.
 void setLength(int size)
          Sets the length of this TextRange with respect to the beginning position of the range.
 void setStart(int start)
          Sets the start position of this TextRange.
 void setStartPointer(TextPointer p)
          Sets the start position of this TextRange.
 void setText(java.lang.String s)
          Replaces the range of text in the ITextBuffer associated with this TextRange with the given String parameter.
 void setTextBuffer(ITextBuffer b)
          Sets the ITextBuffer which is associated with this TextRange.
 java.lang.String toString()
          overrides Object.toString().
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextRange

public TextRange()
Creates an empty TextRange.


TextRange

public TextRange(ITextBuffer b)
Creates a TextRange with the given ITextBuffer.


TextRange

public TextRange(ITextBuffer b,
                 int fromIndex,
                 int toIndex)
Creates a TextRange with the given ITextBuffer and the start and end positions of the range.


TextRange

public TextRange(TextPointer from,
                 TextPointer to)
Creates a TextRange with the given two TextPointers.

Method Detail

delete

public void delete()
Deletes the range of text in the ITextBuffer associated with this TextRange.


dispose

public void dispose()
Disposes this TextRange. This must be called in order for this object to get garbage collected.


equals

public boolean equals(java.lang.Object obj)
overrides Object.equals()

Overrides:
equals in class java.lang.Object

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getEnd

public int getEnd()
Returns:
Returns the position at the end of this TextRange.

getEndPointer

public TextPointer getEndPointer()
Returns:
Returns the TextPointer pointing to the position at the end of this TextRange.

getLength

public int getLength()
Returns:
Returns the length of this TextRange.

getStart

public int getStart()
Returns:
Returns the position at the beginning of this TextRange.

getStartPointer

public TextPointer getStartPointer()
Returns:
Returns the TextPointer pointing to the position at the beginning of this TextRange.

getText

public java.lang.String getText()
Returns:
Returns the range of text in the ITextBuffer associated with this TextRange.

getTextBuffer

public ITextBuffer getTextBuffer()
Returns:
Returns the ITextBuffer associated with this TextRange.

offset

public void offset(int relativeStart,
                   int relativeEnd)
Offsets the current range by offsetting the TextPointers pointing to the beginning and end of the range.


setEnd

public void setEnd(int end)
Sets the end position of this TextRange.


setEndPointer

public void setEndPointer(TextPointer p)
Sets the end position of this TextRange.


setLength

public void setLength(int size)
Sets the length of this TextRange with respect to the beginning position of the range.


setStart

public void setStart(int start)
Sets the start position of this TextRange.


setStartPointer

public void setStartPointer(TextPointer p)
Sets the start position of this TextRange.


setText

public void setText(java.lang.String s)
Replaces the range of text in the ITextBuffer associated with this TextRange with the given String parameter.


setTextBuffer

public void setTextBuffer(ITextBuffer b)
Sets the ITextBuffer which is associated with this TextRange.


toString

public java.lang.String toString()
overrides Object.toString().

Overrides:
toString in class java.lang.Object