swingwtx.swing.text
Class StringContent

java.lang.Object
  extended byswingwtx.swing.text.StringContent
All Implemented Interfaces:
AbstractDocument.Content
Direct Known Subclasses:
GapContent

public class StringContent
extends java.lang.Object
implements AbstractDocument.Content

This class is used to represent document content with a StringBuffer. Hopefully it should be efficient enough.


Constructor Summary
StringContent()
           
StringContent(int initialSize)
           
 
Method Summary
 Position createPosition(int offset)
          Creates an anonymous class implementing Position for the offset given.
 void getChars(int where, int len, Segment txt)
          Assigns the specified substring to the passed Segment
 java.lang.String getString(int where, int len)
          Retrieves a string from the content
 UndoableEdit insertString(int where, java.lang.String str)
          Inserts a string into the content at the specified position.
 int length()
          Returns the content length
 UndoableEdit remove(int where, int nitems)
          Removes nitems chars from the content at the specified position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringContent

public StringContent()

StringContent

public StringContent(int initialSize)
Method Detail

createPosition

public Position createPosition(int offset)
                        throws BadLocationException
Creates an anonymous class implementing Position for the offset given.

Specified by:
createPosition in interface AbstractDocument.Content
Throws:
BadLocationException

length

public int length()
Returns the content length

Specified by:
length in interface AbstractDocument.Content

insertString

public UndoableEdit insertString(int where,
                                 java.lang.String str)
                          throws BadLocationException
Inserts a string into the content at the specified position.

Specified by:
insertString in interface AbstractDocument.Content
Throws:
BadLocationException - if the position is invalid FIXME: UNDO needs implementing

remove

public UndoableEdit remove(int where,
                           int nitems)
                    throws BadLocationException
Removes nitems chars from the content at the specified position.

Specified by:
remove in interface AbstractDocument.Content
Throws:
BadLocationException - if the position is invalid FIXME: UNDO needs implementing

getString

public java.lang.String getString(int where,
                                  int len)
                           throws BadLocationException
Retrieves a string from the content

Specified by:
getString in interface AbstractDocument.Content
Parameters:
where - The offset
len - The length of the string
Returns:
The substring specified
Throws:
BadLocationException - if the position is invalid

getChars

public void getChars(int where,
                     int len,
                     Segment txt)
              throws BadLocationException
Assigns the specified substring to the passed Segment

Specified by:
getChars in interface AbstractDocument.Content
Parameters:
where - The offset
len - The length
txt - The segment object to put the substring in
Throws:
BadLocationException