This class implements the AttributedCharacterIterator interface. It
is used by AttributedString.getIterator().
Method from java.text.AttributedStringIterator Detail: |
public Object clone() {
return(ci.clone());
}
|
public char current() {
return(ci.current());
}
|
public char first() {
return(ci.first());
}
|
public Set getAllAttributeKeys() {
HashSet s = new HashSet();
if (attribs == null)
return(s);
for (int i = 0; i < attribs.length; i++)
{
if (attribs[i].begin_index > getEndIndex()
|| attribs[i].end_index < = getBeginIndex())
continue;
Set key_set = attribs[i].attribs.keySet();
Iterator iter = key_set.iterator();
while (iter.hasNext())
{
s.add(iter.next());
}
}
return(s);
}
Returns a list of all the attribute keys that are defined anywhere
on this string. |
public Object getAttribute(Attribute key) {
return getAttribute(key, ci.getIndex());
}
Returns the value for an attribute at the current position. If the
attribute key (key ) is null , the method returns
null . |
public Map getAttributes() {
HashMap m = new HashMap();
if (attribs == null)
return(m);
for (int i = 0; i < attribs.length; i++)
{
if ((ci.getIndex() >= attribs[i].begin_index) &&
(ci.getIndex() < attribs[i].end_index))
m.putAll(attribs[i].attribs);
}
return(m);
}
Return a list of all the attributes and values defined for this
character |
public int getBeginIndex() {
return(ci.getBeginIndex());
}
|
public int getEndIndex() {
return(ci.getEndIndex());
}
|
public int getIndex() {
return(ci.getIndex());
}
|
public int getRunLimit() {
return(getRunLimit(getAttributes().keySet()));
}
Various methods that determine how far the run extends for various
attribute combinations. |
public int getRunLimit(Attribute attrib) {
HashSet s = new HashSet();
s.add(attrib);
return(getRunLimit(s));
}
|
public synchronized int getRunLimit(Set attributeSet) {
if (attributeSet == null)
return ci.getEndIndex();
int current = ci.getIndex();
int end = ci.getEndIndex();
int limit = current;
if (current == end)
return end;
Map runValues = getAttributes();
while (limit < end)
{
Iterator iterator = attributeSet.iterator();
while (iterator.hasNext())
{
// Qualified name is a workaround for a gcj 4.0 bug.
AttributedCharacterIterator.Attribute attributeKey
= (AttributedCharacterIterator.Attribute) iterator.next();
Object v1 = runValues.get(attributeKey);
Object v2 = getAttribute(attributeKey, limit + 1);
boolean changed = false;
// check for equal or both null, if NO return start
if (v1 != null)
{
changed = !v1.equals(v2);
}
else
{
changed = (v2 != null);
}
if (changed)
return limit + 1;
}
// no differences, so increment limit and next and loop again
limit++;
}
return end;
}
|
public int getRunStart() {
return(getRunStart(getAttributes().keySet()));
}
Returns the index of the first character in the run containing the current
character and defined by all the attributes defined for that character
position. |
public int getRunStart(Attribute attrib) {
if (attrib == null)
return ci.getBeginIndex();
HashSet s = new HashSet();
s.add(attrib);
return(getRunStart(s));
}
Returns the index of the first character in the run, defined by the
specified attribute, that contains the current character. |
public int getRunStart(Set attributeSet) {
if (attributeSet == null)
return ci.getBeginIndex();
int current = ci.getIndex();
int begin = ci.getBeginIndex();
int start = current;
if (start == begin)
return begin;
Map runValues = getAttributes();
int prev = start - 1;
while (start > begin)
{
Iterator iterator = attributeSet.iterator();
while (iterator.hasNext())
{
// Qualified name is a workaround for a gcj 4.0 bug.
AttributedCharacterIterator.Attribute attributeKey
= (AttributedCharacterIterator.Attribute) iterator.next();
Object v1 = runValues.get(attributeKey);
Object v2 = getAttribute(attributeKey, prev);
boolean changed = false;
// check for equal or both null, if NO return start
if (v1 != null)
{
changed = !v1.equals(v2);
}
else
{
changed = (v2 != null);
}
if (changed)
return start;
}
// no differences, so decrement start and prev and loop again
start--;
prev--;
}
return start;
}
Returns the index of the first character in the run, defined by the
specified attribute set, that contains the current character. |
public char last() {
return(ci.last());
}
|
public char next() {
return(ci.next());
}
|
public char previous() {
return(ci.previous());
}
|
public char setIndex(int index) {
return(ci.setIndex(index));
}
|