java.text
Class AttributedString.AttributedStringIterator

java.lang.Object
  extended byjava.text.AttributedString.AttributedStringIterator
All Implemented Interfaces:
AttributedCharacterIterator, CharacterIterator, Cloneable
Enclosing class:
AttributedString

private final class AttributedString.AttributedStringIterator
extends Object
implements AttributedCharacterIterator


Nested Class Summary
 
Nested classes inherited from class java.text.AttributedCharacterIterator
AttributedCharacterIterator.Attribute
 
Field Summary
private  int beginIndex
           
private  int currentIndex
           
private  int currentRunIndex
           
private  int currentRunLimit
           
private  int currentRunStart
           
private  int endIndex
           
private  AttributedCharacterIterator.Attribute[] relevantAttributes
           
 
Fields inherited from interface java.text.CharacterIterator
DONE
 
Constructor Summary
(package private) AttributedString.AttributedStringIterator(AttributedCharacterIterator.Attribute[] attributes, int beginIndex, int endIndex)
           
 
Method Summary
 Object clone()
          Create a copy of this iterator
 char current()
          Gets the character at the current position (as returned by getIndex()).
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 char first()
          Sets the position to getBeginIndex() and returns the character at that position.
 Set getAllAttributeKeys()
          Returns the keys of all attributes defined on the iterator's text range.
 Object getAttribute(AttributedCharacterIterator.Attribute attribute)
          Returns the value of the named attribute for the current character.
 Map getAttributes()
          Returns a map with the attributes defined on the current character.
 int getBeginIndex()
          Returns the start index of the text.
 int getEndIndex()
          Returns the end index of the text.
 int getIndex()
          Returns the current index.
 int getRunLimit()
          Returns the index of the first character following the run with respect to all attributes containing the current character.
 int getRunLimit(AttributedCharacterIterator.Attribute attribute)
          Returns the index of the first character following the run with respect to the given attribute containing the current character.
 int getRunLimit(Set attributes)
          Returns the index of the first character following the run with respect to the given attributes containing the current character.
 int getRunStart()
          Returns the index of the first character of the run with respect to all attributes containing the current character.
 int getRunStart(AttributedCharacterIterator.Attribute attribute)
          Returns the index of the first character of the run with respect to the given attribute containing the current character.
 int getRunStart(Set attributes)
          Returns the index of the first character of the run with respect to the given attributes containing the current character.
private  AttributedString getString()
           
 int hashCode()
          Returns a hash code value for the object.
private  char internalSetIndex(int position)
           
 char last()
          Sets the position to getEndIndex()-1 (getEndIndex() if the text is empty) and returns the character at that position.
 char next()
          Increments the iterator's index by one and returns the character at the new index.
 char previous()
          Decrements the iterator's index by one and returns the character at the new index.
 char setIndex(int position)
          Sets the position to the specified position in the text and returns that character.
private  void updateRunInfo()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beginIndex

private int beginIndex

endIndex

private int endIndex

relevantAttributes

private AttributedCharacterIterator.Attribute[] relevantAttributes

currentIndex

private int currentIndex

currentRunIndex

private int currentRunIndex

currentRunStart

private int currentRunStart

currentRunLimit

private int currentRunLimit
Constructor Detail

AttributedString.AttributedStringIterator

AttributedString.AttributedStringIterator(AttributedCharacterIterator.Attribute[] attributes,
                                          int beginIndex,
                                          int endIndex)
Method Detail

equals

public boolean equals(Object obj)
Description copied from class: Object
Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Object.hashCode(), Hashtable

hashCode

public int hashCode()
Description copied from class: Object
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object), Hashtable

clone

public Object clone()
Description copied from interface: CharacterIterator
Create a copy of this iterator

Specified by:
clone in interface CharacterIterator
Overrides:
clone in class Object
Returns:
a clone of this instance.
See Also:
Cloneable

first

public char first()
Description copied from interface: CharacterIterator
Sets the position to getBeginIndex() and returns the character at that position.

Specified by:
first in interface CharacterIterator
Returns:
the first character in the text, or DONE if the text is empty
See Also:
CharacterIterator.getBeginIndex()

last

public char last()
Description copied from interface: CharacterIterator
Sets the position to getEndIndex()-1 (getEndIndex() if the text is empty) and returns the character at that position.

Specified by:
last in interface CharacterIterator
Returns:
the last character in the text, or DONE if the text is empty
See Also:
CharacterIterator.getEndIndex()

current

