Class SpannableString

java.lang.Object
icyllis.modernui.text.SpannableString
All Implemented Interfaces:
GetChars, Spannable, Spanned, CharSequence

public class SpannableString extends Object implements Spannable, GetChars
This is the class for text whose content is immutable but to which markup objects can be attached and detached.
  • Constructor Details

    • SpannableString

      public SpannableString(@NonNull CharSequence source, boolean ignoreNoCopySpan)
      Parameters:
      source - source object to copy from
      ignoreNoCopySpan - whether to copy NoCopySpans in the source
    • SpannableString

      public SpannableString(@NonNull CharSequence source, int start, int end, boolean ignoreNoCopySpan)
    • SpannableString

      public SpannableString(@NonNull CharSequence source)
    • SpannableString

      public SpannableString(@NonNull CharSequence source, int start, int end)
  • Method Details

    • valueOf

      @NonNull public static SpannableString valueOf(@NonNull CharSequence source)
    • subSequence

      @NonNull public CharSequence subSequence(int start, int end)
      Specified by:
      subSequence in interface CharSequence
    • setSpan

      public void setSpan(@NonNull Object span, int start, int end, int flags)
    • removeSpan

      public void removeSpan(@NonNull Object span)
    • removeSpan

      public void removeSpan(@NonNull Object span, int flags)
    • 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 this CharSequence and whose type is the specified type or a subclass of it.
      Specify null or Object.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.

      Specified by:
      getSpans in interface Spanned
      Parameters:
      start - start char index of the slice
      end - end char index of the slice
      type - markup class
      dest - the list that receives method results
      Returns:
      the list of results
    • getSpanStart

      public int getSpanStart(@NonNull Object span)
      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 interface Spanned
      Parameters:
      span - markup object
      Returns:
      the start char index
    • getSpanEnd

      public int getSpanEnd(@NonNull Object span)
      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 interface Spanned
      Parameters:
      span - markup object
      Returns:
      the end char index
    • getSpanFlags

      public int getSpanFlags(@NonNull Object span)
      Description copied from interface: Spanned
      Return the flags that were specified when Spannable.setSpan(java.lang.Object, int, int, int) was used to attach the specified markup object, or 0 if the specified object has not been attached.
      Specified by:
      getSpanFlags in interface Spanned
      Parameters:
      span - markup object
      Returns:
      the flags
    • nextSpanTransition

      public int nextSpanTransition(int start, int limit, @Nullable Class<?> type)
      Description copied from interface: Spanned
      Return the first offset greater than start where a markup object of class type begins or ends, or limit if there are no starts or ends greater than start but less than limit. Specify null or Object.class for the type if you want every transition regardless of type.
      Specified by:
      nextSpanTransition in interface Spanned
      Parameters:
      start - start char index of the slice
      limit - end char index of the slice
      type - the markup type
      Returns:
      transition point
    • toString

      @NonNull public final String toString()
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Object
    • length

      public final int length()
      Specified by:
      length in interface CharSequence
    • charAt

      public final char charAt(int index)
      Specified by:
      charAt in interface CharSequence
    • getChars

      public final void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
      Specified by:
      getChars in interface GetChars
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface CharSequence
    • chars

      @NonNull public IntStream chars()
      Specified by:
      chars in interface CharSequence
    • codePoints

      @NonNull public IntStream codePoints()
      Specified by:
      codePoints in interface CharSequence
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object