Class java.awt.font.StyledStringIterator
java.lang.Object
|
+----java.awt.font.StyledStringIterator
- public final class StyledStringIterator
- extends Object
- implements AttributedCharacterIterator
StyledStringIterator
implements the
AttributedCharacterIterater
protocol for a
StyledString
.
- See Also:
- CharacterIterator
Constructor Summary
|
StyledStringIterator(StyledString text,
int beginIndex,
int endIndex,
int index)
Allocates a new styled string iterator that iterates over
the styled string argument in the specified range, starting at
the specified index.
|
StyledStringIterator(String text,
AttributeSet attributes)
Allocates a new styled string iterator that iterates over
the entire range of the string argument, with all characters
having the specified attributes.
|
Method Summary
|
Object
|
clone()
Allocates a new copy of this object.
|
char
|
current()
Gets the character at the current position.
|
boolean
|
equals(Object obj)
Compares the equality of two StyledStringIterator objects.
|
boolean
|
equals(StyledStringIterator iter)
Compares the equality of two StyledStringIterator objects.
|
char
|
first()
Sets the position to getBeginIndex() and returns the character at that
position.
|
Enumeration
|
getAllAttributeNames()
Returns the names of all attributes defined on the iterator's text
range.
|
Object
|
getAttribute(String attributeName)
Returns the value of the named attribute for the current character.
|
AttributeSet
|
getAttributes()
Returns an attribute set with the attributes defined on the current
character.
|
int
|
getBeginIndex()
Returns the index of the first character in the range of the iterator.
|
void
|
getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
Copy a range of characters from this object into the specified array.
|
int
|
getEndIndex()
Returns the index after the last character in the range of the iterator.
|
int
|
getIndex()
Returns the current index.
|
int
|
getRunLimit()
Returns the index of the first position following the run
with respect to all attributes on the current character.
|
int
|
getRunLimit(String attributeName)
Returns the index of the first character following the run
with respect to the named attribute on the current character.
|
int
|
getRunLimit(Enumeration attributeNames)
Returns the index of the first character following the run
with respect to the named attributes on the current character.
|
int
|
getRunStart()
Returns the index of the first character of the run
with respect to all attributes on the current character.
|
int
|
getRunStart(String attributeName)
Returns the index of the first character of the run
with respect to the named attribute on the current character.
|
int
|
getRunStart(Enumeration attributeNames)
Returns the index of the first character of the run
with respect to the named attributes on the current character.
|
int
|
hashCode()
Return a hash code.
|
char
|
last()
Sets the position to getEndIndex() - 1 and returns the character at that
position.
|
char
|
next()
Increments the iterator's position by one and returns the character
there.
|
char
|
previous()
Decrements the iterator's position by one and returns the character
there.
|
CharacterIterator
|
restrict(int beginIndex,
int endIndex)
Return an iterator whose range is the range given by
beginIndex and endIndex, intersected with this iterator's
begin and end indices.
|
char
|
setIndex(int p)
Sets the position in the text and returns the character there.
|
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StyledStringIterator
public StyledStringIterator(StyledString text,
int beginIndex,
int endIndex,
int index)
- Allocates a new styled string iterator that iterates over
the styled string argument in the specified range, starting at
the specified index.
- Parameters:
text
- the styled string to iterate over
beginIndex
- the start of the range to iterate over
endIndex
- the end of the range to iterate over
index
- the initial position of the iterator
StyledStringIterator
public StyledStringIterator(String text,
AttributeSet attributes)
- Allocates a new styled string iterator that iterates over
the entire range of the string argument, with all characters
having the specified attributes.
- Parameters:
text
- the string to iterate over
attributes
- the attributes for the characters
first
public char first()
- Sets the position to getBeginIndex() and returns the character at that
position.
- Returns:
- The character at the current position, or DONE if the current
position is getEndIndex().
last
public char last()
- Sets the position to getEndIndex() - 1 and returns the character at that
position. If the position would be before getBeginIndex(), sets the
position to getBeginIndex(). This only happens if the iterator's range
is zero length.
- Returns:
- The character at the current position, or DONE if the current
position is getEndIndex().
current
public char current()
- Gets the character at the current position.
- Returns:
- The character at the current position, or DONE if the current
position is getEndIndex().
- See Also:
- getIndex
next
public char next()
- Increments the iterator's position by one and returns the character
there. If the new position is greater or equal
to getEndIndex(), sets the position to getEndIndex() and returns DONE.
- Returns:
- The character at the new position, or DONE if the new
position is getEndIndex().
previous
public char previous()
- Decrements the iterator's position by one and returns the character
there. If the new position is
less than getBeginIndex(), sets the position to getBeginIndex()
and returns DONE.
- Returns:
- The character at the new position, or DONE if the new
position is getEndIndex().
setIndex
public char setIndex(int p)
- Sets the position in the text and returns the character there.
If the new current position is getEndIndex(), returns DONE.
- Returns:
- The character at the current position, or DONE if the current
position is getEndIndex().
getBeginIndex
public final int getBeginIndex()
- Returns the index of the first character in the range of the iterator.
- Returns:
- The index of the first character in the range of the iterator.
getEndIndex
public final int getEndIndex()
- Returns the index after the last character in the range of the iterator.
- Returns:
- The index after the last character in the range of the iterator.
getIndex
public final int getIndex()
- Returns the current index.
- Returns:
- The current index.
clone
public Object clone()
- Allocates a new copy of this object.
- Returns:
- A copy of this object.
- Overrides:
- clone in class Object
restrict
public CharacterIterator restrict(int beginIndex,
int endIndex)
- Return an iterator whose range is the range given by
beginIndex and endIndex, intersected with this iterator's
begin and end indices.
- Parameters:
beginIndex
- the beginning index of the new iterator
endIndex
- the ending index of the new iterator
- Returns:
- an iterator with range beginIndex, endIndex
getChars
public void getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
- Copy a range of characters from this object into the specified array.
For performance reasons, clients iterating over the characters
in the iterator may prefer to index into an array. This method
extracts the iterator's characters into an array supplied by the
client.
- Parameters:
srcBegin
- the index in the iterator of the first character
to copy into the array
srcEnd
- the index in the iterator after the last character
to copy into the array. The number of characters copied will be
srcEnd - srcBegin
.
dst
- the array into which to copy
dstBegin
- the index in dst at which to begin copying
getRunStart
public int getRunStart()
- Returns the index of the first character of the run
with respect to all attributes on the current character.
- Implements:
- getRunStart in interface AttributedCharacterIterator
getRunStart
public int getRunStart(String attributeName)
- Returns the index of the first character of the run
with respect to the named attribute on the current character.
- Implements:
- getRunStart in interface AttributedCharacterIterator
getRunStart
public int getRunStart(Enumeration attributeNames)
- Returns the index of the first character of the run
with respect to the named attributes on the current character.
- Implements:
- getRunStart in interface AttributedCharacterIterator
getRunLimit
public int getRunLimit()
- Returns the index of the first position following the run
with respect to all attributes on the current character.
- Implements:
- getRunLimit in interface AttributedCharacterIterator
getRunLimit
public int getRunLimit(String attributeName)
- Returns the index of the first character following the run
with respect to the named attribute on the current character.
- Implements:
- getRunLimit in interface AttributedCharacterIterator
getRunLimit
public int getRunLimit(Enumeration attributeNames)
- Returns the index of the first character following the run
with respect to the named attributes on the current character.
- Implements:
- getRunLimit in interface AttributedCharacterIterator
getAttributes
public AttributeSet getAttributes()
- Returns an attribute set with the attributes defined on the current
character.
- Implements:
- getAttributes in interface AttributedCharacterIterator
getAttribute
public Object getAttribute(String attributeName)
- Returns the value of the named attribute for the current character.
Returns null if the attribute is not defined.
- Implements:
- getAttribute in interface AttributedCharacterIterator
- Parameters:
attributeName
- the name of the attribute whose value is requested.
getAllAttributeNames
public Enumeration getAllAttributeNames()
- Returns the names of all attributes defined on the iterator's text
range.
The enumeration is empty if no attributes are defined.
- Implements:
- getAllAttributeNames in interface AttributedCharacterIterator
equals
public boolean equals(Object obj)
- Compares the equality of two StyledStringIterator objects.
- Parameters:
obj
- the Object to be compared with.
- Returns:
- true if the given object is the same as this
StyledStringIterator object; false otherwise.
- Overrides:
- equals in class Object
equals
public boolean equals(StyledStringIterator iter)
- Compares the equality of two StyledStringIterator objects.
- Parameters:
obj
- the StyledStringIterator to be compared with.
- Returns:
- true if the given object is the same as this
StyledStringIterator object; false otherwise.
hashCode
public int hashCode()
- Return a hash code.
- Overrides:
- hashCode in class Object
Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.