Method from java.text.AttributedString$AttributedStringIterator Detail: |
public Object clone() {
try {
AttributedStringIterator other = (AttributedStringIterator) super.clone();
return other;
}
catch (CloneNotSupportedException e) {
throw new InternalError();
}
}
|
public char current() {
if (currentIndex == endIndex) {
return DONE;
} else {
return charAt(currentIndex);
}
}
|
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof AttributedStringIterator)) {
return false;
}
AttributedStringIterator that = (AttributedStringIterator) obj;
if (AttributedString.this != that.getString())
return false;
if (currentIndex != that.currentIndex || beginIndex != that.beginIndex || endIndex != that.endIndex)
return false;
return true;
}
|
public char first() {
return internalSetIndex(beginIndex);
}
|
public Set<Attribute> getAllAttributeKeys() {
// ??? This should screen out attribute keys that aren't relevant to the client
if (runAttributes == null) {
// ??? would be nice to return null, but current spec doesn't allow it
// returning HashSet saves us from dealing with emptiness
return new HashSet();
}
synchronized (AttributedString.this) {
// ??? should try to create this only once, then update if necessary,
// and give callers read-only view
Set keys = new HashSet();
int i = 0;
while (i < runCount) {
if (runStarts[i] < endIndex && (i == runCount - 1 || runStarts[i + 1] > beginIndex)) {
Vector currentRunAttributes = runAttributes[i];
if (currentRunAttributes != null) {
int j = currentRunAttributes.size();
while (j-- > 0) {
keys.add(currentRunAttributes.get(j));
}
}
}
i++;
}
return keys;
}
}
|
public Object getAttribute(Attribute attribute) {
int runIndex = currentRunIndex;
if (runIndex < 0) {
return null;
}
return AttributedString.this.getAttributeCheckRange(attribute, runIndex, beginIndex, endIndex);
}
|
public Map<Attribute, Object> getAttributes() {
if (runAttributes == null || currentRunIndex == -1 || runAttributes[currentRunIndex] == null) {
// ??? would be nice to return null, but current spec doesn't allow it
// returning Hashtable saves AttributeMap from dealing with emptiness
return new Hashtable();
}
return new AttributeMap(currentRunIndex, beginIndex, endIndex);
}
|
public int getBeginIndex() {
return beginIndex;
}
|
public int getEndIndex() {
return endIndex;
}
|
public int getIndex() {
return currentIndex;
}
|
public int getRunLimit() {
return currentRunLimit;
}
|
public int getRunLimit(Attribute attribute) {
if (currentRunLimit == endIndex || currentRunIndex == -1) {
return currentRunLimit;
} else {
Object value = getAttribute(attribute);
int runLimit = currentRunLimit;
int runIndex = currentRunIndex;
while (runLimit < endIndex &&
valuesMatch(value, AttributedString.this.getAttribute(attribute, runIndex + 1))) {
runIndex++;
runLimit = runIndex < runCount - 1 ? runStarts[runIndex + 1] : endIndex;
}
if (runLimit > endIndex) {
runLimit = endIndex;
}
return runLimit;
}
}
|
public int getRunLimit(Set<Attribute> attributes) {
if (currentRunLimit == endIndex || currentRunIndex == -1) {
return currentRunLimit;
} else {
int runLimit = currentRunLimit;
int runIndex = currentRunIndex;
while (runLimit < endIndex &&
AttributedString.this.attributeValuesMatch(attributes, currentRunIndex, runIndex + 1)) {
runIndex++;
runLimit = runIndex < runCount - 1 ? runStarts[runIndex + 1] : endIndex;
}
if (runLimit > endIndex) {
runLimit = endIndex;
}
return runLimit;
}
}
|
public int getRunStart() {
return currentRunStart;
}
|
public int getRunStart(Attribute attribute) {
if (currentRunStart == beginIndex || currentRunIndex == -1) {
return currentRunStart;
} else {
Object value = getAttribute(attribute);
int runStart = currentRunStart;
int runIndex = currentRunIndex;
while (runStart > beginIndex &&
valuesMatch(value, AttributedString.this.getAttribute(attribute, runIndex - 1))) {
runIndex--;
runStart = runStarts[runIndex];
}
if (runStart < beginIndex) {
runStart = beginIndex;
}
return runStart;
}
}
|
public int getRunStart(Set<Attribute> attributes) {
if (currentRunStart == beginIndex || currentRunIndex == -1) {
return currentRunStart;
} else {
int runStart = currentRunStart;
int runIndex = currentRunIndex;
while (runStart > beginIndex &&
AttributedString.this.attributeValuesMatch(attributes, currentRunIndex, runIndex - 1)) {
runIndex--;
runStart = runStarts[runIndex];
}
if (runStart < beginIndex) {
runStart = beginIndex;
}
return runStart;
}
}
|
public int hashCode() {
return text.hashCode() ^ currentIndex ^ beginIndex ^ endIndex;
}
|
public char last() {
if (endIndex == beginIndex) {
return internalSetIndex(endIndex);
} else {
return internalSetIndex(endIndex - 1);
}
}
|
public char next() {
if (currentIndex < endIndex) {
return internalSetIndex(currentIndex + 1);
}
else {
return DONE;
}
}
|
public char previous() {
if (currentIndex > beginIndex) {
return internalSetIndex(currentIndex - 1);
}
else {
return DONE;
}
}
|
public char setIndex(int position) {
if (position < beginIndex || position > endIndex)
throw new IllegalArgumentException("Invalid index");
return internalSetIndex(position);
}
|