DthingApi
|
Public Member Functions | |
String () | |
String (byte[] data) | |
String (byte[] data, int offset, int byteCount) | |
String (byte[] data, int offset, int byteCount, String charsetName) throws UnsupportedEncodingException | |
String (byte[] data, String charsetName) throws UnsupportedEncodingException | |
String (char[] data) | |
String (char[] data, int offset, int charCount) | |
String (String toCopy) | |
String (StringBuffer stringBuffer) | |
char | charAt (int index) |
int | compareTo (String string) |
int | compareToIgnoreCase (String string) |
String | concat (String string) |
boolean | endsWith (String suffix) |
boolean | equals (Object object) |
boolean | equalsIgnoreCase (String string) |
byte [] | getBytes () |
byte [] | getBytes (String charsetName) throws UnsupportedEncodingException |
void | getChars (int start, int end, char[] buffer, int index) |
int | hashCode () |
int | indexOf (int c) |
int | indexOf (int c, int start) |
int | indexOf (String string) |
int | indexOf (String subString, int start) |
native String | intern () |
int | lastIndexOf (int c) |
int | lastIndexOf (int c, int start) |
int | lastIndexOf (String string) |
int | lastIndexOf (String subString, int start) |
int | length () |
boolean | regionMatches (int thisStart, String string, int start, int length) |
boolean | regionMatches (boolean ignoreCase, int thisStart, String string, int start, int length) |
String | replace (char oldChar, char newChar) |
String | replace (CharSequence target, CharSequence replacement) |
boolean | startsWith (String prefix) |
boolean | startsWith (String prefix, int start) |
String | substring (int start) |
String | substring (int start, int end) |
char [] | toCharArray () |
String | toLowerCase () |
String | toString () |
String | toUpperCase () |
String | trim () |
boolean | contentEquals (StringBuffer strbuf) |
boolean | contentEquals (CharSequence cs) |
CharSequence | subSequence (int start, int end) |
boolean | isEmpty () |
boolean | contains (CharSequence cs) |
Static Public Member Functions | |
static String | copyValueOf (char[] data) |
static String | copyValueOf (char[] data, int start, int length) |
static String | valueOf (char[] data) |
static String | valueOf (char[] data, int start, int length) |
static String | valueOf (char value) |
static String | valueOf (double value) |
static String | valueOf (float value) |
static String | valueOf (int value) |
static String | valueOf (long value) |
static String | valueOf (Object value) |
static String | valueOf (boolean value) |
An immutable sequence of characters/code units (
s). A
is represented by array of UTF-16 values, such that Unicode supplementary characters (code points) are stored/encoded as surrogate pairs via Unicode code units (
).
This class is implemented using a char[]. The length of the array may exceed the length of the string. For example, the string "Hello" may be backed by the array
with offset 0 and length 5.
Multiple strings can share the same char[] because strings are immutable. The substring method always returns a string that shares the backing array of its source string. Generally this is an optimization: fewer character arrays need to be allocated, and less copying is necessary. But this can also lead to unwanted heap retention. Taking a short substring of long string means that the long shared char[] won't be garbage until both strings are garbage. This typically happens when parsing small substrings out of a large input. To avoid this where necessary, call
. The string copy constructor always ensures that the backing array is no larger than necessary.
|
inline |
Creates an empty string.
|
inline |
Converts the byte array to a string using the system's default charset.
|
inline |
Converts a subsequence of the byte array to a string using the system's default charset.
NullPointerException | if data == null |
IndexOutOfBoundsException | if byteCount < 0 || offset < 0 || offset + byteCount > data.length |
|
inline |
Converts the byte array to a string using the named charset.
The behavior when the bytes cannot be decoded by the named charset is unspecified. Use java.nio.charset.CharsetDecoder for more control.
NullPointerException | if data == null |
IndexOutOfBoundsException | if byteCount < 0 || offset < 0 || offset + byteCount > data.length |
UnsupportedEncodingException | if the named charset is not supported. |
|
inline |
Converts the byte array to a string using the named charset.
The behavior when the bytes cannot be decoded by the named charset is unspecified. Use java.nio.charset.CharsetDecoder for more control.
NullPointerException | if data == null |
UnsupportedEncodingException | if charsetName |
|
inline |
Initializes this string to contain the characters in the specified character array. Modifying the character array after creating the string has no effect on the string.
NullPointerException | if data == null |
|
inline |
Initializes this string to contain the specified characters in the character array. Modifying the character array after creating the string has no effect on the string.
NullPointerException | if data == null |
IndexOutOfBoundsException | if charCount < 0 || offset < 0 || offset + charCount > data.length |
|
inline |
Constructs a new string with the same sequence of characters as
. The returned string's backing array is no larger than necessary.
|
inline |
|
inline |
Returns the character at the specified offset in this string.
index | the zero-based index in this string. |
IndexOutOfBoundsException | if index < 0 index >= length() |
Implements java.lang.CharSequence.
|
inline |
Compares the specified string to this string using the Unicode values of the characters. Returns 0 if the strings contain the same characters in the same order. Returns a negative integer if the first non-equal character in this string has a Unicode value which is less than the Unicode value of the character at the same position in the specified string, or if this string is a prefix of the specified string. Returns a positive integer if the first non-equal character in this string has a Unicode value which is greater than the Unicode value of the character at the same position in the specified string, or if the specified string is a prefix of this string.
string | the string to compare. |
NullPointerException | if string null |
|
inline |
Compares the specified string to this string using the Unicode values of the characters, ignoring case differences. Returns 0 if the strings contain the same characters in the same order. Returns a negative integer if the first non-equal character in this string has a Unicode value which is less than the Unicode value of the character at the same position in the specified string, or if this string is a prefix of the specified string. Returns a positive integer if the first non-equal character in this string has a Unicode value which is greater than the Unicode value of the character at the same position in the specified string, or if the specified string is a prefix of this string.
string | the string to compare. |
NullPointerException | if string null |
Concatenates this string and the specified string.
string | the string to concatenate |
|
inline |
Determines if this
contains the sequence of characters in the
passed.
cs | the character sequence to search for. |
|
inline |
Returns whether the characters in the StringBuffer
are the same as those in this string.
strbuf | the StringBuffer to compare this string to. |
NullPointerException | if strbuf null |
|
inline |
Compares a
to this
to determine if their contents are equal.
cs | the character sequence to compare to. |
|
inlinestatic |
Creates a new string containing the characters in the specified character array. Modifying the character array after creating the string has no effect on the string.
data | the array of characters. |
NullPointerException | if data null |
|
inlinestatic |
Creates a new string containing the specified characters in the character array. Modifying the character array after creating the string has no effect on the string.
data | the array of characters. |
start | the starting offset in the character array. |
length | the number of characters to use. |
NullPointerException | if data null |
IndexOutOfBoundsException | if length < 0, start < 0 start + length > data.length |
|
inline |
Compares the specified string to this string to determine if the specified string is a suffix.
suffix | the suffix to look for. |
NullPointerException | if suffix null |
|
inline |
Compares the specified object to this string and returns true if they are equal. The object must be an instance of string with the same characters in the same order.
object | the object to compare. |
|
inline |
Compares the specified string to this string ignoring the case of the characters and returns true if they are equal.
string | the string to compare. |
|
inline |
Returns a new byte array containing the characters of this string encoded using the system's default charset.
The behavior when this string cannot be represented in the system's default charset is unspecified. In practice, when the default charset is UTF-8 (as it is on Android), all strings can be encoded.
|
inline |
Returns a new byte array containing the characters of this string encoded using the named charset.
The behavior when this string cannot be represented in the named charset is unspecified. Use java.nio.charset.CharsetEncoder for more control.
UnsupportedEncodingException | if the charset is not supported |
|
inline |
Copies the specified characters in this string to the character array starting at the specified offset in the character array.
start | the starting offset of characters to copy. |
end | the ending offset of characters to copy. |
buffer | the destination character array. |
index | the starting offset in the character array. |
NullPointerException | if buffer null |
IndexOutOfBoundsException | if start < 0 end > length() start > end index < 0 end - start > buffer.length - index |
|
inline |
Returns a hashcode for this string. The hashcode for a String
object is computed as
s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
using int
arithmetic, where s[i]
is the ith character of the string, n
is the length of the string, and ^
indicates exponentiation. (The hash value of the empty string is zero.)
|
inline |
Searches in this string for the first index of the specified character. The search for the character starts at the beginning and moves towards the end of this string.
c | the character to find. |
|
inline |
Searches in this string for the index of the specified character. The search for the character starts at the specified offset and moves towards the end of this string.
c | the character to find. |
start | the starting offset. |
|
inline |
Searches in this string for the first index of the specified string. The search for the string starts at the beginning and moves towards the end of this string.
string | the string to find. |
NullPointerException | if string null |
|
inline |
Searches in this string for the index of the specified string. The search for the string starts at the specified offset and moves towards the end of this string.
subString | the string to find. |
start | the starting offset. |
NullPointerException | if subString null |
native String java.lang.String.intern | ( | ) |
Returns an interned string equal to this string. The VM maintains an internal set of unique strings. All string literals found in loaded classes' constant pools are automatically interned. Manually-interned strings are only weakly referenced, so calling
won't lead to unwanted retention.
Interning is typically used because it guarantees that for interned strings
and
,
can be simplified to
. (This is not true of non-interned strings.)
Many applications find it simpler and more convenient to use an explicit java.util.HashMap to implement their own pools.
|
inline |
Returns the last index of the code point
, or -1. The search for the character starts at the end and moves towards the beginning of this string.
|
inline |
Returns the last index of the code point
, or -1. The search for the character starts at offset
and moves towards the beginning of this string.
|
inline |
Searches in this string for the last index of the specified string. The search for the string starts at the end and moves towards the beginning of this string.
string | the string to find. |
NullPointerException | if string null |
|
inline |
Searches in this string for the index of the specified string. The search for the string starts at the specified offset and moves towards the beginning of this string.
subString | the string to find. |
start | the starting offset. |
NullPointerException | if subString null |
|
inline |
Returns the size of this string.
Implements java.lang.CharSequence.
|
inline |
Compares the specified string to this string and compares the specified range of characters to determine if they are the same.
thisStart | the starting offset in this string. |
string | the string to compare. |
start | the starting offset in the specified string. |
length | the number of characters to compare. |
NullPointerException | if string null |
|
inline |
Compares the specified string to this string and compares the specified range of characters to determine if they are the same. When ignoreCase is true, the case of the characters is ignored during the comparison.
ignoreCase | specifies if case should be ignored. |
thisStart | the starting offset in this string. |
string | the string to compare. |
start | the starting offset in the specified string. |
length | the number of characters to compare. |
NullPointerException | if string null |
|
inline |
Copies this string replacing occurrences of the specified character with another character.
oldChar | the character to replace. |
newChar | the replacement character. |
|
inline |
Copies this string replacing occurrences of the specified target sequence with another sequence. The string is processed from the beginning to the end.
target | the sequence to replace. |
replacement | the replacement sequence. |
NullPointerException | if target replacement null |
|
inline |
Compares the specified string to this string to determine if the specified string is a prefix.
prefix | the string to look for. |
NullPointerException | if prefix null |
|
inline |
Compares the specified string to this string, starting at the specified offset, to determine if the specified string is a prefix.
prefix | the string to look for. |
start | the starting offset. |
NullPointerException | if prefix null |
|
inline |
Returns a
from the
index (inclusive) to the
index (exclusive) of this sequence.
start | the start offset of the sub-sequence. It is inclusive, that is, the index of the first character that is included in the sub-sequence. |
end | the end offset of the sub-sequence. It is exclusive, that is, the index of the first character after those that are included in the sub-sequence |
IndexOutOfBoundsException | if start < 0 end < 0 start > end start end |
Implements java.lang.CharSequence.
|
inline |
Returns a string containing a suffix of this string. The returned string shares this string's backing array.
start | the offset of the first character. |
IndexOutOfBoundsException | if start < 0 start > length() |
|
inline |
Returns a string containing a subsequence of characters from this string. The returned string shares this string's backing array.
start | the offset of the first character. |
end | the offset one past the last character. |
IndexOutOfBoundsException | if start < 0 start > end end > length() |
|
inline |
Copies the characters in this string to a character array.
|
inline |
Converts this string to lower case, using the rules of the user's default locale. See "<a href="../util/Locale.html::default_locale">Be wary of the default locale</a>".
|
inline |
Returns this string.
Implements java.lang.CharSequence.
|
inline |
Converts this this string to upper case, using the rules of the user's default locale. See "<a href="../util/Locale.html::default_locale">Be wary of the default locale</a>".
|
inline |
Copies this string removing white space characters from the beginning and end of the string.
<= \u0020
removed from the beginning and the end.
|
inlinestatic |
Creates a new string containing the characters in the specified character array. Modifying the character array after creating the string has no effect on the string.
data | the array of characters. |
NullPointerException | if data null |
|
inlinestatic |
Creates a new string containing the specified characters in the character array. Modifying the character array after creating the string has no effect on the string.
data | the array of characters. |
start | the starting offset in the character array. |
length | the number of characters to use. |
IndexOutOfBoundsException | if length < 0 start < 0 start + length > data.length |
NullPointerException | if data null |
|
inlinestatic |
Converts the specified character to its string representation.
value | the character. |
|
inlinestatic |
Converts the specified double to its string representation.
value | the double. |
|
inlinestatic |
Converts the specified float to its string representation.
value | the float. |
|
inlinestatic |
Converts the specified integer to its string representation.
value | the integer. |
|
inlinestatic |
Converts the specified long to its string representation.
value | the long. |
Converts the specified object to its string representation. If the object is null return the string
, otherwise use
to get the string representation.
value | the object. |
|
inlinestatic |
Converts the specified boolean to its string representation. When the boolean is
return
, otherwise return
.
value | the boolean. |