Implement AtomicBoolean and String.toLowerCase/toUpperCase(Locale)

This commit is contained in:
Alexey Andreev 2017-11-02 20:26:02 +03:00
parent 6d5b4a67e5
commit 389b55be91
2 changed files with 75 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import org.teavm.classlib.java.util.TArrays;
import org.teavm.classlib.java.util.TComparator; import org.teavm.classlib.java.util.TComparator;
import org.teavm.classlib.java.util.TFormatter; import org.teavm.classlib.java.util.TFormatter;
import org.teavm.classlib.java.util.THashMap; import org.teavm.classlib.java.util.THashMap;
import org.teavm.classlib.java.util.TLocale;
import org.teavm.classlib.java.util.TMap; import org.teavm.classlib.java.util.TMap;
import org.teavm.classlib.java.util.regex.TPattern; import org.teavm.classlib.java.util.regex.TPattern;
@ -597,6 +598,10 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
return new TString(codePoints, 0, codePointCount); return new TString(codePoints, 0, codePointCount);
} }
public TString toLowerCase(TLocale locale) {
return toLowerCase();
}
public TString toUpperCase() { public TString toUpperCase() {
if (isEmpty()) { if (isEmpty()) {
return this; return this;
@ -616,6 +621,10 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
return new TString(codePoints, 0, codePointCount); return new TString(codePoints, 0, codePointCount);
} }
public TString toUpperCase(TLocale locale) {
return toUpperCase();
}
public TString intern() { public TString intern() {
TString interned = pool.get(this); TString interned = pool.get(this);
if (interned == null) { if (interned == null) {

View File

@ -0,0 +1,66 @@
/*
* Copyright 2017 Alexey Andreev.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.teavm.classlib.java.util.concurrent.atomic;
import java.io.Serializable;
public class TAtomicBoolean implements Serializable {
private boolean value;
public TAtomicBoolean(boolean initialValue) {
value = initialValue;
}
public TAtomicBoolean() {
this(false);
}
public final boolean get() {
return value;
}
public final boolean compareAndSet(boolean expect, boolean update) {
if (value == expect) {
value = update;
return true;
} else {
return false;
}
}
public boolean weakCompareAndSet(boolean expect, boolean update) {
return compareAndSet(expect, update);
}
public final void set(boolean newValue) {
value = newValue;
}
public final void lazySet(boolean newValue) {
value = newValue;
}
public final boolean getAndSet(boolean newValue) {
boolean result = value;
value = newValue;
return result;
}
@Override
public String toString() {
return Boolean.toString(value);
}
}