Java Code Examples for android.text.Spanned#SPAN_EXCLUSIVE_EXCLUSIVE

The following examples show how to use android.text.Spanned#SPAN_EXCLUSIVE_EXCLUSIVE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseInputConnection.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** @hide */
public static void setComposingSpans(Spannable text, int start, int end) {
    final Object[] sps = text.getSpans(start, end, Object.class);
    if (sps != null) {
        for (int i=sps.length-1; i>=0; i--) {
            final Object o = sps[i];
            if (o == COMPOSING) {
                text.removeSpan(o);
                continue;
            }

            final int fl = text.getSpanFlags(o);
            if ((fl & (Spanned.SPAN_COMPOSING | Spanned.SPAN_POINT_MARK_MASK))
                    != (Spanned.SPAN_COMPOSING | Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)) {
                text.setSpan(o, text.getSpanStart(o), text.getSpanEnd(o),
                        (fl & ~Spanned.SPAN_POINT_MARK_MASK)
                                | Spanned.SPAN_COMPOSING
                                | Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
    }

    text.setSpan(COMPOSING, start, end,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING);
}
 
Example 2
Source File: ParagraphSpanProcessor.java    From memoir with Apache License 2.0 6 votes vote down vote up
void process(Spannable str) {
    for (ParagraphSpan paragraphSpan : mParagraphSpans) {
        RTParagraphSpan<V> span = paragraphSpan.mSpan;
        int paraStart = paragraphSpan.mParagraph.start();

        if (paragraphSpan.mRemove) {
            int spanStart = str.getSpanStart(span);
            if (spanStart > -1  && spanStart < paraStart) {
                // process preceding spans
                str.setSpan(span.createClone(), spanStart, paraStart, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
            }

            str.removeSpan(span);
        }

        else {
            Paragraph paragraph = paragraphSpan.mParagraph;
            int paraEnd = paragraphSpan.mParagraph.end();
            int flags = paragraph.isLast() && paragraph.isEmpty() ? Spanned.SPAN_INCLUSIVE_INCLUSIVE :
                        paragraph.isLast() && paragraph.isFirst() ? Spanned.SPAN_INCLUSIVE_INCLUSIVE :
                        paragraph.isLast() ? Spanned.SPAN_EXCLUSIVE_INCLUSIVE :
                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
            str.setSpan(span, paraStart, paraEnd, flags);
        }
    }
}
 
Example 3
Source File: Tx3gDecoder.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private static void attachFontFace(SpannableStringBuilder cueText, int fontFace,
    int defaultFontFace, int start, int end, int spanPriority) {
  if (fontFace != defaultFontFace) {
    final int flags = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | spanPriority;
    boolean isBold = (fontFace & FONT_FACE_BOLD) != 0;
    boolean isItalic = (fontFace & FONT_FACE_ITALIC) != 0;
    if (isBold) {
      if (isItalic) {
        cueText.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), start, end, flags);
      } else {
        cueText.setSpan(new StyleSpan(Typeface.BOLD), start, end, flags);
      }
    } else if (isItalic) {
      cueText.setSpan(new StyleSpan(Typeface.ITALIC), start, end, flags);
    }
    boolean isUnderlined = (fontFace & FONT_FACE_UNDERLINE) != 0;
    if (isUnderlined) {
      cueText.setSpan(new UnderlineSpan(), start, end, flags);
    }
    if (!isUnderlined && !isBold && !isItalic) {
      cueText.setSpan(new StyleSpan(Typeface.NORMAL), start, end, flags);
    }
  }
}
 
Example 4
Source File: ParagraphSpanProcessor.java    From Android-RTEditor with Apache License 2.0 6 votes vote down vote up
void process(Spannable str) {
    for (ParagraphSpan paragraphSpan : mParagraphSpans) {
        RTParagraphSpan<V> span = paragraphSpan.mSpan;
        int paraStart = paragraphSpan.mParagraph.start();

        if (paragraphSpan.mRemove) {
            int spanStart = str.getSpanStart(span);
            if (spanStart > -1  && spanStart < paraStart) {
                // process preceding spans
                str.setSpan(span.createClone(), spanStart, paraStart, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
            }

            str.removeSpan(span);
        }

        else {
            Paragraph paragraph = paragraphSpan.mParagraph;
            int paraEnd = paragraphSpan.mParagraph.end();
            int flags = paragraph.isLast() && paragraph.isEmpty() ? Spanned.SPAN_INCLUSIVE_INCLUSIVE :
                        paragraph.isLast() && paragraph.isFirst() ? Spanned.SPAN_INCLUSIVE_INCLUSIVE :
                        paragraph.isLast() ? Spanned.SPAN_EXCLUSIVE_INCLUSIVE :
                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
            str.setSpan(span, paraStart, paraEnd, flags);
        }
    }
}
 
Example 5
Source File: Tx3gDecoder.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private static void attachFontFace(SpannableStringBuilder cueText, int fontFace,
    int defaultFontFace, int start, int end, int spanPriority) {
  if (fontFace != defaultFontFace) {
    final int flags = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | spanPriority;
    boolean isBold = (fontFace & FONT_FACE_BOLD) != 0;
    boolean isItalic = (fontFace & FONT_FACE_ITALIC) != 0;
    if (isBold) {
      if (isItalic) {
        cueText.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), start, end, flags);
      } else {
        cueText.setSpan(new StyleSpan(Typeface.BOLD), start, end, flags);
      }
    } else if (isItalic) {
      cueText.setSpan(new StyleSpan(Typeface.ITALIC), start, end, flags);
    }
    boolean isUnderlined = (fontFace & FONT_FACE_UNDERLINE) != 0;
    if (isUnderlined) {
      cueText.setSpan(new UnderlineSpan(), start, end, flags);
    }
    if (!isUnderlined && !isBold && !isItalic) {
      cueText.setSpan(new StyleSpan(Typeface.NORMAL), start, end, flags);
    }
  }
}
 
Example 6
Source File: Tx3gDecoder.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private static void attachFontFace(SpannableStringBuilder cueText, int fontFace,
    int defaultFontFace, int start, int end, int spanPriority) {
  if (fontFace != defaultFontFace) {
    final int flags = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | spanPriority;
    boolean isBold = (fontFace & FONT_FACE_BOLD) != 0;
    boolean isItalic = (fontFace & FONT_FACE_ITALIC) != 0;
    if (isBold) {
      if (isItalic) {
        cueText.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), start, end, flags);
      } else {
        cueText.setSpan(new StyleSpan(Typeface.BOLD), start, end, flags);
      }
    } else if (isItalic) {
      cueText.setSpan(new StyleSpan(Typeface.ITALIC), start, end, flags);
    }
    boolean isUnderlined = (fontFace & FONT_FACE_UNDERLINE) != 0;
    if (isUnderlined) {
      cueText.setSpan(new UnderlineSpan(), start, end, flags);
    }
    if (!isUnderlined && !isBold && !isItalic) {
      cueText.setSpan(new StyleSpan(Typeface.NORMAL), start, end, flags);
    }
  }
}
 
