Methods Summary |
---|
public java.lang.Object | clone()Creates a shallow copy.
Object o;
try {
o = super.clone();
} catch (CloneNotSupportedException cnse) {
o = null;
}
return o;
|
public char | current()Gets the character at the current position (as returned by getIndex()).
if (count != 0 && pos < offset + count) {
return array[pos];
}
return DONE;
|
public char | first()Sets the position to getBeginIndex() and returns the character at that
position.
pos = offset;
if (count != 0) {
return array[pos];
}
return DONE;
|
public int | getBeginIndex()Returns the start index of the text.
return offset;
|
public int | getEndIndex()Returns the end index of the text. This index is the index of the first
character following the end of the text.
return offset + count;
|
public int | getIndex()Returns the current index.
return pos;
|
public boolean | isPartialReturn()Flag to indicate that partial returns are valid.
return partialReturn;
|
public char | last()Sets the position to getEndIndex()-1 (getEndIndex() if the text is empty)
and returns the character at that position.
pos = offset + count;
if (count != 0) {
pos -= 1;
return array[pos];
}
return DONE;
|
public char | next()Increments the iterator's index by one and returns the character
at the new index. If the resulting index is greater or equal
to getEndIndex(), the current index is reset to getEndIndex() and
a value of DONE is returned.
pos += 1;
int end = offset + count;
if (pos >= end) {
pos = end;
return DONE;
}
return current();
|
public char | previous()Decrements the iterator's index by one and returns the character
at the new index. If the current index is getBeginIndex(), the index
remains at getBeginIndex() and a value of DONE is returned.
if (pos == offset) {
return DONE;
}
pos -= 1;
return current();
|
public char | setIndex(int position)Sets the position to the specified position in the text and returns that
character.
int end = offset + count;
if ((position < offset) || (position > end)) {
throw new IllegalArgumentException("bad position: " + position);
}
pos = position;
if ((pos != end) && (count != 0)) {
return array[pos];
}
return DONE;
|
public void | setPartialReturn(boolean p)Flag to indicate that partial returns are valid. If the flag is true,
an implementation of the interface method Document.getText(position,length,Segment)
should return as much text as possible without making a copy. The default
state of the flag is false which will cause Document.getText(position,length,Segment)
to provide the same return behavior it always had, which may or may not
make a copy of the text depending upon the request.
partialReturn = p;
|
public java.lang.String | toString()Converts a segment into a String.
if (array != null) {
return new String(array, offset, count);
}
return new String();
|