.
Method from java.text.StringCharacterIterator Detail: |
public Object clone() {
try {
StringCharacterIterator other
= (StringCharacterIterator) super.clone();
return other;
}
catch (CloneNotSupportedException e) {
throw new InternalError();
}
}
Creates a copy of this iterator. |
public char current() {
if (pos >= begin && pos < end) {
return text.charAt(pos);
}
else {
return DONE;
}
}
Implements CharacterIterator.current() for String. |
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!(obj instanceof StringCharacterIterator))
return false;
StringCharacterIterator that = (StringCharacterIterator) obj;
if (hashCode() != that.hashCode())
return false;
if (!text.equals(that.text))
return false;
if (pos != that.pos || begin != that.begin || end != that.end)
return false;
return true;
}
Compares the equality of two StringCharacterIterator objects. |
public char first() {
pos = begin;
return current();
}
Implements CharacterIterator.first() for String. |
public int getBeginIndex() {
return begin;
}
Implements CharacterIterator.getBeginIndex() for String. |
public int getEndIndex() {
return end;
}
Implements CharacterIterator.getEndIndex() for String. |
public int getIndex() {
return pos;
}
Implements CharacterIterator.getIndex() for String. |
public int hashCode() {
return text.hashCode() ^ pos ^ begin ^ end;
}
Computes a hashcode for this iterator. |
public char last() {
if (end != begin) {
pos = end - 1;
} else {
pos = end;
}
return current();
}
Implements CharacterIterator.last() for String. |
public char next() {
if (pos < end - 1) {
pos++;
return text.charAt(pos);
}
else {
pos = end;
return DONE;
}
}
Implements CharacterIterator.next() for String. |
public char previous() {
if (pos > begin) {
pos--;
return text.charAt(pos);
}
else {
return DONE;
}
}
Implements CharacterIterator.previous() for String. |
public char setIndex(int p) {
if (p < begin || p > end)
throw new IllegalArgumentException("Invalid index");
pos = p;
return current();
}
Implements CharacterIterator.setIndex() for String. |
public void setText(String text) {
if (text == null)
throw new NullPointerException();
this.text = text;
this.begin = 0;
this.end = text.length();
this.pos = 0;
}
Reset this iterator to point to a new string. This package-visible
method is used by other java.text classes that want to avoid allocating
new StringCharacterIterator objects every time their setText method
is called. |