Top Description Inners Fields Methods
java.text

public Interface AttributedCharacterIterator

extends CharacterIterator
Known Direct Implementers
java.text.AttributedString.AttributedStringIterator
Annotations
@SuppressWarnings:doclint:reference
Imports
java.io.InvalidObjectException, .Serializable, java.util.HashMap, .Map, .Set

An AttributedCharacterIterator allows iteration through both text and related attribute information.

An attribute is a key/value pair, identified by the key. No two attributes on a given character can have the same key.

The values for an attribute are immutable, or must not be mutated by clients or storage. They are always passed by reference, and not cloned.

A run with respect to an attribute is a maximum text range for which:

A run with respect to a set of attributes is a maximum text range for which this condition is met for each member attribute.

When getting a run with no explicit attributes specified (i.e., calling getRunStart() and getRunLimit()), any contiguous text segments having the same attributes (the same set of attribute/value pairs) are treated as separate runs if the attributes have been given to those text segments separately.

The returned indexes are limited to the range of the iterator.

The returned attribute information is limited to runs that contain the current character.

Attribute keys are instances of AttributedCharacterIterator.Attribute and its subclasses, such as java.desktop/java.awt.font.TextAttribute.

Since
1.2
See Also
AttributedCharacterIterator.Attribute, java.desktop/java.awt.font.TextAttribute, AttributedString, Annotation

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
AttributedCharacterIterator.Attribute

Defines attribute keys that are used to identify text attributes.

Field Summary

Inherited from java.text.CharacterIterator:
DONE

Method Summary

Modifier and TypeMethod and Description
public Set<AttributedCharacterIterator.Attribute>

Returns:

the keys of all attributes
getAllAttributeKeys
()

Returns the keys of all attributes defined on the iterator's text range.

public Object

Returns:

the value of the named attribute or null
getAttribute
(AttributedCharacterIterator.Attribute
the desired attribute
attribute
)

Returns the value of the named attribute for the current character.

public Map<AttributedCharacterIterator.Attribute, Object>

Returns:

a map with the attributes defined on the current character
getAttributes
()

Returns a map with the attributes defined on the current character.

public int

Returns:

the index of the first character following the run
getRunLimit
()

Returns the index of the first character following the run with respect to all attributes containing the current character.

public int

Returns:

the index of the first character following the run
getRunLimit
(AttributedCharacterIterator.Attribute
the desired attribute
attribute
)

Returns the index of the first character following the run with respect to the given attribute containing the current character.

public int

Returns:

the index of the first character following the run
getRunLimit
(Set<? extends AttributedCharacterIterator.Attribute>
a set of the desired attributes
attributes
)

Returns the index of the first character following the run with respect to the given attributes containing the current character.

public int

Returns:

the index of the first character of the run
getRunStart
()

Returns the index of the first character of the run with respect to all attributes containing the current character.

public int

Returns:

the index of the first character of the run
getRunStart
(AttributedCharacterIterator.Attribute
the desired attribute.
attribute
)

Returns the index of the first character of the run with respect to the given attribute containing the current character.

public int

Returns:

the index of the first character of the run
getRunStart
(Set<? extends AttributedCharacterIterator.Attribute>
a set of the desired attributes.
attributes
)

Returns the index of the first character of the run with respect to the given attributes containing the current character.

Inherited from java.text.CharacterIterator:
clonecurrentfirstgetBeginIndexgetEndIndexgetIndexlastnextprevioussetIndex

Method Detail

getAllAttributeKeysback to summary
public Set<AttributedCharacterIterator.Attribute> getAllAttributeKeys()

Returns the keys of all attributes defined on the iterator's text range. The set is empty if no attributes are defined.

Returns:Set<AttributedCharacterIterator.Attribute>

the keys of all attributes

getAttributeback to summary
public Object getAttribute(AttributedCharacterIterator.Attribute attribute)

Returns the value of the named attribute for the current character. Returns null if the attribute is not defined.

Parameters
attribute:AttributedCharacterIterator.Attribute

the desired attribute

Returns:Object

the value of the named attribute or null

getAttributesback to summary
public Map<AttributedCharacterIterator.Attribute, Object> getAttributes()

Returns a map with the attributes defined on the current character.

Returns:Map<AttributedCharacterIterator.Attribute, Object>

a map with the attributes defined on the current character

getRunLimitback to summary
public int getRunLimit()

Returns the index of the first character following the run with respect to all attributes containing the current character.

Any contiguous text segments having the same attributes (the same set of attribute/value pairs) are treated as separate runs if the attributes have been given to those text segments separately.

