Build 1.0_r1(from source)

android.text
Class TextUtils

java.lang.Object
  extended by android.text.TextUtils

public class TextUtils
extends Object


Nested Class Summary
static interface TextUtils.EllipsizeCallback
           
static class TextUtils.SimpleStringSplitter
          A simple string splitter.
static interface TextUtils.StringSplitter
          An interface for splitting strings according to rules that are opaque to the user of this interface.
static class TextUtils.TruncateAt
           
 
Field Summary
static Parcelable.Creator<CharSequence> CHAR_SEQUENCE_CREATOR
           
 
Method Summary
static CharSequence commaEllipsize(CharSequence text, TextPaint p, float avail, String oneMore, String more)
          Converts a CharSequence of the comma-separated form "Andy, Bob, Charles, David" that is too wide to fit into the specified width into one like "Andy, Bob, 2 more".
static CharSequence concat(CharSequence... text)
          Returns a CharSequence concatenating the specified CharSequences, retaining their spans if any.
static void copySpansFrom(Spanned source, int start, int end, Class kind, Spannable dest, int destoff)
           
static CharSequence ellipsize(CharSequence text, TextPaint p, float avail, TextUtils.TruncateAt where)
          Returns the original text if it fits in the specified width given the properties of the specified Paint, or, if it does not fit, a truncated copy with ellipsis character added at the specified edge or center.
static CharSequence ellipsize(CharSequence text, TextPaint p, float avail, TextUtils.TruncateAt where, boolean preserveLength, TextUtils.EllipsizeCallback callback)
          Returns the original text if it fits in the specified width given the properties of the specified Paint, or, if it does not fit, a copy with ellipsis character added at the specified edge or center.
static boolean equals(CharSequence a, CharSequence b)
          Returns true if a and b are equal, including if they are both null.
static CharSequence expandTemplate(CharSequence template, CharSequence... values)
          Replace instances of "^1", "^2", etc.
static void getChars(CharSequence s, int start, int end, char[] dest, int destoff)
           
static int getOffsetAfter(CharSequence text, int offset)
           
static int getOffsetBefore(CharSequence text, int offset)
           
static CharSequence getReverse(CharSequence source, int start, int end)
           
static int getTrimmedLength(CharSequence s)
          Returns the length that the specified CharSequence would have if spaces and control characters were trimmed from the start and end, as by String.trim().
static String htmlEncode(String s)
          Html-encode the string.
static int indexOf(CharSequence s, char ch)
           
static int indexOf(CharSequence s, char ch, int start)
           
static int indexOf(CharSequence s, char ch, int start, int end)
           
static int indexOf(CharSequence s, CharSequence needle)
           
static int indexOf(CharSequence s, CharSequence needle, int start)
           
static int indexOf(CharSequence s, CharSequence needle, int start, int end)
           
static boolean isDigitsOnly(CharSequence str)
          Returns whether the given CharSequence contains only digits.
static boolean isEmpty(CharSequence str)
          Returns true if the string is null or 0-length.
static boolean isGraphic(char c)
          Returns whether this character is a printable character.
static boolean isGraphic(CharSequence str)
          Returns whether the given CharSequence contains any printable characters.
static String join(CharSequence delimiter, Iterable tokens)
          Returns a string containing the tokens joined by delimiters.
static String join(CharSequence delimiter, Object[] tokens)
          Returns a string containing the tokens joined by delimiters.
static int lastIndexOf(CharSequence s, char ch)
           
static int lastIndexOf(CharSequence s, char ch, int last)
           
static int lastIndexOf(CharSequence s, char ch, int start, int last)
           
(package private) static char[] obtain(int len)
           
(package private) static void recycle(char[] temp)
           
static boolean regionMatches(CharSequence one, int toffset, CharSequence two, int ooffset, int len)
           
static CharSequence replace(CharSequence template, String[] sources, CharSequence[] destinations)
          Return a new CharSequence in which each of the source strings is replaced by the corresponding element of the destinations.
static String[] split(String text, Pattern pattern)
          Splits a string on a pattern.
static String[] split(String text, String expression)
          String.split() returns [''] when the string to be split is empty.
static CharSequence stringOrSpannedString(CharSequence source)
           
static String substring(CharSequence source, int start, int end)
           
static void writeToParcel(CharSequence cs, Parcel p, int parcelableFlags)
          Flatten a CharSequence and whatever styles can be copied across processes into the parcel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHAR_SEQUENCE_CREATOR

public static final Parcelable.Creator<CharSequence> CHAR_SEQUENCE_CREATOR
Method Detail

getChars

public static void getChars(CharSequence s,
                            int start,
                            int end,
                            char[] dest,
                            int destoff)

indexOf

public static int indexOf(CharSequence s,
                          char ch)

indexOf

public static int indexOf(CharSequence s,
                          char ch,
                          int start)

indexOf

public static int indexOf(CharSequence s,
                          char ch,
                          int start,
                          int end)

lastIndexOf

public static int lastIndexOf(CharSequence s,
                              char ch)

lastIndexOf

public static int lastIndexOf(CharSequence s,
                              char ch,
                              int last)

lastIndexOf

public static int lastIndexOf(CharSequence s,
                              char ch,
                              int start,
                              int last)

indexOf

public static int indexOf(CharSequence s,
                          CharSequence needle)

indexOf

public static int indexOf(CharSequence s,
                          CharSequence needle,
                          int start)

indexOf

public static int indexOf(CharSequence s,
                          CharSequence needle,
                          int start,
                          int end)

regionMatches

public static boolean regionMatches(CharSequence one,
                                    int toffset,
                                    CharSequence two,
                                    int ooffset,
                                    int len)