Example 7
Source File: Tx3gDecoder.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private static void attachFontFace(SpannableStringBuilder cueText, int fontFace,
    int defaultFontFace, int start, int end, int spanPriority) {
  if (fontFace != defaultFontFace) {
    final int flags = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | spanPriority;
    boolean isBold = (fontFace & FONT_FACE_BOLD) != 0;
    boolean isItalic = (fontFace & FONT_FACE_ITALIC) != 0;
    if (isBold) {
      if (isItalic) {
        cueText.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), start, end, flags);
      } else {
        cueText.setSpan(new StyleSpan(Typeface.BOLD), start, end, flags);
      }
    } else if (isItalic) {
      cueText.setSpan(new StyleSpan(Typeface.ITALIC), start, end, flags);
    }
    boolean isUnderlined = (fontFace & FONT_FACE_UNDERLINE) != 0;
    if (isUnderlined) {
      cueText.setSpan(new UnderlineSpan(), start, end, flags);
    }
    if (!isUnderlined && !isBold && !isItalic) {
      cueText.setSpan(new StyleSpan(Typeface.NORMAL), start, end, flags);
    }
  }
}
 
Example 8
Source File: RichUtils.java    From RichEditor with MIT License 5 votes vote down vote up
private int getBlockSpanFlag(@RichTypeEnum String type) {
    if (RichTypeEnum.BLOCK_QUOTE.equals(type)) {
        return Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
    }

    return Spanned.SPAN_INCLUSIVE_INCLUSIVE;
}
 
