• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * This is the interface for text whose content and markup
21  * can be changed (as opposed
22  * to immutable text like Strings).  If you make a {@link DynamicLayout}
23  * of an Editable, the layout will be reflowed as the text is changed.
24  */
25 @android.ravenwood.annotation.RavenwoodKeepWholeClass
26 public interface Editable
27 extends CharSequence, GetChars, Spannable, Appendable
28 {
29     /**
30      * Replaces the specified range (<code>st&hellip;en</code>) of text in this
31      * Editable with a copy of the slice <code>start&hellip;end</code> from
32      * <code>source</code>.  The destination slice may be empty, in which case
33      * the operation is an insertion, or the source slice may be empty,
34      * in which case the operation is a deletion.
35      * <p>
36      * Before the change is committed, each filter that was set with
37      * {@link #setFilters} is given the opportunity to modify the
38      * <code>source</code> text.
39      * <p>
40      * If <code>source</code>
41      * is Spanned, the spans from it are preserved into the Editable.
42      * Existing spans within the Editable that entirely cover the replaced
43      * range are retained, but any that were strictly within the range
44      * that was replaced are removed. If the <code>source</code> contains a span
45      * with {@link Spanned#SPAN_PARAGRAPH} flag, and it does not satisfy the
46      * paragraph boundary constraint, it is not retained. As a special case, the
47      * cursor position is preserved even when the entire range where it is located
48      * is replaced.
49      * @return  a reference to this object.
50      *
51      * @see Spanned#SPAN_PARAGRAPH
52      */
replace(int st, int en, CharSequence source, int start, int end)53     public Editable replace(int st, int en, CharSequence source, int start, int end);
54 
55     /**
56      * Convenience for replace(st, en, text, 0, text.length())
57      * @see #replace(int, int, CharSequence, int, int)
58      */
replace(int st, int en, CharSequence text)59     public Editable replace(int st, int en, CharSequence text);
60 
61     /**
62      * Convenience for replace(where, where, text, start, end)
63      * @see #replace(int, int, CharSequence, int, int)
64      */
insert(int where, CharSequence text, int start, int end)65     public Editable insert(int where, CharSequence text, int start, int end);
66 
67     /**
68      * Convenience for replace(where, where, text, 0, text.length());
69      * @see #replace(int, int, CharSequence, int, int)
70      */
insert(int where, CharSequence text)71     public Editable insert(int where, CharSequence text);
72 
73     /**
74      * Convenience for replace(st, en, "", 0, 0)
75      * @see #replace(int, int, CharSequence, int, int)
76      */
delete(int st, int en)77     public Editable delete(int st, int en);
78 
79     /**
80      * Convenience for replace(length(), length(), text, 0, text.length())
81      * @see #replace(int, int, CharSequence, int, int)
82      */
append(CharSequence text)83     public Editable append(CharSequence text);
84 
85     /**
86      * Convenience for replace(length(), length(), text, start, end)
87      * @see #replace(int, int, CharSequence, int, int)
88      */
append(CharSequence text, int start, int end)89     public Editable append(CharSequence text, int start, int end);
90 
91     /**
92      * Convenience for append(String.valueOf(text)).
93      * @see #replace(int, int, CharSequence, int, int)
94      */
append(char text)95     public Editable append(char text);
96 
97     /**
98      * Convenience for replace(0, length(), "", 0, 0).
99      * Note that this clears the text, not the spans;
100      * use {@link #clearSpans} if you need that.
101      * @see #replace(int, int, CharSequence, int, int)
102      */
clear()103     public void clear();
104 
105     /**
106      * Removes all spans from the Editable, as if by calling
107      * {@link #removeSpan} on each of them.
108      */
clearSpans()109     public void clearSpans();
110 
111     /**
112      * Sets the series of filters that will be called in succession
113      * whenever the text of this Editable is changed, each of which has
114      * the opportunity to limit or transform the text that is being inserted.
115      */
setFilters(InputFilter[] filters)116     public void setFilters(InputFilter[] filters);
117 
118     /**
119      * Returns the array of input filters that are currently applied
120      * to changes to this Editable.
121      */
getFilters()122     public InputFilter[] getFilters();
123 
124     /**
125      * Factory used by TextView to create new {@link Editable Editables}. You can subclass
126      * it to provide something other than {@link SpannableStringBuilder}.
127      *
128      * @see android.widget.TextView#setEditableFactory(Factory)
129      */
130     public static class Factory {
131         private static Editable.Factory sInstance = new Editable.Factory();
132 
133         /**
134          * Returns the standard Editable Factory.
135          */
getInstance()136         public static Editable.Factory getInstance() {
137             return sInstance;
138         }
139 
140         /**
141          * Returns a new SpannableStringBuilder from the specified
142          * CharSequence.  You can override this to provide
143          * a different kind of Spanned.
144          */
newEditable(CharSequence source)145         public Editable newEditable(CharSequence source) {
146             return new SpannableStringBuilder(source);
147         }
148     }
149 }
150