javax.swing.text
Interface AbstractDocument.Content

All Known Implementing Classes:
GapContent sample code for javax.swing.text.GapContent definition code for javax.swing.text.GapContent , StringContent sample code for javax.swing.text.StringContent definition code for javax.swing.text.StringContent
Enclosing class:
AbstractDocument sample code for javax.swing.text.AbstractDocument definition code for javax.swing.text.AbstractDocument

public static interface AbstractDocument.Content

Interface to describe a sequence of character content that can be edited. Implementations may or may not support a history mechanism which will be reflected by whether or not mutations return an UndoableEdit implementation.

See Also:
AbstractDocument sample code for javax.swing.text.AbstractDocument definition code for javax.swing.text.AbstractDocument

Method Summary
 Position sample code for javax.swing.text.Position definition code for javax.swing.text.Position createPosition sample code for javax.swing.text.AbstractDocument.Content.createPosition(int) definition code for javax.swing.text.AbstractDocument.Content.createPosition(int) (int offset)
          Creates a position within the content that will track change as the content is mutated.
 void getChars sample code for javax.swing.text.AbstractDocument.Content.getChars(int, int, javax.swing.text.Segment) definition code for javax.swing.text.AbstractDocument.Content.getChars(int, int, javax.swing.text.Segment) (int where, int len, Segment sample code for javax.swing.text.Segment definition code for javax.swing.text.Segment  txt)
          Gets a sequence of characters and copies them into a Segment.
 String sample code for java.lang.String definition code for java.lang.String getString sample code for javax.swing.text.AbstractDocument.Content.getString(int, int) definition code for javax.swing.text.AbstractDocument.Content.getString(int, int) (int where, int len)
          Fetches a string of characters contained in the sequence.
 UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit insertString sample code for javax.swing.text.AbstractDocument.Content.insertString(int, java.lang.String) definition code for javax.swing.text.AbstractDocument.Content.insertString(int, java.lang.String) (int where, String sample code for java.lang.String definition code for java.lang.String  str)
          Inserts a string of characters into the sequence.
 int length sample code for javax.swing.text.AbstractDocument.Content.length() definition code for javax.swing.text.AbstractDocument.Content.length() ()
          Current length of the sequence of character content.
 UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit remove sample code for javax.swing.text.AbstractDocument.Content.remove(int, int) definition code for javax.swing.text.AbstractDocument.Content.remove(int, int) (int where, int nitems)
          Removes some portion of the sequence.
 

Method Detail

createPosition sample code for javax.swing.text.AbstractDocument.Content.createPosition(int) definition code for javax.swing.text.AbstractDocument.Content.createPosition(int)

Position sample code for javax.swing.text.Position definition code for javax.swing.text.Position  createPosition(int offset)
                        throws BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException 
Creates a position within the content that will track change as the content is mutated.

Parameters:
offset - the offset in the content >= 0
Returns:
a Position
Throws:
BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException - for an invalid offset

length sample code for javax.swing.text.AbstractDocument.Content.length() definition code for javax.swing.text.AbstractDocument.Content.length()

int length()
Current length of the sequence of character content.

Returns:
the length >= 0

insertString sample code for javax.swing.text.AbstractDocument.Content.insertString(int, java.lang.String) definition code for javax.swing.text.AbstractDocument.Content.insertString(int, java.lang.String)

UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit  insertString(int where,
                          String sample code for java.lang.String definition code for java.lang.String  str)
                          throws BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException 
Inserts a string of characters into the sequence.

Parameters:
where - offset into the sequence to make the insertion >= 0
str - string to insert
Returns:
if the implementation supports a history mechanism, a reference to an Edit implementation will be returned, otherwise returns null
Throws:
BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException - thrown if the area covered by the arguments is not contained in the character sequence

remove sample code for javax.swing.text.AbstractDocument.Content.remove(int, int) definition code for javax.swing.text.AbstractDocument.Content.remove(int, int)

UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit  remove(int where,
                    int nitems)
                    throws BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException 
Removes some portion of the sequence.

Parameters:
where - The offset into the sequence to make the insertion >= 0.
nitems - The number of items in the sequence to remove >= 0.
Returns:
If the implementation supports a history mechansim, a reference to an Edit implementation will be returned, otherwise null.
Throws:
BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException - Thrown if the area covered by the arguments is not contained in the character sequence.

getString sample code for javax.swing.text.AbstractDocument.Content.getString(int, int) definition code for javax.swing.text.AbstractDocument.Content.getString(int, int)

String sample code for java.lang.String definition code for java.lang.String  getString(int where,
                 int len)
                 throws BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException 
Fetches a string of characters contained in the sequence.

Parameters:
where - Offset into the sequence to fetch >= 0.
len - number of characters to copy >= 0.
Returns:
the string
Throws:
BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException - Thrown if the area covered by the arguments is not contained in the character sequence.

getChars sample code for javax.swing.text.AbstractDocument.Content.getChars(int, int, javax.swing.text.Segment) definition code for javax.swing.text.AbstractDocument.Content.getChars(int, int, javax.swing.text.Segment)

void getChars(int where,
              int len,
              Segment sample code for javax.swing.text.Segment definition code for javax.swing.text.Segment  txt)
              throws BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException 
Gets a sequence of characters and copies them into a Segment.

Parameters:
where - the starting offset >= 0
len - the number of characters >= 0
txt - the target location to copy into
Throws:
BadLocationException sample code for javax.swing.text.BadLocationException definition code for javax.swing.text.BadLocationException - Thrown if the area covered by the arguments is not contained in the character sequence.