1 /* 2 * Copyright (C) 2006 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 20 /** 21 * This is the class for text whose content is immutable but to which 22 * markup objects can be attached and detached. 23 * For mutable text, see {@link SpannableStringBuilder}. 24 */ 25 public class SpannableString 26 extends SpannableStringInternal 27 implements CharSequence, GetChars, Spannable 28 { 29 public SpannableString(CharSequence source) { 30 super(source, 0, source.length()); 31 } 32 33 private SpannableString(CharSequence source, int start, int end) { 34 super(source, start, end); 35 } 36 37 public static SpannableString valueOf(CharSequence source) { 38 if (source instanceof SpannableString) { 39 return (SpannableString) source; 40 } else { 41 return new SpannableString(source); 42 } 43 } 44 45 public void setSpan(Object what, int start, int end, int flags) { 46 super.setSpan(what, start, end, flags); 47 } 48 49 public void removeSpan(Object what) { 50 super.removeSpan(what); 51 } 52 53 public final CharSequence subSequence(int start, int end) { 54 return new SpannableString(this, start, end); 55 } 56 } 57