Example 9
Source File: RichEditor.java    From RichEditor with MIT License 5 votes vote down vote up
private int[] getStyleTypeState(int start, int end, Spannable spannable) {
    Styleable[] styleables = spannable.getSpans(start, end, Styleable.class);
    if (styleables != null && styleables.length > 0) {
        int[] types = new int[styleables.length];
        for (int i = 0; i < styleables.length; i++) {
            int type = styleables[i].getStyleType();
            Style style = Style.get(type);
            int t;
            int flag = spannable.getSpanFlags(styleables[i]);
            if (style instanceof StyleExt) {
                //noinspection unchecked
                t = ((StyleExt) style).getStyleTypeState(flag, styleables[i]);
            } else {
                int state;
                if (flag == Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) {
                    state = StyleTypeStateSpec.StyleTypeState.STATE_EXIST;
                } else {
                    state = StyleTypeStateSpec.StyleTypeState.STATE_ACTIVE;
                }
                t = StyleTypeStateSpec.makeStyleTypeStateSpec(type, state);
            }
            types[i] = t;
        }
        return types;
    } else {
        return new int[0];
    }
}
 
Example 10
Source File: RichUtils.java    From RichEditor with MIT License 5 votes vote down vote up
/**
 * 获取合并后的span flag
 *
 * @param mergedLeftSpanFlag  被合并的左侧span flag
 * @param mergedRightSpanFlag 被合并的右侧span flag
 * @return 合并后的flag
 */
private int getMergeSpanFlag(int mergedLeftSpanFlag, int mergedRightSpanFlag) {
    boolean isStartInclusive = false;  // 是否包括左端点
    boolean isEndInclusive = false;    // 是否包括右端点
    if (mergedLeftSpanFlag == Spanned.SPAN_INCLUSIVE_EXCLUSIVE
            || mergedLeftSpanFlag == Spanned.SPAN_INCLUSIVE_INCLUSIVE) {
        isStartInclusive = true;
    }

    if (mergedRightSpanFlag == Spanned.SPAN_INCLUSIVE_INCLUSIVE
            || mergedRightSpanFlag == Spanned.SPAN_EXCLUSIVE_INCLUSIVE) {
        isEndInclusive = true;
    }

    if (isStartInclusive && isEndInclusive) {
        return Spanned.SPAN_INCLUSIVE_INCLUSIVE;
    }

    if (isStartInclusive) {
        return Spanned.SPAN_INCLUSIVE_EXCLUSIVE;
    }

    if (isEndInclusive) {
        return Spanned.SPAN_EXCLUSIVE_INCLUSIVE;
    }

    return Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
}
 
Example 11
Source File: EditableSecureBuffer.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
private static boolean hasNonExclusiveExclusiveSpanAt(CharSequence text, int offset) {
    if (text instanceof Spanned) {
        Spanned spanned = (Spanned) text;
        Object[] spans = spanned.getSpans(offset, offset, Object.class);
        final int length = spans.length;
        for (int i = 0; i < length; i++) {
            Object span = spans[i];
            int flags = spanned.getSpanFlags(span);
            if (flags != Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) return true;
        }
    }
    return false;
}
 
Example 12
Source File: RxTextTool.java    From RxTools-master with Apache License 2.0 5 votes vote down vote up
private Builder(@NonNull CharSequence text) {
    this.text = text;
    flag = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
    foregroundColor = defaultValue;
    backgroundColor = defaultValue;
    quoteColor = defaultValue;
    proportion = -1;
    xProportion = -1;
    mBuilder = new SpannableStringBuilder();
}
 
