文字列ツール類TextUtils

1923 ワード

前はコードの中でよくこのタイプに出会いましたが、あまり関心がありませんでした。今日は公式文書を見に行きましたが、意外な収穫がありました。もともとはJavaのString類と同じ機能や近い方法がたくさんあります。しかし、Stringにはないような方法もたくさんあります。
static bootlean
equals(CharSequence) a, CharSequence b)
Returns true if a and b are equal,including if they are both null.
static int
indexOf(CharSequence) s,char ch)
static bootlean
isempty(CharSequence) str
Returns true if the string is null or 0-length.
static int
lastIndexOf(CharSequence) s,char ch)
static String[]
スプリット text String expression)
String.split()returns[']when the string to be split is empty.
static String
substring(CharSequence) source,int start,int end)
Create a new String Oject containing the given range of characters from the source string.
static CharSequence
replace(CharSequence) template、 String[] sources CharSequence[] destinations)
Return a new CharSequence in which each of the source stregs is replace by the corese ponding element of the destination.
いくつかの「似ている」というのはString類にない方法です。私は前に会ったことがないかもしれません。
static void
writeToParcel(Char Sequence) cs Parcel p,int parcellable Flags)
Flatenta CharSequence and whatever style can be copied acros processes into the parel.
public static CharSequence cat (CharSequence… text)
Added in  API level 1
Returns a CharSequence concatentating the specified Char Sequences、retaining their spans if any.
パラメータtextCharSequenceReturnsCharSequencepublic static void dumpSpans (CharSequence cs Printer printer String prefix)
Added in  API level 3
Debuggging tool to print the spans in a CharSequence.The output will be printed one span per line.If the Char Sequence is not a Spanned,then the ntire streing will be printend on a single.
パラメータcsCharSequenceprinterPrinterprefixString