AttributedCharacterIterator | java.text |
This
interface extends CharacterIterator for working
with text that is marked up with attributes in some way. It defines
an inner class,
AttributedCharaterIterator.Attribute, that
represents attribute keys.
AttributedCharacterIterator defines methods for
querying the attribute keys, values, and runs for the text being
iterated over. getAllAttributeKeys( ) returns the
Set of all attribute keys that appear anywhere in
the text. getAttributes( ) returns a
Map that contains the attribute keys and values
that apply to the current character. getAttribute(
) returns the value associated with the specified attribute
key for the current character.
geTRunStart( ) and
getrunLimit( ) return the index of the first and
last characters in a run. A run is a string of
adjacent characters for which an attribute has the same value or is
undefined (i.e., has a value of null). A run can
also be defined for a set of attributes, in which case it is a set of
adjacent characters for which all attributes in the set hold a
constant value (which may include null). Programs
that process or display attributed text must usually work with it one
run at a time. The no-argument versions of getrunStart(
) and geTRunLimit( ) return the start
and end of the run that includes the current character and all
attributes that are applied to the current character. The other
versions of these methods return the start and end of the run of the
specified attribute or set of attributes that includes the current
character.
The
AttributedString class provides a simple way to
define short strings of attributed text and obtain an
AttributedCharacterIterator over them. Most
applications that process attributed text are working with attributed
text from specialized data sources, stored in some specialized data
format, so they need to define a custom implementation of
AttributedCharacterIterator.

public interface AttributedCharacterIterator extends CharacterIterator {
// Nested Types
public static class Attribute implements Serializable;
// Public Instance Methods
java.util.Set<AttributedCharacterIterator.Attribute>
getAllAttributeKeys( );
Object getAttribute(AttributedCharacterIterator.Attribute attribute);
java.util.Map<AttributedCharacterIterator.Attribute,Object>
getAttributes( );
int getRunLimit( );
int getRunLimit(java.util.Set<? extends AttributedCharacterIterator.
Attribute> attributes);
int getRunLimit(AttributedCharacterIterator.Attribute attribute);
int getRunStart( );
int getRunStart(AttributedCharacterIterator.Attribute attribute);
int getRunStart(java.util.Set<? extends AttributedCharacterIterator.
Attribute> attributes);
}
Passed To
AttributedString.AttributedString( ),
Bidi.Bidi( )
Returned By
AttributedString.getIterator( ),
DecimalFormat.formatToCharacterIterator( ),
Format.formatToCharacterIterator( ),
MessageFormat.formatToCharacterIterator( ),
SimpleDateFormat.formatToCharacterIterator( )
|