Package icyllis.modernui.text
Class SpannableString
java.lang.Object
icyllis.modernui.text.SpannableString
- All Implemented Interfaces:
GetChars
,Spannable
,Spanned
,CharSequence
This is the class for text whose content is immutable but to which
markup objects can be attached and detached.
-
Nested Class Summary
Nested classes/interfaces inherited from interface icyllis.modernui.text.Spannable
Spannable.Factory
-
Field Summary
Fields inherited from interface icyllis.modernui.text.Spannable
DEFAULT_FACTORY
Fields inherited from interface icyllis.modernui.text.Spanned
SPAN_COMPOSING, SPAN_EXCLUSIVE_EXCLUSIVE, SPAN_EXCLUSIVE_INCLUSIVE, SPAN_INCLUSIVE_EXCLUSIVE, SPAN_INCLUSIVE_INCLUSIVE, SPAN_INTERMEDIATE, SPAN_MARK_MARK, SPAN_MARK_POINT, SPAN_PARAGRAPH, SPAN_POINT_MARK, SPAN_POINT_MARK_MASK, SPAN_POINT_POINT, SPAN_PRIORITY, SPAN_PRIORITY_SHIFT, SPAN_USER, SPAN_USER_SHIFT
-
Constructor Summary
ConstructorDescriptionSpannableString
(CharSequence source) SpannableString
(CharSequence source, boolean ignoreNoCopySpan) SpannableString
(CharSequence source, int start, int end) SpannableString
(CharSequence source, int start, int end, boolean ignoreNoCopySpan) -
Method Summary
Modifier and TypeMethodDescriptionfinal char
charAt
(int index) chars()
boolean
final void
getChars
(int srcBegin, int srcEnd, char[] dst, int dstBegin) int
getSpanEnd
(Object span) 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 span) Return the flags that were specified whenSpannable.setSpan(java.lang.Object, int, int, int)
was used to attach the specified markup object, or0
if the specified object has not been attached.<T> List
<T> Query a set of the markup objects attached to the specified slice of thisCharSequence
and whose type is the specified type or a subclass of it.int
getSpanStart
(Object span) Return the beginning of the range of text to which the specified markup object is attached, or-1
if the object is not attached.int
hashCode()
boolean
isEmpty()
final int
length()
int
nextSpanTransition
(int start, int limit, Class<?> type) Return the first offset greater thanstart
where a markup object of classtype
begins or ends, orlimit
if there are no starts or ends greater thanstart
but less thanlimit
.void
removeSpan
(Object span) void
removeSpan
(Object span, int flags) void
subSequence
(int start, int end) final String
toString()
static SpannableString
valueOf
(CharSequence source) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
charAt, chars, codePoints, isEmpty, length, toString
Methods inherited from interface icyllis.modernui.text.Spannable
removeSpan, removeSpan, setSpan
Methods inherited from interface icyllis.modernui.text.Spanned
getSpanEnd, getSpanFlags, getSpans, getSpans, getSpanStart, nextSpanTransition
-
Constructor Details
-
SpannableString
- Parameters:
source
- source object to copy fromignoreNoCopySpan
- whether to copy NoCopySpans in thesource
-
SpannableString
-
SpannableString
-
SpannableString
-
-
Method Details
-
valueOf
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
setSpan
-
removeSpan
-
removeSpan
-
getSpans
@NonNull public <T> List<T> getSpans(int start, int end, Class<? extends T> type, @Nullable List<T> dest) Description copied from interface:Spanned
Query a set of the markup objects attached to the specified slice of thisCharSequence
and whose type is the specified type or a subclass of it.
Specifynull
orObject.class
for the type if you want all the objects regardless of type.If
dest
list is non-null, it will be filled with the method results and returned as-is. Otherwise, a new (and possibly- unmodifiable) list will be created with method results and returned. The return list can be empty if there is no match. -
getSpanStart
Description copied from interface:Spanned
Return the beginning of the range of text to which the specified markup object is attached, or-1
if the object is not attached.- Specified by:
getSpanStart
in interfaceSpanned
- Parameters:
span
- markup object- Returns:
- the start char index
-
getSpanEnd
Description copied from interface:Spanned
Return the end of the range of text to which the specified markup object is attached, or-1
if the object is not attached.- Specified by:
getSpanEnd
in interfaceSpanned
- Parameters:
span
- markup object- Returns:
- the end char index
-
getSpanFlags
Description copied from interface:Spanned
Return the flags that were specified whenSpannable.setSpan(java.lang.Object, int, int, int)
was used to attach the specified markup object, or0
if the specified object has not been attached.- Specified by:
getSpanFlags
in interfaceSpanned
- Parameters:
span
- markup object- Returns:
- the flags
-
nextSpanTransition
Description copied from interface:Spanned
Return the first offset greater thanstart
where a markup object of classtype
begins or ends, orlimit
if there are no starts or ends greater thanstart
but less thanlimit
. Specifynull
orObject.class
for the type if you want every transition regardless of type.- Specified by:
nextSpanTransition
in interfaceSpanned
- Parameters:
start
- start char index of the slicelimit
- end char index of the slicetype
- the markup type- Returns:
- transition point
-
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-
length
public final int length()- Specified by:
length
in interfaceCharSequence
-
charAt
public final char charAt(int index) - Specified by:
charAt
in interfaceCharSequence
-
getChars
public final void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) -
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCharSequence
-
chars
- Specified by:
chars
in interfaceCharSequence
-
codePoints
- Specified by:
codePoints
in interfaceCharSequence
-
equals
-
hashCode
public int hashCode()
-