javax.swing.text

Interface AbstractDocument.Content

public interface AbstractDocument.Content

A sequence of data that can be edited. This is were the actual content in AbstractDocument's is stored.
Method Summary
PositioncreatePosition(int offset)
Creates a {@link Position} that keeps track of the location at offset.
voidgetChars(int where, int len, Segment txt)
Fetches a piece of content and stores it in txt.
StringgetString(int where, int len)
Returns a piece of content.
UndoableEditinsertString(int where, String str)
Inserts a string into the content model.
intlength()
Returns the length of the content.
UndoableEditremove(int where, int nitems)
Removes a piece of content from the content model.

Method Detail

createPosition

public Position createPosition(int offset)
Creates a {@link Position} that keeps track of the location at offset.

Returns: a {@link Position} that keeps track of the location at offset.

UNKNOWN: BadLocationException if offset is not a valid location in this Content model

getChars

public void getChars(int where, int len, Segment txt)
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

getString

public String getString(int where, int len)
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

insertString

public UndoableEdit insertString(int where, String str)
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

length

public int length()
Returns the length of the content.

Returns: the length of the content

remove

public UndoableEdit remove(int where, int nitems)
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