Example 13
Source File: Style.java    From RichEditor with MIT License 5 votes vote down vote up
@Override
public int getStyleTypeState(int flag, HeadSpan headSpan) {
    int state;
    if (flag == Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) {
        state = StyleTypeStateSpec.StyleTypeState.STATE_EXIST;
    } else {
        state = StyleTypeStateSpec.StyleTypeState.STATE_ACTIVE;
    }
    byte arg1 = (byte) headSpan.getHeadSize();
    return StyleTypeStateSpec.makeStyleTypeStateSpec(headSpan.getStyleType(), state, arg1);
}
 
Example 14
Source File: Style.java    From RichEditor with MIT License 5 votes vote down vote up
public int getStyleTypeState(int flag, T t) {
    int state;
    if (flag == Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) {
        state = StyleTypeStateSpec.StyleTypeState.STATE_EXIST;
    } else {
        state = StyleTypeStateSpec.StyleTypeState.STATE_ACTIVE;
    }
    return StyleTypeStateSpec.makeStyleTypeStateSpec(t.getStyleType(), state);
}
 
Example 15
Source File: SpanTool.java    From FastLib with Apache License 2.0 5 votes vote down vote up
private Builder(@NonNull CharSequence text) {
    this.text = text;
    flag = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
    foregroundColor = defaultValue;
    backgroundColor = defaultValue;
    quoteColor = defaultValue;
    proportion = -1;
    xProportion = -1;
    mBuilder = new SpannableStringBuilder();
}
 
Example 16
Source File: SpanUtils.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
private void setDefault() {
    flag = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
    foregroundColor = COLOR_DEFAULT;
    backgroundColor = COLOR_DEFAULT;
    lineHeight = -1;
    quoteColor = COLOR_DEFAULT;
    first = -1;
    bulletColor = COLOR_DEFAULT;
    fontSize = -1;
    proportion = -1;
    xProportion = -1;
    isStrikethrough = false;
    isUnderline = false;
    isSuperscript = false;
    isSubscript = false;
    isBold = false;
    isItalic = false;
    isBoldItalic = false;
    fontFamily = null;
    typeface = null;
    alignment = null;
    verticalAlign = -1;
    clickSpan = null;
    url = null;
    blurRadius = -1;
    shader = null;
    shadowRadius = -1;
    spans = null;

    imageBitmap = null;
    imageDrawable = null;
    imageUri = null;
    imageResourceId = -1;

    spaceSize = -1;
}
 
Example 17
Source File: TextDecorator.java    From text-decorator with Apache License 2.0 4 votes vote down vote up
private TextDecorator(TextView textView, String content) {
  this.textView = textView;
  this.content = content;
  this.decoratedContent = new SpannableString(content);
  this.flags = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
}
 
Example 18
Source File: SpanEZ.java    From SpanEZ with Apache License 2.0 4 votes vote down vote up
@Override
public StyleEZ exclusive() {
    spanFlags = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
    return this;
}
 
Example 19
Source File: LocaleSpanCompatUtils.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 4 votes vote down vote up
/**
 * Ensures that the specified range is covered with only one {@link LocaleSpan} with the given
 * locale. If the region is already covered by one or more {@link LocaleSpan}, their ranges are
 * updated so that each character has only one locale.
 * @param spannable the spannable object to be updated.
 * @param start the start index from which {@link LocaleSpan} is attached (inclusive).
 * @param end the end index to which {@link LocaleSpan} is attached (exclusive).
 * @param locale the locale to be attached to the specified range.
 */
