summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-06-28 15:57:53 -0700
committerElliott Hughes <enh@google.com>2013-06-28 16:16:41 -0700
commit2a6f23ff8690ac2f025588a360547ce96cde0943 (patch)
tree7f16e717fa0aa11fd704d683525b969bd6055f23
parent52ac40530506afe4c5a85d370e04ee77e523b1fa (diff)
downloadlibcore-2a6f23ff8690ac2f025588a360547ce96cde0943.zip
libcore-2a6f23ff8690ac2f025588a360547ce96cde0943.tar.gz
libcore-2a6f23ff8690ac2f025588a360547ce96cde0943.tar.bz2
Add java.nio.charsets.StandardCharsets.
Bug: 3484927 Change-Id: I5820267491b850b8fcc696fa48962710de123009
-rw-r--r--dalvik/src/main/java/dalvik/system/BlockGuard.java1
-rw-r--r--luni/src/main/java/java/net/InetUnixAddress.java6
-rw-r--r--luni/src/main/java/java/net/Socks4Message.java6
-rw-r--r--luni/src/main/java/java/net/URLClassLoader.java4
-rw-r--r--luni/src/main/java/java/net/URLEncoder.java4
-rw-r--r--luni/src/main/java/java/nio/charset/StandardCharsets.java56
-rw-r--r--luni/src/main/java/java/util/ResourceBundle.java5
-rw-r--r--luni/src/main/java/java/util/jar/InitManifest.java6
-rw-r--r--luni/src/main/java/java/util/jar/JarVerifier.java6
-rw-r--r--luni/src/main/java/java/util/jar/Manifest.java6
-rw-r--r--luni/src/main/java/java/util/prefs/AbstractPreferences.java4
-rw-r--r--luni/src/main/java/java/util/zip/ZipEntry.java8
-rw-r--r--luni/src/main/java/java/util/zip/ZipOutputStream.java8
-rw-r--r--luni/src/main/java/libcore/io/Base64.java4
-rw-r--r--luni/src/main/java/libcore/io/IoUtils.java4
-rw-r--r--luni/src/main/java/libcore/io/StrictLineReader.java9
-rw-r--r--luni/src/main/java/libcore/net/UriCodec.java8
-rw-r--r--luni/src/main/java/libcore/net/url/FtpURLConnection.java6
-rw-r--r--luni/src/main/java/libcore/util/ZoneInfoDB.java8
-rw-r--r--luni/src/main/java/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java4
-rw-r--r--luni/src/main/java/org/apache/harmony/security/asn1/ASN1StringType.java10
-rw-r--r--luni/src/main/java/org/apache/harmony/security/asn1/ASN1UTCTime.java4
-rw-r--r--luni/src/main/java/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java8
-rw-r--r--luni/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java4
-rw-r--r--luni/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java4
-rw-r--r--luni/src/test/java/libcore/io/StrictLineReaderTest.java5
-rw-r--r--luni/src/test/java/libcore/javax/net/ssl/DefaultHostnameVerifierTest.java4
27 files changed, 127 insertions, 75 deletions
diff --git a/dalvik/src/main/java/dalvik/system/BlockGuard.java b/dalvik/src/main/java/dalvik/system/BlockGuard.java
index d61f0e1..b9de236 100644
--- a/dalvik/src/main/java/dalvik/system/BlockGuard.java
+++ b/dalvik/src/main/java/dalvik/system/BlockGuard.java
@@ -22,7 +22,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.net.SocketException;
-import java.nio.charset.Charsets;
/**
* Mechanism to let threads set restrictions on what code is allowed
diff --git a/luni/src/main/java/java/net/InetUnixAddress.java b/luni/src/main/java/java/net/InetUnixAddress.java
index 95bb097..44b9cba 100644
--- a/luni/src/main/java/java/net/InetUnixAddress.java
+++ b/luni/src/main/java/java/net/InetUnixAddress.java
@@ -16,7 +16,7 @@
package java.net;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import static libcore.io.OsConstants.*;
@@ -29,7 +29,7 @@ public final class InetUnixAddress extends InetAddress {
* Constructs an AF_UNIX InetAddress for the given path.
*/
public InetUnixAddress(String path) {
- this(path.getBytes(Charsets.UTF_8));
+ this(path.getBytes(StandardCharsets.UTF_8));
}
/**
@@ -43,6 +43,6 @@ public final class InetUnixAddress extends InetAddress {
* Returns a string form of this InetAddress.
*/
@Override public String toString() {
- return "InetUnixAddress[" + new String(ipaddress, Charsets.UTF_8) + "]";
+ return "InetUnixAddress[" + new String(ipaddress, StandardCharsets.UTF_8) + "]";
}
}
diff --git a/luni/src/main/java/java/net/Socks4Message.java b/luni/src/main/java/java/net/Socks4Message.java
index c193520..f7b190d 100644
--- a/luni/src/main/java/java/net/Socks4Message.java
+++ b/luni/src/main/java/java/net/Socks4Message.java
@@ -18,7 +18,7 @@
package java.net;
import java.nio.ByteOrder;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import libcore.io.Memory;
class Socks4Message {
@@ -188,7 +188,7 @@ class Socks4Message {
while (index < lastIndex && (buffer[index] != 0)) {
index++;
}
- return new String(buffer, offset, index - offset, Charsets.ISO_8859_1);
+ return new String(buffer, offset, index - offset, StandardCharsets.ISO_8859_1);
}
/**
@@ -202,7 +202,7 @@ class Socks4Message {
* Put a string into the buffer at the offset given.
*/
private void setString(int offset, int maxLength, String theString) {
- byte[] stringBytes = theString.getBytes(Charsets.ISO_8859_1);
+ byte[] stringBytes = theString.getBytes(StandardCharsets.ISO_8859_1);
int length = Math.min(stringBytes.length, maxLength);
System.arraycopy(stringBytes, 0, buffer, offset, length);
buffer[offset + length] = 0;
diff --git a/luni/src/main/java/java/net/URLClassLoader.java b/luni/src/main/java/java/net/URLClassLoader.java
index efb7531..88d2e25 100644
--- a/luni/src/main/java/java/net/URLClassLoader.java
+++ b/luni/src/main/java/java/net/URLClassLoader.java
@@ -26,7 +26,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.security.CodeSource;
import java.security.PermissionCollection;
import java.security.SecureClassLoader;
@@ -76,7 +76,7 @@ public class URLClassLoader extends SecureClassLoader {
String parentURLString = getParentURL(url).toExternalForm();
String prefix = "jar:" + parentURLString + "/";
is = jf.getInputStream(indexEntry);
- in = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
+ in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
HashMap<String, ArrayList<URL>> pre_map = new HashMap<String, ArrayList<URL>>();
// Ignore the 2 first lines (index version)
if (in.readLine() == null) return null;
diff --git a/luni/src/main/java/java/net/URLEncoder.java b/luni/src/main/java/java/net/URLEncoder.java
index 527c017..0f94907 100644
--- a/luni/src/main/java/java/net/URLEncoder.java
+++ b/luni/src/main/java/java/net/URLEncoder.java
@@ -19,7 +19,7 @@ package java.net;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import libcore.net.UriCodec;
/**
@@ -47,7 +47,7 @@ public class URLEncoder {
*/
@Deprecated
public static String encode(String s) {
- return ENCODER.encode(s, Charsets.UTF_8);
+ return ENCODER.encode(s, StandardCharsets.UTF_8);
}
/**
diff --git a/luni/src/main/java/java/nio/charset/StandardCharsets.java b/luni/src/main/java/java/nio/charset/StandardCharsets.java
new file mode 100644
index 0000000..66fa9f6
--- /dev/null
+++ b/luni/src/main/java/java/nio/charset/StandardCharsets.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * 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 java.nio.charset;
+
+/**
+ * Convenient access to the most important built-in charsets.
+ * @since 1.7
+ */
+public final class StandardCharsets {
+ private StandardCharsets() {
+ }
+
+ /**
+ * The ISO-8859-1 charset.
+ */
+ public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
+
+ /**
+ * The US-ASCII charset.
+ */
+ public static final Charset US_ASCII = Charset.forName("US-ASCII");
+
+ /**
+ * The UTF-8 charset.
+ */
+ public static final Charset UTF_8 = Charset.forName("UTF-8");
+
+ /**
+ * The UTF-16 charset.
+ */
+ public static final Charset UTF_16 = Charset.forName("UTF-16");
+
+ /**
+ * The UTF-16BE (big-endian) charset.
+ */
+ public static final Charset UTF_16BE = Charset.forName("UTF-16BE");
+
+ /**
+ * The UTF-16LE (little-endian) charset.
+ */
+ public static final Charset UTF_16LE = Charset.forName("UTF-16LE");
+}
diff --git a/luni/src/main/java/java/util/ResourceBundle.java b/luni/src/main/java/java/util/ResourceBundle.java
index f5c8285..a9c5824 100644
--- a/luni/src/main/java/java/util/ResourceBundle.java
+++ b/luni/src/main/java/java/util/ResourceBundle.java
@@ -24,8 +24,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
-import java.nio.charset.Charsets;
-import static java.nio.charset.Charsets.UTF_8;
+import java.nio.charset.StandardCharsets;
import libcore.io.IoUtils;
/**
@@ -518,7 +517,7 @@ public abstract class ResourceBundle {
: ClassLoader.getSystemResourceAsStream(fileName);
if (stream != null) {
try {
- bundle = new PropertyResourceBundle(new InputStreamReader(stream, UTF_8));
+ bundle = new PropertyResourceBundle(new InputStreamReader(stream, StandardCharsets.UTF_8));
bundle.setLocale(locale);
} catch (IOException ignored) {
} finally {
diff --git a/luni/src/main/java/java/util/jar/InitManifest.java b/luni/src/main/java/java/util/jar/InitManifest.java
index ade4790..07efd96 100644
--- a/luni/src/main/java/java/util/jar/InitManifest.java
+++ b/luni/src/main/java/java/util/jar/InitManifest.java
@@ -18,7 +18,7 @@
package java.util.jar;
import java.io.IOException;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
@@ -110,7 +110,7 @@ class InitManifest {
continue;
}
- String name = new String(buf, mark, pos - mark - 1, Charsets.US_ASCII);
+ String name = new String(buf, mark, pos - mark - 1, StandardCharsets.US_ASCII);
if (buf[pos++] != ' ') {
throw new IOException(String.format("Invalid value for attribute '%s'", name));
@@ -164,6 +164,6 @@ class InitManifest {
}
valueBuffer.write(buf, mark, last - mark);
- value = valueBuffer.toString(Charsets.UTF_8);
+ value = valueBuffer.toString(StandardCharsets.UTF_8);
}
}
diff --git a/luni/src/main/java/java/util/jar/JarVerifier.java b/luni/src/main/java/java/util/jar/JarVerifier.java
index 187b229..bb46fd4 100644
--- a/luni/src/main/java/java/util/jar/JarVerifier.java
+++ b/luni/src/main/java/java/util/jar/JarVerifier.java
@@ -20,7 +20,7 @@ package java.util.jar;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -206,7 +206,7 @@ class JarVerifier {
if (hash == null) {
continue;
}
- byte[] hashBytes = hash.getBytes(Charsets.ISO_8859_1);
+ byte[] hashBytes = hash.getBytes(StandardCharsets.ISO_8859_1);
try {
return new VerifierEntry(name, MessageDigest.getInstance(algorithm), hashBytes,
@@ -408,7 +408,7 @@ class JarVerifier {
md.update(data, start, end - start);
}
byte[] b = md.digest();
- byte[] hashBytes = hash.getBytes(Charsets.ISO_8859_1);
+ byte[] hashBytes = hash.getBytes(StandardCharsets.ISO_8859_1);
return MessageDigest.isEqual(b, Base64.decode(hashBytes));
}
return ignorable;
diff --git a/luni/src/main/java/java/util/jar/Manifest.java b/luni/src/main/java/java/util/jar/Manifest.java
index 723aa99..da1e707 100644
--- a/luni/src/main/java/java/util/jar/Manifest.java
+++ b/luni/src/main/java/java/util/jar/Manifest.java
@@ -25,8 +25,8 @@ import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharsetEncoder;
-import java.nio.charset.Charsets;
import java.nio.charset.CoderResult;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -302,7 +302,7 @@ public class Manifest implements Cloneable {
* If an error occurs writing the {@code Manifest}.
*/
static void write(Manifest manifest, OutputStream out) throws IOException {
- CharsetEncoder encoder = Charsets.UTF_8.newEncoder();
+ CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder();
ByteBuffer buffer = ByteBuffer.allocate(LINE_LENGTH_LIMIT);
Attributes.Name versionName = Attributes.Name.MANIFEST_VERSION;
@@ -339,7 +339,7 @@ public class Manifest implements Cloneable {
private static void writeEntry(OutputStream os, Attributes.Name name,
String value, CharsetEncoder encoder, ByteBuffer bBuf) throws IOException {
String nameString = name.getName();
- os.write(nameString.getBytes(Charsets.US_ASCII));
+ os.write(nameString.getBytes(StandardCharsets.US_ASCII));
os.write(VALUE_SEPARATOR);
encoder.reset();
diff --git a/luni/src/main/java/java/util/prefs/AbstractPreferences.java b/luni/src/main/java/java/util/prefs/AbstractPreferences.java
index 71110c3..d2cb28e 100644
--- a/luni/src/main/java/java/util/prefs/AbstractPreferences.java
+++ b/luni/src/main/java/java/util/prefs/AbstractPreferences.java
@@ -19,7 +19,7 @@ package java.util.prefs;
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.EventListener;
import java.util.EventObject;
@@ -441,7 +441,7 @@ public abstract class AbstractPreferences extends Preferences {
return EmptyArray.BYTE;
}
try {
- byte[] bavalue = svalue.getBytes(Charsets.US_ASCII);
+ byte[] bavalue = svalue.getBytes(StandardCharsets.US_ASCII);
if (bavalue.length % 4 != 0) {
return deflt;
}
diff --git a/luni/src/main/java/java/util/zip/ZipEntry.java b/luni/src/main/java/java/util/zip/ZipEntry.java
index 91485e7..1be00d8 100644
--- a/luni/src/main/java/java/util/zip/ZipEntry.java
+++ b/luni/src/main/java/java/util/zip/ZipEntry.java
@@ -20,7 +20,7 @@ package java.util.zip;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteOrder;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
@@ -184,7 +184,7 @@ public class ZipEntry implements ZipConstants, Cloneable {
return;
}
- byte[] commentBytes = comment.getBytes(Charsets.UTF_8);
+ byte[] commentBytes = comment.getBytes(StandardCharsets.UTF_8);
if (commentBytes.length > 0xffff) {
throw new IllegalArgumentException("Comment too long: " + commentBytes.length);
}
@@ -383,14 +383,14 @@ public class ZipEntry implements ZipConstants, Cloneable {
byte[] nameBytes = new byte[nameLength];
Streams.readFully(in, nameBytes, 0, nameBytes.length);
- name = new String(nameBytes, 0, nameBytes.length, Charsets.UTF_8);
+ name = new String(nameBytes, 0, nameBytes.length, StandardCharsets.UTF_8);
// The RI has always assumed UTF-8. (If GPBF_UTF8_FLAG isn't set, the encoding is
// actually IBM-437.)
if (commentByteCount > 0) {
byte[] commentBytes = new byte[commentByteCount];
Streams.readFully(in, commentBytes, 0, commentByteCount);
- comment = new String(commentBytes, 0, commentBytes.length, Charsets.UTF_8);
+ comment = new String(commentBytes, 0, commentBytes.length, StandardCharsets.UTF_8);
}
if (extraLength > 0) {
diff --git a/luni/src/main/java/java/util/zip/ZipOutputStream.java b/luni/src/main/java/java/util/zip/ZipOutputStream.java
index 59849d3..7f51751 100644
--- a/luni/src/main/java/java/util/zip/ZipOutputStream.java
+++ b/luni/src/main/java/java/util/zip/ZipOutputStream.java
@@ -20,7 +20,7 @@ package java.util.zip;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashSet;
import libcore.util.EmptyArray;
@@ -182,7 +182,7 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
String comment = currentEntry.getComment();
byte[] commentBytes = EmptyArray.BYTE;
if (comment != null) {
- commentBytes = comment.getBytes(Charsets.UTF_8);
+ commentBytes = comment.getBytes(StandardCharsets.UTF_8);
}
writeShort(cDir, commentBytes.length); // Comment length.
writeShort(cDir, 0); // Disk Start
@@ -294,7 +294,7 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
// TODO: support Zip64.
throw new ZipException("Too many entries for the zip file format's 16-bit entry count");
}
- nameBytes = ze.name.getBytes(Charsets.UTF_8);
+ nameBytes = ze.name.getBytes(StandardCharsets.UTF_8);
nameLength = nameBytes.length;
if (nameLength > 0xffff) {
throw new IllegalArgumentException("Name too long: " + nameLength + " UTF-8 bytes");
@@ -353,7 +353,7 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
return;
}
- byte[] newCommentBytes = comment.getBytes(Charsets.UTF_8);
+ byte[] newCommentBytes = comment.getBytes(StandardCharsets.UTF_8);
if (newCommentBytes.length > 0xffff) {
throw new IllegalArgumentException("Comment too long: " + newCommentBytes.length + " bytes");
}
diff --git a/luni/src/main/java/libcore/io/Base64.java b/luni/src/main/java/libcore/io/Base64.java
index e4643b5..00b0251 100644
--- a/luni/src/main/java/libcore/io/Base64.java
+++ b/luni/src/main/java/libcore/io/Base64.java
@@ -21,7 +21,7 @@
package libcore.io;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import libcore.util.EmptyArray;
/**
@@ -156,6 +156,6 @@ public final class Base64 {
out[index++] = '=';
break;
}
- return new String(out, 0, index, Charsets.US_ASCII);
+ return new String(out, 0, index, StandardCharsets.US_ASCII);
}
}
diff --git a/luni/src/main/java/libcore/io/IoUtils.java b/luni/src/main/java/libcore/io/IoUtils.java
index c0c9e7e..f7cc41f 100644
--- a/luni/src/main/java/libcore/io/IoUtils.java
+++ b/luni/src/main/java/libcore/io/IoUtils.java
@@ -22,7 +22,7 @@ import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.RandomAccessFile;
import java.net.Socket;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.util.Random;
import static libcore.io.OsConstants.*;
@@ -110,7 +110,7 @@ public final class IoUtils {
* Returns the contents of 'path' as a string. The contents are assumed to be UTF-8.
*/
public static String readFileAsString(String path) throws IOException {
- return readFileAsBytes(path).toString(Charsets.UTF_8);
+ return readFileAsBytes(path).toString(StandardCharsets.UTF_8);
}
private static UnsafeByteSequence readFileAsBytes(String path) throws IOException {
diff --git a/luni/src/main/java/libcore/io/StrictLineReader.java b/luni/src/main/java/libcore/io/StrictLineReader.java
index 36556a0..a2e55cc 100644
--- a/luni/src/main/java/libcore/io/StrictLineReader.java
+++ b/luni/src/main/java/libcore/io/StrictLineReader.java
@@ -22,7 +22,7 @@ import java.io.EOFException;
import java.io.InputStream;
import java.io.IOException;
import java.nio.charset.Charset;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
/**
* Buffers input from an {@link InputStream} for reading lines.
@@ -78,7 +78,7 @@ public class StrictLineReader implements Closeable {
* @throws IllegalArgumentException for negative or zero {@code capacity}.
*/
public StrictLineReader(InputStream in, int capacity) {
- this(in, capacity, Charsets.US_ASCII);
+ this(in, capacity, StandardCharsets.US_ASCII);
}
/**
@@ -114,8 +114,8 @@ public class StrictLineReader implements Closeable {
if (capacity < 0) {
throw new IllegalArgumentException("capacity <= 0");
}
- if (!(charset.equals(Charsets.US_ASCII) || charset.equals(Charsets.UTF_8) ||
- charset.equals(Charsets.ISO_8859_1))) {
+ if (!(charset.equals(StandardCharsets.US_ASCII) || charset.equals(StandardCharsets.UTF_8) ||
+ charset.equals(StandardCharsets.ISO_8859_1))) {
throw new IllegalArgumentException("Unsupported encoding");
}
@@ -240,4 +240,3 @@ public class StrictLineReader implements Closeable {
end = result;
}
}
-
diff --git a/luni/src/main/java/libcore/net/UriCodec.java b/luni/src/main/java/libcore/net/UriCodec.java
index 3db95d0..dd18c5f 100644
--- a/luni/src/main/java/libcore/net/UriCodec.java
+++ b/luni/src/main/java/libcore/net/UriCodec.java
@@ -20,7 +20,7 @@ package libcore.net;
import java.io.ByteArrayOutputStream;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
/**
* Encodes and decodes {@code application/x-www-form-urlencoded} content.
@@ -135,11 +135,11 @@ public abstract class UriCodec {
}
public final void appendEncoded(StringBuilder builder, String s) {
- appendEncoded(builder, s, Charsets.UTF_8, false);
+ appendEncoded(builder, s, StandardCharsets.UTF_8, false);
}
public final void appendPartiallyEncoded(StringBuilder builder, String s) {
- appendEncoded(builder, s, Charsets.UTF_8, true);
+ appendEncoded(builder, s, StandardCharsets.UTF_8, true);
}
/**
@@ -203,7 +203,7 @@ public abstract class UriCodec {
}
public static String decode(String s) {
- return decode(s, false, Charsets.UTF_8, true);
+ return decode(s, false, StandardCharsets.UTF_8, true);
}
private static void appendHex(StringBuilder builder, String s, Charset charset) {
diff --git a/luni/src/main/java/libcore/net/url/FtpURLConnection.java b/luni/src/main/java/libcore/net/url/FtpURLConnection.java
index e168428..7594c3a 100644
--- a/luni/src/main/java/libcore/net/url/FtpURLConnection.java
+++ b/luni/src/main/java/libcore/net/url/FtpURLConnection.java
@@ -35,7 +35,7 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.security.Permission;
import java.util.ArrayList;
import java.util.Iterator;
@@ -350,7 +350,7 @@ public class FtpURLConnection extends URLConnection {
}
code[i] = (byte) tmp;
}
- replyCode = new String(code, 0, code.length, Charsets.ISO_8859_1);
+ replyCode = new String(code, 0, code.length, StandardCharsets.ISO_8859_1);
boolean multiline = false;
if (ctrlInput.read() == '-') {
@@ -497,6 +497,6 @@ public class FtpURLConnection extends URLConnection {
}
private void write(String command) throws IOException {
- ctrlOutput.write(command.getBytes(Charsets.ISO_8859_1));
+ ctrlOutput.write(command.getBytes(StandardCharsets.ISO_8859_1));
}
}
diff --git a/luni/src/main/java/libcore/util/ZoneInfoDB.java b/luni/src/main/java/libcore/util/ZoneInfoDB.java
index 7ffa647..10e3900 100644
--- a/luni/src/main/java/libcore/util/ZoneInfoDB.java
+++ b/luni/src/main/java/libcore/util/ZoneInfoDB.java
@@ -21,7 +21,7 @@ import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.FileChannel.MapMode;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -111,11 +111,11 @@ public final class ZoneInfoDB {
byte[] tzdata_version = new byte[12];
it.readByteArray(tzdata_version, 0, tzdata_version.length);
- String magic = new String(tzdata_version, 0, 6, Charsets.US_ASCII);
+ String magic = new String(tzdata_version, 0, 6, StandardCharsets.US_ASCII);
if (!magic.equals("tzdata") || tzdata_version[11] != 0) {
throw new RuntimeException("bad tzdata magic: " + Arrays.toString(tzdata_version));
}
- version = new String(tzdata_version, 6, 5, Charsets.US_ASCII);
+ version = new String(tzdata_version, 6, 5, StandardCharsets.US_ASCII);
int index_offset = it.readInt();
int data_offset = it.readInt();
@@ -129,7 +129,7 @@ public final class ZoneInfoDB {
byte[] bytes = new byte[zoneTabSize];
it.seek(zoneTabOffset);
it.readByteArray(bytes, 0, bytes.length);
- zoneTab = new String(bytes, 0, bytes.length, Charsets.US_ASCII);
+ zoneTab = new String(bytes, 0, bytes.length, StandardCharsets.US_ASCII);
}
private void readIndex(BufferIterator it, int indexOffset, int dataOffset) {
diff --git a/luni/src/main/java/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java b/luni/src/main/java/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java
index 64d7ced..26097cf 100644
--- a/luni/src/main/java/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java
+++ b/luni/src/main/java/org/apache/harmony/security/asn1/ASN1GeneralizedTime.java
@@ -23,7 +23,7 @@
package org.apache.harmony.security.asn1;
import java.io.IOException;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.TimeZone;
@@ -99,7 +99,7 @@ public final class ASN1GeneralizedTime extends ASN1Time {
temp = temp.substring(0, currLength);
}
- out.content = (temp + "Z").getBytes(Charsets.UTF_8);
+ out.content = (temp + "Z").getBytes(StandardCharsets.UTF_8);
out.length = ((byte[]) out.content).length;
}
}
diff --git a/luni/src/main/java/org/apache/harmony/security/asn1/ASN1StringType.java b/luni/src/main/java/org/apache/harmony/security/asn1/ASN1StringType.java
index 024b65f..f7ea2bd 100644
--- a/luni/src/main/java/org/apache/harmony/security/asn1/ASN1StringType.java
+++ b/luni/src/main/java/org/apache/harmony/security/asn1/ASN1StringType.java
@@ -23,7 +23,7 @@
package org.apache.harmony.security.asn1;
import java.io.IOException;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
/**
* This class is the super class for all string ASN.1 types
@@ -39,12 +39,12 @@ public abstract class ASN1StringType extends ASN1Type {
@Override
public Object getDecodedObject(BerInputStream in) throws IOException {
- return new String(in.buffer, in.contentOffset, in.length, Charsets.UTF_8);
+ return new String(in.buffer, in.contentOffset, in.length, StandardCharsets.UTF_8);
}
@Override
public void setEncodingContent(BerOutputStream out) {
- byte[] bytes = ((String) out.content).getBytes(Charsets.UTF_8);
+ byte[] bytes = ((String) out.content).getBytes(StandardCharsets.UTF_8);
out.content = bytes;
out.length = bytes.length;
}
@@ -96,7 +96,7 @@ public abstract class ASN1StringType extends ASN1Type {
public Object getDecodedObject(BerInputStream in) throws IOException {
/* To ensure we get the correct encoding on non-ASCII platforms, specify
that we wish to convert from ASCII to the default platform encoding */
- return new String(in.buffer, in.contentOffset, in.length, Charsets.ISO_8859_1);
+ return new String(in.buffer, in.contentOffset, in.length, StandardCharsets.ISO_8859_1);
}
public void encodeASN(BerOutputStream out) {
@@ -109,7 +109,7 @@ public abstract class ASN1StringType extends ASN1Type {
}
public void setEncodingContent(BerOutputStream out) {
- byte[] bytes = ((String) out.content).getBytes(Charsets.UTF_8);
+ byte[] bytes = ((String) out.content).getBytes(StandardCharsets.UTF_8);
out.content = bytes;
out.length = bytes.length;
}
diff --git a/luni/src/main/java/org/apache/harmony/security/asn1/ASN1UTCTime.java b/luni/src/main/java/org/apache/harmony/security/asn1/ASN1UTCTime.java
index 7c355f8..a3e77d3 100644
--- a/luni/src/main/java/org/apache/harmony/security/asn1/ASN1UTCTime.java
+++ b/luni/src/main/java/org/apache/harmony/security/asn1/ASN1UTCTime.java
@@ -23,7 +23,7 @@
package org.apache.harmony.security.asn1;
import java.io.IOException;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.TimeZone;
@@ -97,7 +97,7 @@ public final class ASN1UTCTime extends ASN1Time {
@Override public void setEncodingContent(BerOutputStream out) {
SimpleDateFormat sdf = new SimpleDateFormat(UTC_PATTERN, Locale.US);
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
- out.content = sdf.format(out.content).getBytes(Charsets.UTF_8);
+ out.content = sdf.format(out.content).getBytes(StandardCharsets.UTF_8);
out.length = ((byte[]) out.content).length;
}
}
diff --git a/luni/src/main/java/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java b/luni/src/main/java/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java
index 9453164..9129ec2 100644
--- a/luni/src/main/java/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java
+++ b/luni/src/main/java/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java
@@ -24,7 +24,7 @@ package org.apache.harmony.security.provider.cert;
import java.io.IOException;
import java.io.InputStream;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.security.cert.CRL;
import java.security.cert.CRLException;
import java.security.cert.CertPath;
@@ -432,8 +432,8 @@ public class X509CertFactoryImpl extends CertificateFactorySpi {
// ------------------------ Staff methods ------------------------------
// ---------------------------------------------------------------------
- private static final byte[] PEM_BEGIN = "-----BEGIN".getBytes(Charsets.UTF_8);
- private static final byte[] PEM_END = "-----END".getBytes(Charsets.UTF_8);
+ private static final byte[] PEM_BEGIN = "-----BEGIN".getBytes(StandardCharsets.UTF_8);
+ private static final byte[] PEM_END = "-----END".getBytes(StandardCharsets.UTF_8);
/**
* Code describing free format for PEM boundary suffix:
* "^-----BEGIN.*\n" at the beginning, and<br>
@@ -445,7 +445,7 @@ public class X509CertFactoryImpl extends CertificateFactorySpi {
* "^-----BEGIN CERTIFICATE-----\n" at the beginning, and<br>
* "\n-----END CERTIFICATE-----" at the end.
*/
- private static final byte[] CERT_BOUND_SUFFIX = " CERTIFICATE-----".getBytes(Charsets.UTF_8);
+ private static final byte[] CERT_BOUND_SUFFIX = " CERTIFICATE-----".getBytes(StandardCharsets.UTF_8);
/**
* Method retrieves the PEM encoded data from the stream
diff --git a/luni/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java b/luni/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java
index cd9549e..29e9d21 100644
--- a/luni/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java
+++ b/luni/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java
@@ -23,7 +23,7 @@
package org.apache.harmony.security.x501;
import java.io.IOException;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
@@ -378,7 +378,7 @@ public final class AttributeTypeAndValue {
av.bytes = (byte[]) out.content;
out.content = av;
} else {
- av.bytes = av.rawString.getBytes(Charsets.UTF_8);
+ av.bytes = av.rawString.getBytes(StandardCharsets.UTF_8);
out.length = av.bytes.length;
}
}
diff --git a/luni/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java b/luni/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java
index 54117bb..c4ff069 100644
--- a/luni/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java
+++ b/luni/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java
@@ -10,7 +10,7 @@ package org.xml.sax.helpers;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
@@ -126,7 +126,7 @@ final public class XMLReaderFactory
in = loader.getResourceAsStream (service);
if (in != null) {
- reader = new BufferedReader (new InputStreamReader (in, Charsets.UTF_8));
+ reader = new BufferedReader (new InputStreamReader (in, StandardCharsets.UTF_8));
className = reader.readLine ();
in.close ();
}
diff --git a/luni/src/test/java/libcore/io/StrictLineReaderTest.java b/luni/src/test/java/libcore/io/StrictLineReaderTest.java
index d5d3381..db88a6b 100644
--- a/luni/src/test/java/libcore/io/StrictLineReaderTest.java
+++ b/luni/src/test/java/libcore/io/StrictLineReaderTest.java
@@ -23,7 +23,7 @@ import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStream;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
public class StrictLineReaderTest extends TestCase {
@@ -31,7 +31,7 @@ public class StrictLineReaderTest extends TestCase {
try {
// Testing with LineReader buffer capacity 32 to check some corner cases.
StrictLineReader lineReader = new StrictLineReader(createTestInputStream(), 32,
- Charsets.US_ASCII);
+ StandardCharsets.US_ASCII);
InputStream refStream = createTestInputStream();
while (true) {
try {
@@ -81,4 +81,3 @@ public class StrictLineReaderTest extends TestCase {
).getBytes());
}
}
-
diff --git a/luni/src/test/java/libcore/javax/net/ssl/DefaultHostnameVerifierTest.java b/luni/src/test/java/libcore/javax/net/ssl/DefaultHostnameVerifierTest.java
index 69ae1c1..e1c9fe3 100644
--- a/luni/src/test/java/libcore/javax/net/ssl/DefaultHostnameVerifierTest.java
+++ b/luni/src/test/java/libcore/javax/net/ssl/DefaultHostnameVerifierTest.java
@@ -19,7 +19,7 @@ package libcore.javax.net.ssl;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.math.BigInteger;
-import java.nio.charset.Charsets;
+import java.nio.charset.StandardCharsets;
import java.security.Principal;
import java.security.PublicKey;
import java.security.cert.CertificateFactory;
@@ -301,7 +301,7 @@ public final class DefaultHostnameVerifierTest extends TestCase {
}
X509Certificate parseCertificate(String encoded) throws Exception {
- InputStream in = new ByteArrayInputStream(encoded.getBytes(Charsets.US_ASCII));
+ InputStream in = new ByteArrayInputStream(encoded.getBytes(StandardCharsets.US_ASCII));
return (X509Certificate) CertificateFactory.getInstance("X509").generateCertificate(in);
}