substring

public static String substring(CharSequence source,
                               int start,
                               int end)

join

public static String join(CharSequence delimiter,
                          Object[] tokens)
Returns a string containing the tokens joined by delimiters.

Parameters:
tokens - an array objects to be joined. Strings will be formed from the objects by calling object.toString().

join

public static String join(CharSequence delimiter,
                          Iterable tokens)
Returns a string containing the tokens joined by delimiters.

Parameters:
tokens - an array objects to be joined. Strings will be formed from the objects by calling object.toString().

split

public static String[] split(String text,
                             String expression)
String.split() returns [''] when the string to be split is empty. This returns []. This does not remove any empty strings from the result. For example split("a,", "," ) returns {"a", ""}.

Parameters:
text - the string to split
expression - the regular expression to match
Returns:
an array of strings. The array will be empty if text is empty
Throws:
NullPointerException - if expression or text is null

split

public static String[] split(String text,
                             Pattern pattern)
Splits a string on a pattern. String.split() returns [''] when the string to be split is empty. This returns []. This does not remove any empty strings from the result.

Parameters:
text - the string to split
pattern - the regular expression to match
Returns:
an array of strings. The array will be empty if text is empty
Throws:
NullPointerException - if expression or text is null

stringOrSpannedString

public static CharSequence stringOrSpannedString(CharSequence source)

isEmpty

public static boolean isEmpty(CharSequence str)
Returns true if the string is null or 0-length.

Parameters:
str - the string to be examined
Returns:
true if str is null or zero length

getTrimmedLength

public static int getTrimmedLength(CharSequence s)
Returns the length that the specified CharSequence would have if spaces and control characters were trimmed from the start and end, as by String.trim().


equals

public static boolean equals(CharSequence a,
                             CharSequence b)
Returns true if a and b are equal, including if they are both null.

Parameters:
a - first CharSequence to check
b - second CharSequence to check
Returns:
true if a and b are equal

getReverse

public static CharSequence getReverse(CharSequence source,
                                      int start,
                                      int end)

writeToParcel

public static void writeToParcel(CharSequence cs,
                                 Parcel p,
                                 int parcelableFlags)
Flatten a CharSequence and whatever styles can be copied across processes into the parcel.


replace

public static CharSequence replace(CharSequence template,
                                   String[] sources,
                                   CharSequence[] destinations)
Return a new CharSequence in which each of the source strings is replaced by the corresponding element of the destinations.


expandTemplate

public static CharSequence expandTemplate(CharSequence template,
                                          CharSequence... values)
Replace instances of "^1", "^2", etc. in the template CharSequence with the corresponding values. "^^" is used to produce a single caret in the output. Only up to 9 replacement values are supported, "^10" will be produce the first replacement value followed by a '0'.

Parameters:
template - the input text containing "^1"-style placeholder values. This object is not modified; a copy is returned.
values - CharSequences substituted into the template. The first is substituted for "^1", the second for "^2", and so on.
Returns:
the new CharSequence produced by doing the replacement
Throws:
IllegalArgumentException - if the template requests a value that was not provided, or if more than 9 values are provided.

getOffsetBefore

public static int getOffsetBefore(CharSequence text,
                                  int offset)

getOffsetAfter

public static int getOffsetAfter(CharSequence text,
                                 int offset)

copySpansFrom

public static void copySpansFrom(Spanned source,
                                 int start,
                                 int end,
                                 Class kind,
                                 Spannable dest,
                                 int destoff)

ellipsize

public static CharSequence ellipsize(CharSequence text,
                                     TextPaint p,
                                     float avail,
                                     TextUtils.TruncateAt where)
Returns the original text if it fits in the specified width given the properties of the specified Paint, or, if it does not fit, a truncated copy with ellipsis character added at the specified edge or center.


ellipsize

public static CharSequence ellipsize(CharSequence text,
                                     TextPaint p,
                                     float avail,
                                     TextUtils.TruncateAt where,
                                     boolean preserveLength,
                                     TextUtils.EllipsizeCallback callback)
Returns the original text if it fits in the specified width given the properties of the specified Paint, or, if it does not fit, a copy with ellipsis character added at the specified edge or center. If preserveLength is specified, the returned copy will be padded with zero-width spaces to preserve the original length and offsets instead of truncating. If callback is non-null, it will be called to report the start and end of the ellipsized range.


commaEllipsize

public static CharSequence commaEllipsize(CharSequence text,
                                          TextPaint p,
                                          float avail,
                                          String oneMore,
                                          String more)
Converts a CharSequence of the comma-separated form "Andy, Bob, Charles, David" that is too wide to fit into the specified width into one like "Andy, Bob, 2 more".

Parameters:
text - the text to truncate
p - the Paint with which to measure the text
avail - the horizontal width available for the text
oneMore - the string for "1 more" in the current locale
more - the string for "%d more" in the current locale

obtain

static char[] obtain(int len)

recycle

static void recycle(char[] temp)

htmlEncode

public static String htmlEncode(String s)
Html-encode the string.

Parameters:
s - the string to be encoded
Returns:
the encoded string

concat

public static CharSequence concat(CharSequence... text)
Returns a CharSequence concatenating the specified CharSequences, retaining their spans if any.


isGraphic

public static boolean isGraphic(CharSequence str)
Returns whether the given CharSequence contains any printable characters.


isGraphic

public static boolean isGraphic(char c)
Returns whether this character is a printable character.


isDigitsOnly

public static boolean isDigitsOnly(CharSequence str)
Returns whether the given CharSequence contains only digits.


Build 1.0_r1(from source)

Please submit a feedback, bug or feature