home *** CD-ROM | disk | FTP | other *** search
- package java.text;
-
- import java.util.HashSet;
- import java.util.Hashtable;
- import java.util.Map;
- import java.util.Set;
- import java.util.Vector;
-
- final class AttributedString$AttributedStringIterator implements AttributedCharacterIterator {
- private int beginIndex;
- private int endIndex;
- private AttributedCharacterIterator.Attribute[] relevantAttributes;
- private int currentIndex;
- private int currentRunIndex;
- private int currentRunStart;
- private int currentRunLimit;
- // $FF: synthetic field
- private final AttributedString this$0;
-
- AttributedString$AttributedStringIterator(AttributedString var1, AttributedCharacterIterator.Attribute[] var2, int var3, int var4) {
- this.this$0 = var1;
- if (var3 >= 0 && var3 <= var4 && var4 <= AttributedString.access$000(var1)) {
- this.beginIndex = var3;
- this.endIndex = var4;
- this.currentIndex = var3;
- this.updateRunInfo();
- if (var2 != null) {
- this.relevantAttributes = (AttributedCharacterIterator.Attribute[])var2.clone();
- }
-
- } else {
- throw new IllegalArgumentException("Invalid substring range");
- }
- }
-
- public boolean equals(Object var1) {
- if (this == var1) {
- return true;
- } else if (!(var1 instanceof AttributedString$AttributedStringIterator)) {
- return false;
- } else {
- AttributedString$AttributedStringIterator var2 = (AttributedString$AttributedStringIterator)var1;
- if (this.this$0 != var2.getString()) {
- return false;
- } else {
- return this.currentIndex == var2.currentIndex && this.beginIndex == var2.beginIndex && this.endIndex == var2.endIndex;
- }
- }
- }
-
- public int hashCode() {
- return this.this$0.text.hashCode() ^ this.currentIndex ^ this.beginIndex ^ this.endIndex;
- }
-
- public Object clone() {
- try {
- AttributedString$AttributedStringIterator var1 = (AttributedString$AttributedStringIterator)super.clone();
- return var1;
- } catch (CloneNotSupportedException var2) {
- throw new InternalError();
- }
- }
-
- public char first() {
- return this.internalSetIndex(this.beginIndex);
- }
-
- public char last() {
- return this.endIndex == this.beginIndex ? this.internalSetIndex(this.endIndex) : this.internalSetIndex(this.endIndex - 1);
- }
-
- public char current() {
- return this.currentIndex == this.endIndex ? '\uffff' : AttributedString.access$100(this.this$0, this.currentIndex);
- }
-
- public char next() {
- return this.currentIndex < this.endIndex ? this.internalSetIndex(this.currentIndex + 1) : '\uffff';
- }
-
- public char previous() {
- return this.currentIndex > this.beginIndex ? this.internalSetIndex(this.currentIndex - 1) : '\uffff';
- }
-
- public char setIndex(int var1) {
- if (var1 >= this.beginIndex && var1 <= this.endIndex) {
- return this.internalSetIndex(var1);
- } else {
- throw new IllegalArgumentException("Invalid index");
- }
- }
-
- public int getBeginIndex() {
- return this.beginIndex;
- }
-
- public int getEndIndex() {
- return this.endIndex;
- }
-
- public int getIndex() {
- return this.currentIndex;
- }
-
- public int getRunStart() {
- return this.currentRunStart;
- }
-
- public int getRunStart(AttributedCharacterIterator.Attribute var1) {
- if (this.currentRunStart != this.beginIndex && this.currentRunIndex != -1) {
- Object var2 = this.getAttribute(var1);
- int var3 = this.currentRunStart;
-
- for(int var4 = this.currentRunIndex; var3 > this.beginIndex && AttributedString.access$300(var2, AttributedString.access$200(this.this$0, var1, var4 - 1)); var3 = this.this$0.runStarts[var4]) {
- --var4;
- }
-
- if (var3 < this.beginIndex) {
- var3 = this.beginIndex;
- }
-
- return var3;
- } else {
- return this.currentRunStart;
- }
- }
-
- public int getRunStart(Set var1) {
- if (this.currentRunStart != this.beginIndex && this.currentRunIndex != -1) {
- int var2 = this.currentRunStart;
-
- for(int var3 = this.currentRunIndex; var2 > this.beginIndex && AttributedString.access$400(this.this$0, var1, this.currentRunIndex, var3 - 1); var2 = this.this$0.runStarts[var3]) {
- --var3;
- }
-
- if (var2 < this.beginIndex) {
- var2 = this.beginIndex;
- }
-
- return var2;
- } else {
- return this.currentRunStart;
- }
- }
-
- public int getRunLimit() {
- return this.currentRunLimit;
- }
-
- public int getRunLimit(AttributedCharacterIterator.Attribute var1) {
- if (this.currentRunLimit != this.endIndex && this.currentRunIndex != -1) {
- Object var2 = this.getAttribute(var1);
- int var3 = this.currentRunLimit;
-
- for(int var4 = this.currentRunIndex; var3 < this.endIndex && AttributedString.access$300(var2, AttributedString.access$200(this.this$0, var1, var4 + 1)); var3 = var4 < this.this$0.runCount - 1 ? this.this$0.runStarts[var4 + 1] : this.endIndex) {
- ++var4;
- }
-
- if (var3 > this.endIndex) {
- var3 = this.endIndex;
- }
-
- return var3;
- } else {
- return this.currentRunLimit;
- }
- }
-
- public int getRunLimit(Set var1) {
- if (this.currentRunLimit != this.endIndex && this.currentRunIndex != -1) {
- int var2 = this.currentRunLimit;
-
- for(int var3 = this.currentRunIndex; var2 < this.endIndex && AttributedString.access$400(this.this$0, var1, this.currentRunIndex, var3 + 1); var2 = var3 < this.this$0.runCount - 1 ? this.this$0.runStarts[var3 + 1] : this.endIndex) {
- ++var3;
- }
-
- if (var2 > this.endIndex) {
- var2 = this.endIndex;
- }
-
- return var2;
- } else {
- return this.currentRunLimit;
- }
- }
-
- public Map getAttributes() {
- return (Map)(this.this$0.runAttributes != null && this.currentRunIndex != -1 && this.this$0.runAttributes[this.currentRunIndex] != null ? new AttributedString.AttributeMap(this.this$0, this.currentRunIndex, this.beginIndex, this.endIndex) : new Hashtable());
- }
-
- public Set getAllAttributeKeys() {
- if (this.this$0.runAttributes == null) {
- return new HashSet();
- } else {
- AttributedString var1 = this.this$0;
- synchronized(var1) {
- HashSet var2 = new HashSet();
-
- for(int var3 = 0; var3 < this.this$0.runCount; ++var3) {
- if (this.this$0.runStarts[var3] < this.endIndex && (var3 == this.this$0.runCount - 1 || this.this$0.runStarts[var3 + 1] > this.beginIndex)) {
- Vector var4 = this.this$0.runAttributes[var3];
- if (var4 != null) {
- int var5 = var4.size();
-
- while(var5-- > 0) {
- var2.add(var4.get(var5));
- }
- }
- }
- }
-
- return var2;
- }
- }
- }
-
- public Object getAttribute(AttributedCharacterIterator.Attribute var1) {
- int var2 = this.currentRunIndex;
- return var2 < 0 ? null : AttributedString.access$500(this.this$0, var1, var2, this.beginIndex, this.endIndex);
- }
-
- private AttributedString getString() {
- return this.this$0;
- }
-
- private char internalSetIndex(int var1) {
- this.currentIndex = var1;
- if (var1 < this.currentRunStart || var1 >= this.currentRunLimit) {
- this.updateRunInfo();
- }
-
- return this.currentIndex == this.endIndex ? '\uffff' : AttributedString.access$100(this.this$0, var1);
- }
-
- private void updateRunInfo() {
- if (this.currentIndex == this.endIndex) {
- this.currentRunStart = this.currentRunLimit = this.endIndex;
- this.currentRunIndex = -1;
- } else {
- AttributedString var1 = this.this$0;
- synchronized(var1) {
- int var2;
- for(var2 = -1; var2 < this.this$0.runCount - 1 && this.this$0.runStarts[var2 + 1] <= this.currentIndex; ++var2) {
- }
-
- this.currentRunIndex = var2;
- if (var2 >= 0) {
- this.currentRunStart = this.this$0.runStarts[var2];
- if (this.currentRunStart < this.beginIndex) {
- this.currentRunStart = this.beginIndex;
- }
- } else {
- this.currentRunStart = this.beginIndex;
- }
-
- if (var2 < this.this$0.runCount - 1) {
- this.currentRunLimit = this.this$0.runStarts[var2 + 1];
- if (this.currentRunLimit > this.endIndex) {
- this.currentRunLimit = this.endIndex;
- }
- } else {
- this.currentRunLimit = this.endIndex;
- }
- }
- }
-
- }
- }
-