FileDocCategorySizeDatePackage
TextInfo.javaAPI DocAndroid 5.1 API5140Thu Mar 12 22:22:10 GMT 2015android.view.textservice

TextInfo

public final class TextInfo extends Object implements android.os.Parcelable
This class contains a metadata of the input of TextService

Fields Summary
private final CharSequence
mCharSequence
private final int
mCookie
private final int
mSequenceNumber
private static final int
DEFAULT_COOKIE
private static final int
DEFAULT_SEQUENCE_NUMBER
public static final Parcelable.Creator
CREATOR
Used to make this class parcelable.
Constructors Summary
public TextInfo(String text)
Constructor.

param
text the text which will be input to TextService


                    
       
        this(text, 0, getStringLengthOrZero(text), DEFAULT_COOKIE, DEFAULT_SEQUENCE_NUMBER);
    
public TextInfo(String text, int cookie, int sequenceNumber)
Constructor.

param
text the text which will be input to TextService
param
cookie the cookie for this TextInfo
param
sequenceNumber the sequence number for this TextInfo

        this(text, 0, getStringLengthOrZero(text), cookie, sequenceNumber);
    
public TextInfo(CharSequence charSequence, int start, int end, int cookie, int sequenceNumber)
Constructor.

param
charSequence the text which will be input to TextService. Attached spans that implement {@link ParcelableSpan} will also be marshaled alongside with the text.
param
start the beginning of the range of text (inclusive).
param
end the end of the range of text (exclusive).
param
cookie the cookie for this TextInfo
param
sequenceNumber the sequence number for this TextInfo

        if (TextUtils.isEmpty(charSequence)) {
            throw new IllegalArgumentException("charSequence is empty");
        }
        // Create a snapshot of the text including spans in case they are updated outside later.
        final SpannableStringBuilder spannableString =
                new SpannableStringBuilder(charSequence, start, end);
        // SpellCheckSpan is for internal use. We do not want to marshal this for TextService.
        final SpellCheckSpan[] spans = spannableString.getSpans(0, spannableString.length(),
                SpellCheckSpan.class);
        for (int i = 0; i < spans.length; ++i) {
            spannableString.removeSpan(spans[i]);
        }

        mCharSequence = spannableString;
        mCookie = cookie;
        mSequenceNumber = sequenceNumber;
    
public TextInfo(android.os.Parcel source)

        mCharSequence = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        mCookie = source.readInt();
        mSequenceNumber = source.readInt();
    
Methods Summary
public intdescribeContents()
Used to make this class parcelable.


               
    
       
        return 0;
    
public java.lang.CharSequencegetCharSequence()

return
the charSequence which is an input of a text service. This may have some parcelable spans.

        return mCharSequence;
    
public intgetCookie()

return
the cookie of TextInfo

        return mCookie;
    
public intgetSequence()

return
the sequence of TextInfo

        return mSequenceNumber;
    
private static intgetStringLengthOrZero(java.lang.String text)

        return TextUtils.isEmpty(text) ? 0 : text.length();
    
public java.lang.StringgetText()

return
the text which is an input of a text service

        if (mCharSequence == null) {
            return null;
        }
        return mCharSequence.toString();
    
public voidwriteToParcel(android.os.Parcel dest, int flags)
Used to package this object into a {@link Parcel}.

param
dest The {@link Parcel} to be written.
param
flags The flags used for parceling.

        TextUtils.writeToParcel(mCharSequence, dest, flags);
        dest.writeInt(mCookie);
        dest.writeInt(mSequenceNumber);