1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.text; 18 19 import android.os.Parcel; 20 21 /** 22 * Annotations are simple key-value pairs that are preserved across 23 * TextView save/restore cycles and can be used to keep application-specific 24 * data that needs to be maintained for regions of text. 25 */ 26 @android.ravenwood.annotation.RavenwoodKeepWholeClass 27 public class Annotation implements ParcelableSpan { 28 private final String mKey; 29 private final String mValue; 30 Annotation(String key, String value)31 public Annotation(String key, String value) { 32 mKey = key; 33 mValue = value; 34 } 35 Annotation(Parcel src)36 public Annotation(Parcel src) { 37 mKey = src.readString(); 38 mValue = src.readString(); 39 } 40 getSpanTypeId()41 public int getSpanTypeId() { 42 return getSpanTypeIdInternal(); 43 } 44 45 /** @hide */ getSpanTypeIdInternal()46 public int getSpanTypeIdInternal() { 47 return TextUtils.ANNOTATION; 48 } 49 describeContents()50 public int describeContents() { 51 return 0; 52 } 53 writeToParcel(Parcel dest, int flags)54 public void writeToParcel(Parcel dest, int flags) { 55 writeToParcelInternal(dest, flags); 56 } 57 58 /** @hide */ writeToParcelInternal(Parcel dest, int flags)59 public void writeToParcelInternal(Parcel dest, int flags) { 60 dest.writeString(mKey); 61 dest.writeString(mValue); 62 } 63 getKey()64 public String getKey() { 65 return mKey; 66 } 67 getValue()68 public String getValue() { 69 return mValue; 70 } 71 } 72