@UsedForTesting
public static void updateLocaleSpan(final Spannable spannable, final int start,
        final int end, final Locale locale) {
    if (end < start) {
        Log.e(TAG, "Invalid range: start=" + start + " end=" + end);
        return;
    }
    if (!isLocaleSpanAvailable()) {
        return;
    }
    // A brief summary of our strategy;
    //   1. Enumerate all LocaleSpans between [start - 1, end + 1].
    //   2. For each LocaleSpan S:
    //      - Update the range of S so as not to cover [start, end] if S doesn't have the
    //        expected locale.
    //      - Mark S as "to be merged" if S has the expected locale.
    //   3. Merge all the LocaleSpans that are marked as "to be merged" into one LocaleSpan.
    //      If no appropriate span is found, create a new one with newLocaleSpan method.
    final int searchStart = Math.max(start - 1, 0);
    final int searchEnd = Math.min(end + 1, spannable.length());
    // LocaleSpans found in the target range. See the step 1 in the above comment.
    final Object[] existingLocaleSpans = spannable.getSpans(searchStart, searchEnd,
            LOCALE_SPAN_TYPE);
    // LocaleSpans that are marked as "to be merged". See the step 2 in the above comment.
    final ArrayList<Object> existingLocaleSpansToBeMerged = new ArrayList<>();
    boolean isStartExclusive = true;
    boolean isEndExclusive = true;
    int newStart = start;
    int newEnd = end;
    for (final Object existingLocaleSpan : existingLocaleSpans) {
        final Locale attachedLocale = getLocaleFromLocaleSpan(existingLocaleSpan);
        if (!locale.equals(attachedLocale)) {
            // This LocaleSpan does not have the expected locale. Update its range if it has
            // an intersection with the range [start, end] (the first case of the step 2 in the
            // above comment).
            removeLocaleSpanFromRange(existingLocaleSpan, spannable, start, end);
            continue;
        }
        final int spanStart = spannable.getSpanStart(existingLocaleSpan);
        final int spanEnd = spannable.getSpanEnd(existingLocaleSpan);
        if (spanEnd < spanStart) {
            Log.e(TAG, "Invalid span: spanStart=" + spanStart + " spanEnd=" + spanEnd);
            continue;
        }
        if (spanEnd < start || end < spanStart) {
            // No intersection found.
            continue;
        }

        // Here existingLocaleSpan has the expected locale and an intersection with the
        // range [start, end] (the second case of the the step 2 in the above comment).
        final int spanFlag = spannable.getSpanFlags(existingLocaleSpan);
        if (spanStart < newStart) {
            newStart = spanStart;
            isStartExclusive = ((spanFlag & Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) ==
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        if (newEnd < spanEnd) {
            newEnd = spanEnd;
            isEndExclusive = ((spanFlag & Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) ==
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        existingLocaleSpansToBeMerged.add(existingLocaleSpan);
    }

    int originalLocaleSpanFlag = 0;
    Object localeSpan = null;
    if (existingLocaleSpansToBeMerged.isEmpty()) {
        // If there is no LocaleSpan that is marked as to be merged, create a new one.
        localeSpan = newLocaleSpan(locale);
    } else {
        // Reuse the first LocaleSpan to avoid unnecessary object instantiation.
        localeSpan = existingLocaleSpansToBeMerged.get(0);
        originalLocaleSpanFlag = spannable.getSpanFlags(localeSpan);
        // No need to keep other instances.
        for (int i = 1; i < existingLocaleSpansToBeMerged.size(); ++i) {
            spannable.removeSpan(existingLocaleSpansToBeMerged.get(i));
        }
    }
    final int localeSpanFlag = getSpanFlag(originalLocaleSpanFlag, isStartExclusive,
            isEndExclusive);
    spannable.setSpan(localeSpan, newStart, newEnd, localeSpanFlag);
}
 
Example 20
Source File: SpannableStringUtilsTests.java    From Indic-Keyboard with Apache License 2.0 4 votes vote down vote up
public void testSplitCharSequenceWithSpan() {
    // text:  " a bcd efg hij  "
    // span1:  ^^^^^^^
    // span2:  ^^^^^
    // span3:              ^
    final SpannableString spannableString = new SpannableString(" a bcd efg hij  ");
    final Object span1 = new Object();
    final Object span2 = new Object();
    final Object span3 = new Object();
    final int SPAN1_FLAGS = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
    final int SPAN2_FLAGS = Spanned.SPAN_EXCLUSIVE_INCLUSIVE;
    final int SPAN3_FLAGS = Spanned.SPAN_INCLUSIVE_INCLUSIVE;
    spannableString.setSpan(span1, 0, 7, SPAN1_FLAGS);
    spannableString.setSpan(span2, 0, 5, SPAN2_FLAGS);
    spannableString.setSpan(span3, 12, 13, SPAN3_FLAGS);
    final CharSequence[] charSequencesFromSpanned = SpannableStringUtils.split(
            spannableString, " ", true /* preserveTrailingEmptySegmengs */);
    final CharSequence[] charSequencesFromString = SpannableStringUtils.split(
            spannableString.toString(), " ", true /* preserveTrailingEmptySegmengs */);


    assertEquals(7, charSequencesFromString.length);
    assertEquals(7, charSequencesFromSpanned.length);

    // text:  ""
    // span1: ^
    // span2: ^
    // span3:
    assertEquals("", charSequencesFromString[0].toString());
    assertSpanCount(0, charSequencesFromString[0]);
    assertEquals("", charSequencesFromSpanned[0].toString());
    assertSpanCount(2, charSequencesFromSpanned[0]);
    assertSpan(charSequencesFromSpanned[0], span1, 0, 0, SPAN1_FLAGS);
    assertSpan(charSequencesFromSpanned[0], span2, 0, 0, SPAN2_FLAGS);

    // text:  "a"
    // span1:  ^
    // span2:  ^
    // span3:
    assertEquals("a", charSequencesFromString[1].toString());
    assertSpanCount(0, charSequencesFromString[1]);
    assertEquals("a", charSequencesFromSpanned[1].toString());
    assertSpanCount(2, charSequencesFromSpanned[1]);
    assertSpan(charSequencesFromSpanned[1], span1, 0, 1, SPAN1_FLAGS);
    assertSpan(charSequencesFromSpanned[1], span2, 0, 1, SPAN2_FLAGS);

    // text:  "bcd"
    // span1:  ^^^
    // span2:  ^^
    // span3:
    assertEquals("bcd", charSequencesFromString[2].toString());
    assertSpanCount(0, charSequencesFromString[2]);
    assertEquals("bcd", charSequencesFromSpanned[2].toString());
    assertSpanCount(2, charSequencesFromSpanned[2]);
    assertSpan(charSequencesFromSpanned[2], span1, 0, 3, SPAN1_FLAGS);
    assertSpan(charSequencesFromSpanned[2], span2, 0, 2, SPAN2_FLAGS);

    // text:  "efg"
    // span1:
    // span2:
    // span3:
    assertEquals("efg", charSequencesFromString[3].toString());
    assertSpanCount(0, charSequencesFromString[3]);
    assertEquals("efg", charSequencesFromSpanned[3].toString());
    assertSpanCount(0, charSequencesFromSpanned[3]);

    // text:  "hij"
    // span1:
    // span2:
    // span3:   ^
    assertEquals("hij", charSequencesFromString[4].toString());
    assertSpanCount(0, charSequencesFromString[4]);
    assertEquals("hij", charSequencesFromSpanned[4].toString());
    assertSpanCount(1, charSequencesFromSpanned[4]);
    assertSpan(charSequencesFromSpanned[4], span3, 1, 2, SPAN3_FLAGS);

    // text:  ""
    // span1:
    // span2:
    // span3:
    assertEquals("", charSequencesFromString[5].toString());
    assertSpanCount(0, charSequencesFromString[5]);
    assertEquals("", charSequencesFromSpanned[5].toString());
    assertSpanCount(0, charSequencesFromSpanned[5]);

    // text:  ""
    // span1:
    // span2:
    // span3:
    assertEquals("", charSequencesFromString[6].toString());
    assertSpanCount(0, charSequencesFromString[6]);
    assertEquals("", charSequencesFromSpanned[6].toString());
    assertSpanCount(0, charSequencesFromSpanned[6]);
}