Method from javax.swing.text.Segment Detail: |
public char charAt(int index) {
if (index < 0
|| index >= count) {
throw new StringIndexOutOfBoundsException(index);
}
return array[offset + index];
}
|
public Object clone() {
Object o;
try {
o = super.clone();
} catch (CloneNotSupportedException cnse) {
o = null;
}
return o;
}
|
public char current() {
if (count != 0 && pos < offset + count) {
return array[pos];
}
return DONE;
}
Gets the character at the current position (as returned by getIndex()). |
public char first() {
pos = offset;
if (count != 0) {
return array[pos];
}
return DONE;
}
Sets the position to getBeginIndex() and returns the character at that
position. |
public int getBeginIndex() {
return offset;
}
Returns the start index of the text. |
public int getEndIndex() {
return offset + count;
}
Returns the end index of the text. This index is the index of the first
character following the end of the text. |
public int getIndex() {
return pos;
}
Returns the current index. |
public boolean isPartialReturn() {
return partialReturn;
}
Flag to indicate that partial returns are valid. |
public char last() {
pos = offset + count;
if (count != 0) {
pos -= 1;
return array[pos];
}
return DONE;
}
Sets the position to getEndIndex()-1 (getEndIndex() if the text is empty)
and returns the character at that position. |
public int length() {
return count;
}
|
public char next() {
pos += 1;
int end = offset + count;
if (pos >= end) {
pos = end;
return DONE;
}
return current();
}
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. |
public char previous() {
if (pos == offset) {
return DONE;
}
pos -= 1;
return current();
}
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. |
public char setIndex(int position) {
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;
}
Sets the position to the specified position in the text and returns that
character. |
public void setPartialReturn(boolean p) {
partialReturn = 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. |
public CharSequence subSequence(int start,
int end) {
if (start < 0) {
throw new StringIndexOutOfBoundsException(start);
}
if (end > count) {
throw new StringIndexOutOfBoundsException(end);
}
if (start > end) {
throw new StringIndexOutOfBoundsException(end - start);
}
Segment segment = new Segment();
segment.array = this.array;
segment.offset = this.offset + start;
segment.count = end - start;
return segment;
}
|
public String toString() {
if (array != null) {
return new String(array, offset, count);
}
return "";
}
Converts a segment into a String. |