public char current()
Description copied from interface: CharacterIterator
Gets the character at the current position (as returned by getIndex()).

Specified by:
current in interface CharacterIterator
Returns:
the character at the current position or DONE if the current position is off the end of the text.
See Also:
CharacterIterator.getIndex()

next

public char next()
Description copied from interface: CharacterIterator
Increments the iterator's index by one and returns the character at the new index. If the resulting index is greater or equal to getEndIndex(), the current index is reset to getEndIndex() and a value of DONE is returned.

Specified by:
next in interface CharacterIterator
Returns:
the character at the new position or DONE if the new position is off the end of the text range.

previous

public char previous()
Description copied from interface: CharacterIterator
Decrements the iterator's index by one and returns the character at the new index. If the current index is getBeginIndex(), the index remains at getBeginIndex() and a value of DONE is returned.

Specified by:
previous in interface CharacterIterator
Returns:
the character at the new position or DONE if the current position is equal to getBeginIndex().

setIndex

public char setIndex(int position)
Description copied from interface: CharacterIterator
Sets the position to the specified position in the text and returns that character.

Specified by:
setIndex in interface CharacterIterator
Parameters:
position - the position within the text. Valid values range from getBeginIndex() to getEndIndex(). An IllegalArgumentException is thrown if an invalid value is supplied.
Returns:
the character at the specified position or DONE if the specified position is equal to getEndIndex()

getBeginIndex

public int getBeginIndex()
Description copied from interface: CharacterIterator
Returns the start index of the text.

Specified by:
getBeginIndex in interface CharacterIterator
Returns:
the index at which the text begins.

getEndIndex

public int getEndIndex()
Description copied from interface: CharacterIterator
Returns the end index of the text. This index is the index of the first character following the end of the text.

Specified by:
getEndIndex in interface CharacterIterator
Returns:
the index after the last character in the text

getIndex

public int getIndex()
Description copied from interface: CharacterIterator
Returns the current index.

Specified by:
getIndex in interface CharacterIterator
Returns:
the current index.

getRunStart

public int getRunStart()
Description copied from interface: AttributedCharacterIterator
Returns the index of the first character of the run with respect to all attributes containing the current character.

Specified by:
getRunStart in interface AttributedCharacterIterator

getRunStart

public int getRunStart(AttributedCharacterIterator.Attribute attribute)
Description copied from interface: AttributedCharacterIterator
Returns the index of the first character of the run with respect to the given attribute containing the current character.

Specified by:
getRunStart in interface AttributedCharacterIterator

getRunStart

public int getRunStart(Set attributes)
Description copied from interface: AttributedCharacterIterator
Returns the index of the first character of the run with respect to the given attributes containing the current character.

Specified by:
getRunStart in interface AttributedCharacterIterator

getRunLimit

public int getRunLimit()
Description copied from interface: AttributedCharacterIterator
Returns the index of the first character following the run with respect to all attributes containing the current character.

Specified by:
getRunLimit in interface AttributedCharacterIterator

getRunLimit

public int getRunLimit(AttributedCharacterIterator.Attribute attribute)
Description copied from interface: AttributedCharacterIterator
Returns the index of the first character following the run with respect to the given attribute containing the current character.

Specified by:
getRunLimit in interface AttributedCharacterIterator

getRunLimit

public int getRunLimit(Set attributes)
Description copied from interface: AttributedCharacterIterator
Returns the index of the first character following the run with respect to the given attributes containing the current character.

Specified by:
getRunLimit in interface AttributedCharacterIterator

getAttributes

public Map getAttributes()
Description copied from interface: AttributedCharacterIterator
Returns a map with the attributes defined on the current character.

Specified by:
getAttributes in interface AttributedCharacterIterator

getAllAttributeKeys

public Set getAllAttributeKeys()
Description copied from interface: AttributedCharacterIterator
Returns the keys of all attributes defined on the iterator's text range. The set is empty if no attributes are defined.

Specified by:
getAllAttributeKeys in interface AttributedCharacterIterator

getAttribute

public Object getAttribute(AttributedCharacterIterator.Attribute attribute)
Description copied from interface: AttributedCharacterIterator
Returns the value of the named attribute for the current character. Returns null if the attribute is not defined.

Specified by:
getAttribute in interface AttributedCharacterIterator
Parameters:
attribute - the key of the attribute whose value is requested.

getString

private AttributedString getString()

internalSetIndex

private char internalSetIndex(int position)

updateRunInfo

private void updateRunInfo()