public final class String extends Object implements Comparable<String>, CharSequence, Serializable
Modifier and Type | Field and Description |
---|---|
static Comparator<String> |
CASE_INSENSITIVE_ORDER |
Constructor and Description |
---|
String() |
String(byte[] bytes) |
String(byte[] bytes,
int ofs,
int len) |
String(byte[] bytes,
int ofs,
int len,
String charsetName) |
String(byte[] bytes,
String charsetName) |
String(char[] value) |
String(char[] value,
int offset,
int count) |
String(int[] codePoints,
int offset,
int count) |
String(String other) |
String(StringBuffer sb) |
String(StringBuilder sb) |
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index) |
int |
codePointAt(int index) |
int |
codePointBefore(int index) |
int |
codePointCount(int beginIndex,
int endIndex) |
int |
compareTo(String other) |
int |
compareToIgnoreCase(String other) |
String |
concat(String str) |
boolean |
contains(CharSequence s) |
boolean |
contentEquals(CharSequence cs) |
boolean |
contentEquals(StringBuffer sb) |
static String |
copyValueOf(char[] v) |
static String |
copyValueOf(char[] v,
int offset,
int count) |
boolean |
endsWith(String suffix) |
boolean |
equals(Object other) |
boolean |
equalsIgnoreCase(String other) |
byte[] |
getBytes() |
byte[] |
getBytes(String charSet) |
void |
getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin) |
Class<? extends Object> |
getClass()
Magic; JSODevirtualizer will use this implementation.
|
int |
hashCode() |
int |
indexOf(int codePoint) |
int |
indexOf(int codePoint,
int startIndex) |
int |
indexOf(String str) |
int |
indexOf(String str,
int startIndex) |
String |
intern() |
boolean |
isEmpty() |
int |
lastIndexOf(int codePoint) |
int |
lastIndexOf(int codePoint,
int startIndex) |
int |
lastIndexOf(String str) |
int |
lastIndexOf(String str,
int start) |
int |
length() |
boolean |
matches(String regex)
Regular expressions vary from the standard implementation.
|
int |
offsetByCodePoints(int index,
int codePointOffset) |
boolean |
regionMatches(boolean ignoreCase,
int toffset,
String other,
int ooffset,
int len) |
boolean |
regionMatches(int toffset,
String other,
int ooffset,
int len) |
String |
replace(char from,
char to) |
String |
replace(CharSequence from,
CharSequence to) |
String |
replaceAll(String regex,
String replace)
Regular expressions vary from the standard implementation.
|
String |
replaceFirst(String regex,
String replace)
Regular expressions vary from the standard implementation.
|
String[] |
split(String regex)
Regular expressions vary from the standard implementation.
|
String[] |
split(String regex,
int maxMatch)
Regular expressions vary from the standard implementation.
|
boolean |
startsWith(String prefix) |
boolean |
startsWith(String prefix,
int toffset) |
CharSequence |
subSequence(int beginIndex,
int endIndex) |
String |
substring(int beginIndex) |
String |
substring(int beginIndex,
int endIndex) |
char[] |
toCharArray() |
String |
toLowerCase()
Transforms the String to lower-case in a locale insensitive way.
|
String |
toLowerCase(Locale locale)
If provided
locale is Locale.getDefault() , uses javascript's
toLocaleLowerCase to do a locale specific transformation. |
String |
toString() |
String |
toUpperCase() |
String |
toUpperCase(Locale locale) |
String |
trim() |
static String |
valueOf(boolean x) |
static String |
valueOf(char x) |
static String |
valueOf(char[] x) |
static String |
valueOf(char[] x,
int offset,
int count) |
static String |
valueOf(double x) |
static String |
valueOf(float x) |
static String |
valueOf(int x) |
static String |
valueOf(long x) |
static String |
valueOf(Object x) |
public static final Comparator<String> CASE_INSENSITIVE_ORDER
public String()
public String(byte[] bytes)
public String(byte[] bytes, int ofs, int len)
public String(byte[] bytes, int ofs, int len, String charsetName) throws UnsupportedEncodingException
UnsupportedEncodingException
public String(byte[] bytes, String charsetName) throws UnsupportedEncodingException
UnsupportedEncodingException
public String(char[] value)
public String(char[] value, int offset, int count)
public String(int[] codePoints, int offset, int count)
public String(String other)
public String(StringBuffer sb)
public String(StringBuilder sb)
public static String copyValueOf(char[] v)
public static String copyValueOf(char[] v, int offset, int count)
public static String valueOf(boolean x)
public static String valueOf(char x)
public static String valueOf(char[] x, int offset, int count)
public static String valueOf(char[] x)
public static String valueOf(double x)
public static String valueOf(float x)
public static String valueOf(int x)
public static String valueOf(long x)
public char charAt(int index)
charAt
in interface CharSequence
public int codePointAt(int index)
public int codePointBefore(int index)
public int codePointCount(int beginIndex, int endIndex)
public int compareTo(String other)
compareTo
in interface Comparable<String>
public int compareToIgnoreCase(String other)
public boolean contains(CharSequence s)
public boolean contentEquals(CharSequence cs)
public boolean contentEquals(StringBuffer sb)
public boolean endsWith(String suffix)
public boolean equalsIgnoreCase(String other)
public byte[] getBytes()
public byte[] getBytes(String charSet) throws UnsupportedEncodingException
UnsupportedEncodingException
public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
public Class<? extends Object> getClass()
Each class gets a synthetic stubs for getClass at AST construction time with the exception of
Object, JavaScriptObject and subclasses and String; see GwtAstBuilder.createMembers()
.
These stubs are replaced in ReplaceGetClassOverrides
by an access to field __clazz
which is initialized in each class prototype to point to the class literal. String is
implemented as a plain JavaScript string hence lacking said field.
The devirtualizer JsoDevirtualizer
will insert a trampoline that uses this
implementation.
public int indexOf(int codePoint)
public int indexOf(int codePoint, int startIndex)
public int indexOf(String str)
public int indexOf(String str, int startIndex)
public String intern()
public boolean isEmpty()
public int lastIndexOf(int codePoint)
public int lastIndexOf(int codePoint, int startIndex)
public int lastIndexOf(String str)
public int lastIndexOf(String str, int start)
public int length()
length
in interface CharSequence
public boolean matches(String regex)
regex
parameter is interpreted by JavaScript as a JavaScript
regular expression. For consistency, use only the subset of regular
expression syntax common to both Java and JavaScript.
TODO(jat): properly handle Java regex syntaxpublic int offsetByCodePoints(int index, int codePointOffset)
public boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len)
public boolean regionMatches(int toffset, String other, int ooffset, int len)
public String replace(char from, char to)
public String replace(CharSequence from, CharSequence to)
public String replaceAll(String regex, String replace)
regex
parameter is interpreted by JavaScript as a JavaScript
regular expression. For consistency, use only the subset of regular
expression syntax common to both Java and JavaScript.
TODO(jat): properly handle Java regex syntaxpublic String replaceFirst(String regex, String replace)
regex
parameter is interpreted by JavaScript as a JavaScript
regular expression. For consistency, use only the subset of regular
expression syntax common to both Java and JavaScript.
TODO(jat): properly handle Java regex syntaxpublic String[] split(String regex)
regex
parameter is interpreted by JavaScript as a JavaScript
regular expression. For consistency, use only the subset of regular
expression syntax common to both Java and JavaScript.public String[] split(String regex, int maxMatch)
regex
parameter is interpreted by JavaScript as a JavaScript
regular expression. For consistency, use only the subset of regular
expression syntax common to both Java and JavaScript.
TODO(jat): properly handle Java regex syntaxpublic boolean startsWith(String prefix)
public boolean startsWith(String prefix, int toffset)
public CharSequence subSequence(int beginIndex, int endIndex)
subSequence
in interface CharSequence
public String substring(int beginIndex)
public String substring(int beginIndex, int endIndex)
public char[] toCharArray()
public String toLowerCase()
Unlike JRE, we don't do locale specific transformation by default. That is backward compatible
for GWT and in most of the cases that is what the developer actually wants. If you want to make
a transformation based on native locale of the browser, you can do
toLowerCase(Locale.getDefault())
instead.
public String toLowerCase(Locale locale)
locale
is Locale.getDefault()
, uses javascript's
toLocaleLowerCase
to do a locale specific transformation. Otherwise, it will fallback
to toLowerCase
which performs the right thing for the limited set of Locale's
predefined in GWT Locale emulation.public String toUpperCase()
public String toString()
toString
in interface CharSequence
toString
in class Object
public String trim()
Copyright © 2018. All rights reserved.