diff options
author | Narayan Kamath <narayan@google.com> | 2015-04-22 14:07:02 +0100 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2015-04-22 13:50:01 +0000 |
commit | 3f7c674bd1d220d1a8c149b5658145171c28094f (patch) | |
tree | 1fe9d19690461a1c7d6a5fe0967f7b9fcc29da08 | |
parent | 298bf64cb09d9e11f99aeda8a7a0a1f709ec91f9 (diff) | |
download | libcore-3f7c674bd1d220d1a8c149b5658145171c28094f.zip libcore-3f7c674bd1d220d1a8c149b5658145171c28094f.tar.gz libcore-3f7c674bd1d220d1a8c149b5658145171c28094f.tar.bz2 |
Move java.nio.Charsets to libcore.util.
This isn't public API, and isn't related to NIO. It's only ever
used by java.lang.String.
bug: 10898787
Change-Id: I4e194406746b88ba7268c2553e467e7e05400b40
-rw-r--r-- | libart/src/main/java/java/lang/String.java | 14 | ||||
-rw-r--r-- | luni/src/main/java/libcore/util/CharsetUtils.java (renamed from luni/src/main/java/java/nio/charset/Charsets.java) | 6 | ||||
-rw-r--r-- | luni/src/main/native/Register.cpp | 2 | ||||
-rw-r--r-- | luni/src/main/native/libcore_util_CharsetUtils.cpp (renamed from luni/src/main/native/java_nio_charset_Charsets.cpp) | 4 | ||||
-rw-r--r-- | luni/src/main/native/sub.mk | 2 |
5 files changed, 14 insertions, 14 deletions
diff --git a/libart/src/main/java/java/lang/String.java b/libart/src/main/java/java/lang/String.java index 0107b6e..a5bf34c 100644 --- a/libart/src/main/java/java/lang/String.java +++ b/libart/src/main/java/java/lang/String.java @@ -22,12 +22,12 @@ import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; -import java.nio.charset.Charsets; import java.util.Arrays; import java.util.Comparator; import java.util.Formatter; import java.util.Locale; import java.util.regex.Pattern; +import libcore.util.CharsetUtils; import libcore.util.EmptyArray; /** @@ -337,12 +337,12 @@ outer: this.offset = 0; this.value = new char[byteCount]; this.count = byteCount; - Charsets.isoLatin1BytesToChars(data, offset, byteCount, value); + CharsetUtils.isoLatin1BytesToChars(data, offset, byteCount, value); } else if (canonicalCharsetName.equals("US-ASCII")) { this.offset = 0; this.value = new char[byteCount]; this.count = byteCount; - Charsets.asciiBytesToChars(data, offset, byteCount, value); + CharsetUtils.asciiBytesToChars(data, offset, byteCount, value); } else { CharBuffer cb = charset.decode(ByteBuffer.wrap(data, offset, byteCount)); this.offset = 0; @@ -772,13 +772,13 @@ outer: public byte[] getBytes(Charset charset) { String canonicalCharsetName = charset.name(); if (canonicalCharsetName.equals("UTF-8")) { - return Charsets.toUtf8Bytes(value, offset, count); + return CharsetUtils.toUtf8Bytes(value, offset, count); } else if (canonicalCharsetName.equals("ISO-8859-1")) { - return Charsets.toIsoLatin1Bytes(value, offset, count); + return CharsetUtils.toIsoLatin1Bytes(value, offset, count); } else if (canonicalCharsetName.equals("US-ASCII")) { - return Charsets.toAsciiBytes(value, offset, count); + return CharsetUtils.toAsciiBytes(value, offset, count); } else if (canonicalCharsetName.equals("UTF-16BE")) { - return Charsets.toBigEndianUtf16Bytes(value, offset, count); + return CharsetUtils.toBigEndianUtf16Bytes(value, offset, count); } else { CharBuffer chars = CharBuffer.wrap(this.value, this.offset, this.count); ByteBuffer buffer = charset.encode(chars.asReadOnlyBuffer()); diff --git a/luni/src/main/java/java/nio/charset/Charsets.java b/luni/src/main/java/libcore/util/CharsetUtils.java index 3dede7a..2e426c4 100644 --- a/luni/src/main/java/java/nio/charset/Charsets.java +++ b/luni/src/main/java/libcore/util/CharsetUtils.java @@ -14,14 +14,14 @@ * limitations under the License. */ -package java.nio.charset; +package libcore.util; /** * Various special-case charset conversions (for performance). * * @hide internal use only */ -public final class Charsets { +public final class CharsetUtils { /** * Returns a new byte array containing the bytes corresponding to the given characters, * encoded in US-ASCII. Unrepresentable characters are replaced by (byte) '?'. @@ -75,6 +75,6 @@ public final class Charsets { */ public static native void isoLatin1BytesToChars(byte[] bytes, int offset, int length, char[] chars); - private Charsets() { + private CharsetUtils() { } } diff --git a/luni/src/main/native/Register.cpp b/luni/src/main/native/Register.cpp index 035b1d9..0f2d0ad 100644 --- a/luni/src/main/native/Register.cpp +++ b/luni/src/main/native/Register.cpp @@ -48,7 +48,6 @@ jint JNI_OnLoad(JavaVM* vm, void*) { REGISTER(register_java_lang_System); REGISTER(register_java_math_NativeBN); REGISTER(register_java_nio_ByteOrder); - REGISTER(register_java_nio_charset_Charsets); REGISTER(register_java_text_Bidi); REGISTER(register_java_util_jar_StrictJarFile); REGISTER(register_java_util_regex_Matcher); @@ -70,6 +69,7 @@ jint JNI_OnLoad(JavaVM* vm, void*) { REGISTER(register_libcore_io_AsynchronousCloseMonitor); REGISTER(register_libcore_io_Memory); REGISTER(register_libcore_io_Posix); + REGISTER(register_libcore_util_CharsetUtils); REGISTER(register_org_apache_harmony_dalvik_NativeTestTarget); REGISTER(register_org_apache_harmony_xml_ExpatParser); REGISTER(register_sun_misc_Unsafe); diff --git a/luni/src/main/native/java_nio_charset_Charsets.cpp b/luni/src/main/native/libcore_util_CharsetUtils.cpp index a49ba22..57c8172 100644 --- a/luni/src/main/native/java_nio_charset_Charsets.cpp +++ b/luni/src/main/native/libcore_util_CharsetUtils.cpp @@ -245,6 +245,6 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(Charsets, toIsoLatin1Bytes, "([CII)[B"), NATIVE_METHOD(Charsets, toUtf8Bytes, "([CII)[B"), }; -void register_java_nio_charset_Charsets(JNIEnv* env) { - jniRegisterNativeMethods(env, "java/nio/charset/Charsets", gMethods, NELEM(gMethods)); +void register_libcore_util_CharsetUtils(JNIEnv* env) { + jniRegisterNativeMethods(env, "libcore/util/CharsetUtils", gMethods, NELEM(gMethods)); } diff --git a/luni/src/main/native/sub.mk b/luni/src/main/native/sub.mk index 2bc44ed..a90c683 100644 --- a/luni/src/main/native/sub.mk +++ b/luni/src/main/native/sub.mk @@ -28,7 +28,6 @@ LOCAL_SRC_FILES := \ java_lang_System.cpp \ java_math_NativeBN.cpp \ java_nio_ByteOrder.cpp \ - java_nio_charset_Charsets.cpp \ java_text_Bidi.cpp \ java_util_jar_StrictJarFile.cpp \ java_util_regex_Matcher.cpp \ @@ -50,6 +49,7 @@ LOCAL_SRC_FILES := \ libcore_io_AsynchronousCloseMonitor.cpp \ libcore_io_Memory.cpp \ libcore_io_Posix.cpp \ + libcore_util_CharsetUtils.cpp \ org_apache_harmony_xml_ExpatParser.cpp \ readlink.cpp \ sun_misc_Unsafe.cpp \ |