public class

AttributedString

extends Object
java.lang.Object
   ↳ java.text.AttributedString

Class Overview

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)
Returns an AttributedCharacterIterator that gives access to the complete content of this attributed 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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AttributedString (AttributedCharacterIterator iterator)

Since: API Level 1

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

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

public AttributedString (AttributedCharacterIterator iterator, int start, int end)

Since: API Level 1

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 the AttributedCharacterIterator that contains the text for this attributed string.
start the start index of the range of the copied text.
end 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.

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

Since: API Level 1

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 the AttributedCharacterIterator that contains the text for this attributed string.
start the start index of the range of the copied text.
end the end index of the range of the copied text.
attributes 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.

public AttributedString (String value)

Since: API Level 1

Creates an AttributedString from the given text.

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

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

Since: API Level 1

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

Parameters
value the text to take as base for this attributed string.
attributes 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

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

Since: API Level 1

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

Parameters
attribute the attribute that will be applied to this string.
value the value of the attribute that will be applied to this string.
start the start of the range where the attribute will be applied.
end 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.

public void addAttribute (AttributedCharacterIterator.Attribute attribute, Object value)

Since: API Level 1

Applies a given attribute to this string.

Parameters
attribute the attribute that will be applied to this string.
value 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.

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

Since: API Level 1

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

Parameters
attributes the set of attributes that will be applied to this string.
start the start of the range where the attribute will be applied.
end 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.

public AttributedCharacterIterator getIterator (Attribute[] attributes)

Since: API Level 1

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 the array containing attributes that will be in the new iterator if they are defined for this text.
Returns
  • the newly created AttributedCharacterIterator.

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

Since: API Level 1

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 the array containing attributes that will be in the new iterator if they are defined for this text.
start the start index of the iterator on the underlying text.
end the end index of the iterator on the underlying text.
Returns
  • the newly created AttributedCharacterIterator.

public AttributedCharacterIterator getIterator ()

Since: API Level 1

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

Returns
  • the newly created AttributedCharacterIterator.