Better name to reflect that we are populating the map based on the JRE's
StandardCharsets.
*
* @see <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @since 2.3
- *
*/
public class Charsets {
+
//
// This class should only contain Charset instances for required encodings. This guarantees that it will load
// correctly and without delay on all Java platforms.
//
- private static final SortedMap<String, Charset> REQUIRED_CHARSETS;
+ private static final SortedMap<String, Charset> STANDARD_CHARSET_MAP;
static {
- SortedMap<String, Charset> requiredCharsets = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
- requiredCharsets.put(StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1);
- requiredCharsets.put(StandardCharsets.US_ASCII.name(), StandardCharsets.US_ASCII);
- requiredCharsets.put(StandardCharsets.UTF_16.name(), StandardCharsets.UTF_16);
- requiredCharsets.put(StandardCharsets.UTF_16BE.name(), StandardCharsets.UTF_16BE);
- requiredCharsets.put(StandardCharsets.UTF_16LE.name(), StandardCharsets.UTF_16LE);
- requiredCharsets.put(StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8);
- REQUIRED_CHARSETS = Collections.unmodifiableSortedMap(requiredCharsets);
+ SortedMap<String, Charset> standardCharsetMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ standardCharsetMap.put(StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1);
+ standardCharsetMap.put(StandardCharsets.US_ASCII.name(), StandardCharsets.US_ASCII);
+ standardCharsetMap.put(StandardCharsets.UTF_16.name(), StandardCharsets.UTF_16);
+ standardCharsetMap.put(StandardCharsets.UTF_16BE.name(), StandardCharsets.UTF_16BE);
+ standardCharsetMap.put(StandardCharsets.UTF_16LE.name(), StandardCharsets.UTF_16LE);
+ standardCharsetMap.put(StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8);
+ STANDARD_CHARSET_MAP = Collections.unmodifiableSortedMap(standardCharsetMap);
}
/**
* @since 2.5
*/
public static SortedMap<String, Charset> requiredCharsets() {
- return REQUIRED_CHARSETS;
+ return STANDARD_CHARSET_MAP;
}
/**
