Method from java.awt.font.CharArrayIterator Detail: |
public Object clone() {
CharArrayIterator c = new CharArrayIterator(chars, begin);
c.pos = this.pos;
return c;
}
Create a copy of this iterator |
public char current() {
if (pos >= 0 && pos < chars.length) {
return chars[pos];
}
else {
return DONE;
}
}
Gets the character at the current position (as returned by getIndex()). |
public char first() {
pos = 0;
return current();
}
Sets the position to getBeginIndex() and returns the character at that
position. |
public int getBeginIndex() {
return begin;
}
Returns the start index of the text. |
public int getEndIndex() {
return begin+chars.length;
}
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 begin+pos;
}
Returns the current index. |
public char last() {
if (chars.length > 0) {
pos = chars.length-1;
}
else {
pos = 0;
}
return current();
}
Sets the position to getEndIndex()-1 (getEndIndex() if the text is empty)
and returns the character at that position. |
public char next() {
if (pos < chars.length-1) {
pos++;
return chars[pos];
}
else {
pos = chars.length;
return DONE;
}
}
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 > 0) {
pos--;
return chars[pos];
}
else {
pos = 0;
return DONE;
}
}
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. |
void reset(char[] chars) {
reset(chars, 0);
}
|
void reset(char[] chars,
int begin) {
this.chars = chars;
this.begin = begin;
pos = 0;
}
|
public char setIndex(int position) {
position -= begin;
if (position < 0 || position > chars.length) {
throw new IllegalArgumentException("Invalid index");
}
pos = position;
return current();
}
Sets the position to the specified position in the text and returns that
character. |