public final class

SpannedString

extends Object
implements GetChars Spanned CharSequence
java.lang.Object
   ↳ android.text.SpannedString

Class Overview

This is the class for text whose content and markup are immutable. For mutable markup, see SpannableString; for mutable text, see SpannableStringBuilder.

Summary

[Expand]
Inherited Constants
From interface android.text.Spanned
Public Constructors
SpannedString(CharSequence source)
Public Methods
final char charAt(int i)
Returns the character at the specified index, with the first character having index zero.
final void getChars(int start, int end, char[] dest, int off)
Exactly like String.getChars(): copy chars start through end - 1 from this CharSequence into dest beginning at offset destoff.
int getSpanEnd(Object what)
Return the end of the range of text to which the specified markup object is attached, or -1 if the object is not attached.
int getSpanFlags(Object what)
Return the flags that were specified when setSpan(Object, int, int, int) was used to attach the specified markup object, or 0 if the specified object has not been attached.
int getSpanStart(Object what)
Return the beginning of the range of text to which the specified markup object is attached, or -1 if the object is not attached.
<T> T[] getSpans(int queryStart, int queryEnd, Class<T> kind)
Return an array of the markup objects attached to the specified slice of this CharSequence and whose type is the specified type or a subclass of it.
final int length()
Returns the number of characters in this sequence.
int nextSpanTransition(int start, int limit, Class kind)
Return the first offset greater than or equal to start where a markup object of class type begins or ends, or limit if there are no starts or ends greater than or equal to start but less than limit.
CharSequence subSequence(int start, int end)
Returns a CharSequence from the start index (inclusive) to the end index (exclusive) of this sequence.
final String toString()
Returns a string containing a concise, human-readable description of this object.
static SpannedString valueOf(CharSequence source)
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.text.GetChars
From interface android.text.Spanned
From interface java.lang.CharSequence

Public Constructors

public SpannedString (CharSequence source)

Public Methods

public final char charAt (int i)

Returns the character at the specified index, with the first character having index zero.

Parameters
i the index of the character to return.
Returns
  • the requested character.

public final void getChars (int start, int end, char[] dest, int off)

Exactly like String.getChars(): copy chars start through end - 1 from this CharSequence into dest beginning at offset destoff.

public int getSpanEnd (Object what)

Return the end of the range of text to which the specified markup object is attached, or -1 if the object is not attached.

public int getSpanFlags (Object what)

Return the flags that were specified when setSpan(Object, int, int, int) was used to attach the specified markup object, or 0 if the specified object has not been attached.

public int getSpanStart (Object what)

Return the beginning of the range of text to which the specified markup object is attached, or -1 if the object is not attached.

public T[] getSpans (int queryStart, int queryEnd, Class<T> kind)

Return an array of the markup objects attached to the specified slice of this CharSequence and whose type is the specified type or a subclass of it. Specify Object.class for the type if you want all the objects regardless of type.

public final int length ()

Returns the number of characters in this sequence.

Returns
  • the number of characters.

public int nextSpanTransition (int start, int limit, Class kind)

Return the first offset greater than or equal to start where a markup object of class type begins or ends, or limit if there are no starts or ends greater than or equal to start but less than limit. Specify null or Object.class for the type if you want every transition regardless of type.

public CharSequence subSequence (int start, int end)

Returns a CharSequence from the start index (inclusive) to the end index (exclusive) of this sequence.

Parameters
start the start offset of the sub-sequence. It is inclusive, that is, the index of the first character that is included in the sub-sequence.
end the end offset of the sub-sequence. It is exclusive, that is, the index of the first character after those that are included in the sub-sequence
Returns
  • the requested sub-sequence.

public final String toString ()

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation simply concatenates the class name, the '@' sign and a hexadecimal representation of the object's hashCode(), that is, it is equivalent to the following expression:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
  • a printable representation of this object.

public static SpannedString valueOf (CharSequence source)