package java.text;

import java.lang.String;

/*
 * Java core library component.
 *
 * Copyright (c) 1997, 1998
 *      Transvirtual Technologies, Inc.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file.
 */
final public class StringCharacterIterator
  implements CharacterIterator
{
	private String text;
	private int pos;
	private int begin;
	private int end;

public StringCharacterIterator(String text) {
	this(text, 0, text.length(), 0);
}

public StringCharacterIterator(String text, int pos) {
	this(text, 0, text.length(), pos);
}

public StringCharacterIterator(String text, int begin, int end, int pos) {
	this.text = text;
	this.pos = pos;
	this.begin = begin;
	this.end = end;
}

public Object clone() {
	StringCharacterIterator obj = new StringCharacterIterator(this.text, this.begin, this.end, this.pos);
	return (obj);
}

public char current() {
	if (pos < begin || pos >= end) {
		return (DONE);
	}
	else {
		return (text.charAt(pos));
	}
}

public boolean equals(Object obj) {
	if (obj instanceof StringCharacterIterator) {
		StringCharacterIterator other = (StringCharacterIterator)obj;
		if (text.equals(other.text) && pos == other.pos && begin == other.begin && end == other.end) {
			return (true);
		}
	}
	return (false);
}

public char first() {
	pos = begin;
	return (current());
}

public int getBeginIndex() {
	return (begin);
}

public int getEndIndex() {
	return (end);
}

public int getIndex() {
	return (pos);
}

public int hashCode() {
	return (super.hashCode());
}

public char last() {
	pos = end - 1;
	return (current());
}

public char next() {
	if ( pos < end ) {
		pos++;
		return (current());
	}
	return (DONE);
}

public char previous() {
	if ( pos > begin ) {
		pos--;
		return (current());
	}
	return (DONE);
}

public char setIndex(int pos) {
        if ( pos < getBeginIndex() || pos > getEndIndex() ) {
	        throw new IllegalArgumentException("Invalid index: "+pos);
	}
	    
	this.pos = pos;

	if ( pos == getEndIndex() )
	    return DONE;
	else
	    return text.charAt(pos);
}
}

@@ -1,50 +1,4 @@
-package java.text;%0A%0Aimport java.lang.String;%0A%0A
 /*%0A 
@@ -225,21 +225,68 @@
  */%0A
-final 
+%0Apackage java.text;%0A%0Aimport java.lang.String;%0A%0A
 public 
+final 
 clas
@@ -310,18 +310,16 @@
 Iterator
-%0A 
  impleme
@@ -339,17 +339,17 @@
 Iterator
-%0A
+ 
 %7B%0A%09priva
@@ -669,24 +669,163 @@
  int pos) %7B%0A
+%09if (begin %3C 0 %7C%7C end %3E text.length() %7C%7C begin %3E end%0A%09    %7C%7C pos %3C begin %7C%7C pos %3E end) %7B%0A%09%09throw new StringIndexOutOfBoundsException();%0A%09%7D%0A
 %09this.text =
@@ -893,147 +893,213 @@
 %0A%7D%0A%0A
+/*
 public 
-Object clone() %7B%0A%09StringCharacterIterator obj = new StringCharacterIterator(this.text, this.begin, this.end, this.pos);%0A%09return (obj
+?? */ void setText(String text) %7B%0A%09this.text = text;%0A%09this.pos = 0;%0A%09this.begin = 0;%0A%09this.end = text.length();%0A%7D%0A%0Apublic Object clone() %7B%0A%09return new StringCharacterIterator(text, begin, end, pos
 );%0A%7D
@@ -1397,16 +1397,22 @@
 er.text)
+%0A%09%09   
  && pos 
@@ -1447,16 +1447,22 @@
 er.begin
+%0A%09%09   
  && end 
@@ -1563,32 +1563,107 @@
 n;%0A%09return (
-current(
+text.charAt(pos));%0A%7D%0A%0Apublic char last() %7B%0A%09pos = end - 1;%0A%09return (text.charAt(pos
 ));%0A%7D%0A%0Apubli
@@ -1852,69 +1852,8 @@
 %0A%7D%0A%0A
-public char last() %7B%0A%09pos = end - 1;%0A%09return (current());%0A%7D%0A%0A
 publ
@@ -1895,33 +1895,33 @@
 %7B%0A%09%09
-pos++;%0A%09%09return (current(
+return (text.charAt(pos++
 ));%0A
@@ -1995,33 +1995,33 @@
 %7B%0A%09%09
-pos--;%0A%09%09return (current(
+return (text.charAt(--pos
 ));%0A
@@ -2097,46 +2097,26 @@
 s %3C 
-getBeginIndex() %7C%7C pos %3E getEndIndex()
+begin %7C%7C pos %3E end
  ) %7B
@@ -2191,14 +2191,8 @@
 %0A%09%7D%0A
-%09    %0A
 %09thi
@@ -2208,74 +2208,17 @@
 os;%0A
-%0A%09if ( pos == getEndIndex() )%0A%09    return DONE;%0A%09else%0A%09    return 
+%09return (
 text
@@ -2225,18 +2225,19 @@
 .charAt(pos)
+)
 ;%0A%7D%0A%7D%0A

Fix bug in next(); misc cleanups/tweaks.