mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-23 00:24:11 -08:00
Add some methods to String
This commit is contained in:
parent
c47689dc30
commit
e1d5b45750
|
@ -162,6 +162,18 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean contentEquals(TStringBuffer buffer) {
|
||||||
|
if (characters.length != buffer.length()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < characters.length; ++i) {
|
||||||
|
if (characters[i] != buffer.charAt(i)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean contentEquals(TCharSequence charSeq) {
|
public boolean contentEquals(TCharSequence charSeq) {
|
||||||
if (this == charSeq) {
|
if (this == charSeq) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -227,6 +239,24 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
|
||||||
return startsWith(prefix, 0);
|
return startsWith(prefix, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) {
|
||||||
|
if (toffset < 0 || ooffset < 0 || toffset + len > length() || ooffset + len > other.length()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
char a = charAt(toffset++);
|
||||||
|
char b = other.charAt(ooffset++);
|
||||||
|
if (ignoreCase) {
|
||||||
|
a = TCharacter.toLowerCase(a);
|
||||||
|
b = TCharacter.toLowerCase(b);
|
||||||
|
}
|
||||||
|
if (a != b) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean regionMatches(int toffset, TString other, int ooffset, int len) {
|
public boolean regionMatches(int toffset, TString other, int ooffset, int len) {
|
||||||
if (toffset < 0 || ooffset < 0 || toffset + len > length() || ooffset + len > other.length()) {
|
if (toffset < 0 || ooffset < 0 || toffset + len > length() || ooffset + len > other.length()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -626,4 +656,12 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
|
||||||
public String[] split(String regex, int limit) {
|
public String[] split(String regex, int limit) {
|
||||||
return TPattern.compile(regex).split(this.toString(), limit);
|
return TPattern.compile(regex).split(this.toString(), limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String replaceAll(String regex, String replacement) {
|
||||||
|
return TPattern.compile(regex).matcher(toString()).replaceAll(replacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String replaceFirst(String regex, String replacement) {
|
||||||
|
return TPattern.compile(regex).matcher(toString()).replaceFirst(replacement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user