Overview | Package | Class | Tree | Deprecated | Index | Help |
Java Platform 1.1.7 |
||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.java.swing.text.GapContent
The positions tracking change are also generally cheap to maintain. The Position implementations (marks) store the array index and can easily calculate the sequential position from the current gap location. Changes only require update to the the marks between the old and new gap boundries when the gap is moved, so generally updating the marks is pretty cheap. The marks are stored sorted so they can be located quickly with a binary search. This increases the cost of adding a mark, and decreases the cost of keeping the mark updated.
Constructor Summary | |
GapContent()
Creates a new GapContent object. |
|
GapContent(int initialLength)
Creates a new GapContent object, with the initial size specified. |
Method Summary | |
Position | createPosition(int offset)
Creates a position within the content that will track change as the content is mutated. |
void | getChars(int where,
int len,
Segment chars)
Retrieves a portion of the content. |
java.lang.String | getString(int where,
int len)
Retrieves a portion of the content. |
UndoableEdit | insertString(int where,
java.lang.String str)
Inserts a string into the content. |
int | length()
Returns the length of the content. |
UndoableEdit | remove(int where,
int nitems)
Removes part of the content. |
Methods inherited from class java.lang.Object | |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
Constructor Detail |
public GapContent()
public GapContent(int initialLength)
initialLength
- the initial sizeMethod Detail |
public int length()
public UndoableEdit insertString(int where, java.lang.String str) throws BadLocationException
where
- the starting position >= 0, < length()
str
- the non-null string to insertpublic UndoableEdit remove(int where, int nitems) throws BadLocationException
where
- the starting position >= 0, where + nitems < length()
nitems
- the number of characters to remove >= 0public java.lang.String getString(int where, int len) throws BadLocationException
where
- the starting position >= 0
len
- the length to retrieve >= 0public void getChars(int where, int len, Segment chars) throws BadLocationException
where
- the starting position >= 0, where + len <= length()
len
- the number of characters to retrieve >= 0
chars
- the Segment object to return the characters inpublic Position createPosition(int offset) throws BadLocationException
offset
- the offset to track >= 0Overview | Package | Class | Tree | Deprecated | Index | Help |
Java Platform 1.1.7 |
||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |