home *** CD-ROM | disk | FTP | other *** search
- package java.text;
-
- final class SimpleTextBoundary extends BreakIterator {
- private int pos;
- private CharacterIterator text;
- private TextBoundaryData data;
- private static final char END_OF_STRING = '\uffff';
-
- protected SimpleTextBoundary(TextBoundaryData var1) {
- this.data = var1;
- this.text = new StringCharacterIterator("");
- this.pos = this.text.getBeginIndex();
- }
-
- public boolean equals(Object var1) {
- if (this == var1) {
- return true;
- } else if (!(var1 instanceof SimpleTextBoundary)) {
- return false;
- } else {
- SimpleTextBoundary var2 = (SimpleTextBoundary)var1;
- if (this.data.getClass() != var2.data.getClass()) {
- return false;
- } else if (this.hashCode() != var2.hashCode()) {
- return false;
- } else if (this.pos != var2.pos) {
- return false;
- } else {
- return this.text.equals(var2.text);
- }
- }
- }
-
- public int hashCode() {
- return this.getClass().hashCode() ^ this.text.hashCode();
- }
-
- public Object clone() {
- try {
- SimpleTextBoundary var1 = (SimpleTextBoundary)super.clone();
- var1.text = (CharacterIterator)this.text.clone();
- return var1;
- } catch (InternalError var2) {
- throw new InternalError();
- }
- }
-
- public CharacterIterator getText() {
- return this.text;
- }
-
- public void setText(String var1) {
- this.text = new StringCharacterIterator(var1);
- this.pos = this.text.getBeginIndex();
- }
-
- public void setText(CharacterIterator var1) {
- this.text = var1;
- this.pos = this.text.getBeginIndex();
- }
-
- public int first() {
- this.pos = this.text.getBeginIndex();
- return this.pos;
- }
-
- public int last() {
- this.pos = this.text.getEndIndex();
- return this.pos;
- }
-
- public int next(int var1) {
- int var2 = this.current();
- if (var1 < 0) {
- for(int var3 = var1; var3 < 0 && var2 != -1; ++var3) {
- var2 = this.previous();
- }
- } else {
- for(int var4 = var1; var4 > 0 && var2 != -1; --var4) {
- var2 = this.next();
- }
- }
-
- return var2;
- }
-
- public int previous() {
- if (this.pos <= this.text.getBeginIndex()) {
- return -1;
- } else {
- int var1 = this.pos;
- this.pos = this.previousSafePosition(this.pos - 1);
- int var2 = this.pos;
-
- for(int var3 = this.next(); var3 < var1 && var3 != -1; var3 = this.next()) {
- var2 = var3;
- }
-
- this.pos = var2;
- return this.pos;
- }
- }
-
- public int next() {
- int var1 = this.pos;
- if (this.pos < this.text.getEndIndex()) {
- this.pos = this.nextPosition(this.pos);
- var1 = this.pos;
- } else {
- var1 = -1;
- }
-
- return var1;
- }
-
- public int following(int var1) {
- if (var1 >= this.text.getBeginIndex() && var1 < this.text.getEndIndex()) {
- this.pos = this.previousSafePosition(var1);
-
- int var2;
- do {
- var2 = this.next();
- } while(var2 <= var1 && var2 != -1);
-
- return var2;
- } else {
- throw new IllegalArgumentException("nextBoundaryAt offset out of bounds");
- }
- }
-
- public int current() {
- return this.pos;
- }
-
- private int previousSafePosition(int var1) {
- int var2 = this.text.getBeginIndex();
- int var3 = this.data.backward().initialState();
-
- for(char var4 = this.text.setIndex(var1); var4 != '\uffff' && !this.data.backward().isEndState(var3); var4 = this.text.previous()) {
- var3 = this.data.backward().get(var3, this.mappedChar(var4));
- if (this.data.backward().isMarkState(var3)) {
- var2 = this.text.getIndex();
- }
- }
-
- return var2;
- }
-
- private int nextPosition(int var1) {
- int var2 = this.text.getEndIndex();
- int var3 = this.data.forward().initialState();
-
- for(char var4 = this.text.setIndex(var1); var4 != '\uffff' && !this.data.forward().isEndState(var3); var4 = this.text.next()) {
- var3 = this.data.forward().get(var3, this.mappedChar(var4));
- if (this.data.forward().isMarkState(var3)) {
- var2 = this.text.getIndex();
- }
- }
-
- if (this.data.forward().isEndState(var3)) {
- return var2;
- } else {
- var3 = this.data.forward().get(var3, this.mappedChar('\uffff'));
- return this.data.forward().isMarkState(var3) ? this.text.getEndIndex() : var2;
- }
- }
-
- protected int mappedChar(char var1) {
- return this.data.map().mappedChar(var1);
- }
- }
-