Skip to content

Most visited

Recently visited

navigation
Added in API level 1

AttributedString

public class AttributedString
extends Object

java.lang.Object
   ↳ java.text.AttributedString


Holds a string with attributes describing the characters of this string.

Summary

Public constructors

AttributedString(AttributedCharacterIterator iterator)

Constructs an AttributedString from an AttributedCharacterIterator, which represents attributed text.

AttributedString(AttributedCharacterIterator iterator, int start, int end)

Constructs an AttributedString from a range of the text contained in the specified AttributedCharacterIterator, starting at start and ending at end.

AttributedString(AttributedCharacterIterator iterator, int start, int end, Attribute[] attributes)

Constructs an AttributedString from a range of the text contained in the specified AttributedCharacterIterator, starting at start, ending at end and it will copy the attributes defined in the specified set.

AttributedString(String value)

Creates an AttributedString from the given text.

AttributedString(String value, Map<? extends AttributedCharacterIterator.Attribute, ?> attributes)

Creates an AttributedString from the given text and the attributes.

Public methods

void addAttribute(AttributedCharacterIterator.Attribute attribute, Object value, int start, int end)

Applies a given attribute to the given range of this string.

void addAttribute(AttributedCharacterIterator.Attribute attribute, Object value)

Applies a given attribute to this string.

void addAttributes(Map<? extends AttributedCharacterIterator.Attribute, ?> attributes, int start, int end)

Applies a given set of attributes to the given range of the string.

AttributedCharacterIterator getIterator(Attribute[] attributes, int start, int end)

Returns an AttributedCharacterIterator that gives access to the contents of this attributed string starting at index start up to index end.

AttributedCharacterIterator getIterator()

Returns an AttributedCharacterIterator that gives access to the complete content of this attributed string.

AttributedCharacterIterator getIterator(Attribute[] attributes)

Returns an AttributedCharacterIterator that gives access to the complete content of this attributed string.

Inherited methods

From class java.lang.Object

Public constructors

AttributedString

Added in API level 1
AttributedString (AttributedCharacterIterator iterator)

Constructs an AttributedString from an AttributedCharacterIterator, which represents attributed text.

Parameters
iterator AttributedCharacterIterator: the AttributedCharacterIterator that contains the text for this attributed string.

AttributedString

Added in API level 1
AttributedString (AttributedCharacterIterator iterator, 
                int start, 
                int end)

Constructs an AttributedString from a range of the text contained in the specified AttributedCharacterIterator, starting at start and ending at end. All attributes will be copied to this attributed string.

Parameters
iterator AttributedCharacterIterator: the AttributedCharacterIterator that contains the text for this attributed string.
start int: the start index of the range of the copied text.
end int: the end index of the range of the copied text.
Throws
IllegalArgumentException if start is less than first index of iterator, end is greater than the last index + 1 in iterator or if start > end.

AttributedString

Added in API level 1
AttributedString (AttributedCharacterIterator iterator, 
                int start, 
                int end, 
                Attribute[] attributes)

Constructs an AttributedString from a range of the text contained in the specified AttributedCharacterIterator, starting at start, ending at end and it will copy the attributes defined in the specified set. If the set is null then all attributes are copied.

Parameters
iterator AttributedCharacterIterator: the AttributedCharacterIterator that contains the text for this attributed string.
start int: the start index of the range of the copied text.
end int: the end index of the range of the copied text.
attributes Attribute: the set of attributes that will be copied, or all if it is null.
Throws
IllegalArgumentException if start is less than first index of iterator, end is greater than the last index + 1 in iterator or if start > end.

AttributedString

Added in API level 1
AttributedString (String value)

Creates an AttributedString from the given text.

Parameters
value String: the text to take as base for this attributed string.

AttributedString

Added in API level 1
AttributedString (String value, 
                Map<? extends AttributedCharacterIterator.Attribute, ?> attributes)

Creates an AttributedString from the given text and the attributes. The whole text has the given attributes applied.

Parameters
value String: the text to take as base for this attributed string.
attributes Map: the attributes that the text is associated with.
Throws
IllegalArgumentException if the length of value is 0 but the size of attributes is greater than 0.
NullPointerException if value is null.

Public methods

addAttribute

Added in API level 1
void addAttribute (AttributedCharacterIterator.Attribute attribute, 
                Object value, 
                int start, 
                int end)

Applies a given attribute to the given range of this string.

Parameters
attribute AttributedCharacterIterator.Attribute: the attribute that will be applied to this string.
value Object: the value of the attribute that will be applied to this string.
start int: the start of the range where the attribute will be applied.
end int: the end of the range where the attribute will be applied.
Throws
IllegalArgumentException if start < 0, end is greater than the length of this string, or if start >= end.
NullPointerException if attribute is null.

addAttribute

Added in API level 1
void addAttribute (AttributedCharacterIterator.Attribute attribute, 
                Object value)

Applies a given attribute to this string.

Parameters
attribute AttributedCharacterIterator.Attribute: the attribute that will be applied to this string.
value Object: the value of the attribute that will be applied to this string.
Throws
IllegalArgumentException if the length of this attributed string is 0.
NullPointerException if attribute is null.

addAttributes

Added in API level 1
void addAttributes (Map<? extends AttributedCharacterIterator.Attribute, ?> attributes, 
                int start, 
                int end)

Applies a given set of attributes to the given range of the string.

Parameters
attributes Map: the set of attributes that will be applied to this string.
start int: the start of the range where the attribute will be applied.
end int: the end of the range where the attribute will be applied.
Throws
IllegalArgumentException if start < 0, end is greater than the length of this string, or if start >= end.

getIterator

Added in API level 1
AttributedCharacterIterator getIterator (Attribute[] attributes, 
                int start, 
                int end)

Returns an AttributedCharacterIterator that gives access to the contents of this attributed string starting at index start up to index end. Only attributes contained in attributes are available from this iterator if they are defined for this text.

Parameters
attributes Attribute: the array containing attributes that will be in the new iterator if they are defined for this text.
start int: the start index of the iterator on the underlying text.
end int: the end index of the iterator on the underlying text.
Returns
AttributedCharacterIterator the newly created AttributedCharacterIterator.

getIterator

Added in API level 1
AttributedCharacterIterator getIterator ()

Returns an AttributedCharacterIterator that gives access to the complete content of this attributed string.

Returns
AttributedCharacterIterator the newly created AttributedCharacterIterator.

getIterator

Added in API level 1
AttributedCharacterIterator getIterator (Attribute[] attributes)

Returns an AttributedCharacterIterator that gives access to the complete content of this attributed string. Only attributes contained in attributes are available from this iterator if they are defined for this text.

Parameters
attributes Attribute: the array containing attributes that will be in the new iterator if they are defined for this text.
Returns
AttributedCharacterIterator the newly created AttributedCharacterIterator.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.