Returns:int

the index of the first character following the run

getRunLimitback to summary
public 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.

Parameters
attribute:AttributedCharacterIterator.Attribute

the desired attribute

Returns:int

the index of the first character following the run

getRunLimitback to summary
public int getRunLimit(Set<? extends AttributedCharacterIterator.Attribute> attributes)

Returns the index of the first character following the run with respect to the given attributes containing the current character.

Parameters
attributes:Set<? extends AttributedCharacterIterator.Attribute>

a set of the desired attributes

Returns:int

the index of the first character following the run

getRunStartback to summary
public int getRunStart()

Returns the index of the first character of the run with respect to all attributes containing the current character.

Any contiguous text segments having the same attributes (the same set of attribute/value pairs) are treated as separate runs if the attributes have been given to those text segments separately.

Returns:int

the index of the first character of the run

getRunStartback to summary
public 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.

Parameters
attribute:AttributedCharacterIterator.Attribute

the desired attribute.

Returns:int

the index of the first character of the run

getRunStartback to summary
public int getRunStart(Set<? extends AttributedCharacterIterator.Attribute> attributes)

Returns the index of the first character of the run with respect to the given attributes containing the current character.

Parameters
attributes:Set<? extends AttributedCharacterIterator.Attribute>

a set of the desired attributes.

Returns:int

the index of the first character of the run

java.text back to summary

public Class AttributedCharacterIterator.Attribute

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
java.text.Format.Field

Defines attribute keys that are used to identify text attributes. These keys are used in AttributedCharacterIterator and AttributedString.
Since
1.2
See Also
AttributedCharacterIterator, AttributedString

Field Summary

Modifier and TypeField and Description
public static final AttributedCharacterIterator.Attribute
INPUT_METHOD_SEGMENT

Attribute key for input method segments.

private static final Map<String, AttributedCharacterIterator.Attribute>
public static final AttributedCharacterIterator.Attribute
LANGUAGE

Attribute key for the language of some text.

private String
name

The name of this Attribute.

public static final AttributedCharacterIterator.Attribute
READING

Attribute key for the reading of some text.

private static final long

Constructor Summary

AccessConstructor and Description
protected
Attribute(String
the name of Attribute
name
)

Constructs an Attribute with the given name.

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Compares two objects for equality.

protected String

Returns:

the name of Attribute
getName
()

Returns the name of the attribute.

public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.

protected Object

Returns:

the resolved Attribute object
readResolve
()

Resolves instances being deserialized to the predefined constants.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

INPUT_METHOD_SEGMENTback to summary
public static final AttributedCharacterIterator.Attribute INPUT_METHOD_SEGMENT

Attribute key for input method segments. Input methods often break up text into segments, which usually correspond to words.

Values are instances of Annotation holding a null reference.

See Also
Annotation
instanceMapback to summary
private static final Map<String, AttributedCharacterIterator.Attribute> instanceMap
LANGUAGEback to summary
public static final AttributedCharacterIterator.Attribute LANGUAGE

Attribute key for the language of some text.

Values are instances of Locale.

See Also
java.util.Locale
nameback to summary
private String name

The name of this Attribute. The name is used primarily by readResolve to look up the corresponding predefined instance when deserializing an instance.

READINGback to summary
public static final AttributedCharacterIterator.Attribute READING

Attribute key for the reading of some text. In languages where the written form and the pronunciation of a word are only loosely related (such as Japanese), it is often necessary to store the reading (pronunciation) along with the written form.

Values are instances of Annotation holding instances of String.

See Also
Annotation, java.lang.String
serialVersionUIDback to summary
private static final long serialVersionUID
Annotations
@Serial

Constructor Detail

Attributeback to summary
protected Attribute(String name)

Constructs an Attribute with the given name.

Parameters
name:String

the name of Attribute

Method Detail

equalsback to summary
public final boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares two objects for equality. This version only returns true for x.equals(y) if x and y refer to the same object, and guarantees this for all subclasses.

Parameters
obj:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

getNameback to summary
protected String getName()

Returns the name of the attribute.

Returns:String

the name of Attribute

hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object. This version is identical to the one in Object, but is also final.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

readResolveback to summary
protected Object readResolve() throws InvalidObjectException

Resolves instances being deserialized to the predefined constants.

Returns:Object

the resolved Attribute object

Annotations
@Serial
Exceptions
InvalidObjectException:
if the object to resolve is not an instance of Attribute
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object. This version returns the concatenation of class name, "(", a name identifying the attribute and ")".

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object