javax.swing.text
Interface AbstractDocument.Content

All Known Implementing Classes:
GapContent, StringContent
Enclosing class:
AbstractDocument

public static interface AbstractDocument.Content

A sequence of data that can be edited. This is were the actual content in AbstractDocument's is stored.


Method Summary
 Position createPosition(int offset)
          Creates a Position that keeps track of the location at offset.
 void getChars(int where, int len, Segment txt)
          Fetches a piece of content and stores it in txt.
 String getString(int where, int len)
          Returns a piece of content.
 UndoableEdit insertString(int where, String str)
          Inserts a string into the content model.
 int length()
          Returns the length of the content.
 UndoableEdit remove(int where, int nitems)
          Removes a piece of content from the content model.
 

Method Detail

createPosition

Position createPosition(int offset)
                        throws BadLocationException
Creates a Position that keeps track of the location at offset.

Returns:
a Position that keeps track of the location at offset.
Throws:
BadLocationException

length

int length()
Returns the length of the content.

Returns:
the length of the content

insertString

UndoableEdit insertString(int where,
                          String str)
                          throws BadLocationException
Inserts a string into the content model.

Parameters:
where - the offset at which to insert the string
str - the string to be inserted
Returns:
an UndoableEdit or null if undo is not supported by this Content model
Throws:
BadLocationException - if where is not a valid location in this Content model

remove

UndoableEdit remove(int where,
                    int nitems)
                    throws BadLocationException
Removes a piece of content from the content model.

Parameters:
where - the offset at which to remove content
nitems - the number of characters to be removed
Returns:
an UndoableEdit or null if undo is not supported by this Content model
Throws:
BadLocationException - if where is not a valid location in this Content model

getString

String getString(int where,
                 int len)
                 throws BadLocationException
Returns a piece of content.

Parameters:
where - the start offset of the requested fragment
len - the length of the requested fragment
Returns:
the requested fragment
Throws:
BadLocationException - if offset or offset + lenis not a valid location in this Content model

getChars

void getChars(int where,
              int len,
              Segment txt)
              throws BadLocationException
Fetches a piece of content and stores it in txt.

Parameters:
where - the start offset of the requested fragment
len - the length of the requested fragment
txt - the Segment where to fragment is stored into
Throws:
BadLocationException - if offset or offset + lenis not a valid location in this Content model