Package com.ibm.icu.charset
Class CharsetProviderICU
- java.lang.Object
-
- java.nio.charset.spi.CharsetProvider
-
- com.ibm.icu.charset.CharsetProviderICU
-
public final class CharsetProviderICU extends java.nio.charset.spi.CharsetProvider
A concrete subclass of CharsetProvider for loading and providing charset converters in ICU.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<java.nio.charset.Charset>
icuCharsets
List of available ICU Charsets, empty during static initialization.
-
Constructor Summary
Constructors Constructor Description CharsetProviderICU()
Default constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.nio.charset.Charset
charsetForName(java.lang.String charsetName)
Constructs a Charset for the given charset name.java.nio.charset.Charset
charsetForName(java.lang.String charsetName, java.lang.String classPath)
Constructs a charset for the given ICU conversion table from the specified class path.java.nio.charset.Charset
charsetForName(java.lang.String charsetName, java.lang.String classPath, java.lang.ClassLoader loader)
Constructs a charset for the given ICU conversion table from the specified class path.java.util.Iterator<java.nio.charset.Charset>
charsets()
Returns an iterator for the available ICU Charsets.private static java.lang.String[]
getAliases(java.lang.String encName)
Deprecated.This API is ICU internal only.static java.lang.String[]
getAllNames()
Deprecated.This API is ICU internal only.static java.lang.String[]
getAvailableNames()
Deprecated.This API is ICU internal only.private static java.nio.charset.Charset
getCharset(java.lang.String icuCanonicalName, java.lang.String optionsString)
static java.lang.String
getICUCanonicalName(java.lang.String enc)
Deprecated.This API is ICU internal only.static java.lang.String
getJavaCanonicalName(java.lang.String charsetName)
Deprecated.This API is ICU internal only.private static void
loadAvailableICUCharsets()
Lazy-init the icuCharsets list.
-
-
-
Field Detail
-
icuCharsets
private static java.util.List<java.nio.charset.Charset> icuCharsets
List of available ICU Charsets, empty during static initialization. Not a Set or Map, so that we can add different Charset objects with the same name(), which means that they are .equals(). See ICU ticket #11493.
-
-
Method Detail
-
charsetForName
public final java.nio.charset.Charset charsetForName(java.lang.String charsetName)
Constructs a Charset for the given charset name. Implements the abstract method of super class.- Specified by:
charsetForName
in classjava.nio.charset.spi.CharsetProvider
- Parameters:
charsetName
- charset name- Returns:
- Charset object for the given charset name, null if unsupported
-
charsetForName
public final java.nio.charset.Charset charsetForName(java.lang.String charsetName, java.lang.String classPath)
Constructs a charset for the given ICU conversion table from the specified class path. Example use:cnv = CharsetProviderICU.charsetForName("myConverter", "com/myCompany/myDataPackage");
. In this example myConverter.cnv would exist in the com/myCompany/myDataPackage Java package. Conversion tables can be made with ICU4C's makeconv tool. This function allows you to allows you to load user defined conversion tables that are outside of ICU's core data.- Parameters:
charsetName
- The name of the charset conversion table.classPath
- The class path that contain the conversion table.- Returns:
- charset object for the given charset name, null if unsupported
-
charsetForName
public java.nio.charset.Charset charsetForName(java.lang.String charsetName, java.lang.String classPath, java.lang.ClassLoader loader)
Constructs a charset for the given ICU conversion table from the specified class path. This function is similar tocharsetForName(String, String)
.- Parameters:
charsetName
- The name of the charset conversion table.classPath
- The class path that contain the conversion table.loader
- the class object from which to load the charset conversion table- Returns:
- charset object for the given charset name, null if unsupported
-
getICUCanonicalName
@Deprecated public static final java.lang.String getICUCanonicalName(java.lang.String enc) throws java.nio.charset.UnsupportedCharsetException
Deprecated.This API is ICU internal only.Gets the canonical name of the converter as defined by Java- Parameters:
enc
- converter name- Returns:
- canonical name of the converter
- Throws:
java.nio.charset.UnsupportedCharsetException
-
getCharset
private static final java.nio.charset.Charset getCharset(java.lang.String icuCanonicalName, java.lang.String optionsString) throws java.io.IOException
- Throws:
java.io.IOException
-
getJavaCanonicalName
@Deprecated public static java.lang.String getJavaCanonicalName(java.lang.String charsetName)
Deprecated.This API is ICU internal only.Gets the canonical name of the converter as defined by Java- Parameters:
charsetName
- converter name- Returns:
- canonical name of the converter
-
getAliases
@Deprecated private static final java.lang.String[] getAliases(java.lang.String encName) throws java.io.IOException
Deprecated.This API is ICU internal only.Gets the aliases associated with the converter name- Parameters:
encName
- converter name- Returns:
- converter names as elements in an object array
- Throws:
java.io.IOException
-
loadAvailableICUCharsets
private static final void loadAvailableICUCharsets()
Lazy-init the icuCharsets list. Could be done during static initialization if constructing all of the Charsets were cheap enough. See ICU ticket #11481.
-
charsets
public final java.util.Iterator<java.nio.charset.Charset> charsets()
Returns an iterator for the available ICU Charsets. Implements the abstract method of super class.- Specified by:
charsets
in classjava.nio.charset.spi.CharsetProvider
- Returns:
- the Charset iterator
-
getAvailableNames
@Deprecated public static final java.lang.String[] getAvailableNames()
Deprecated.This API is ICU internal only.Gets the canonical names of available ICU converters- Returns:
- array of available converter names
-
getAllNames
@Deprecated public static final java.lang.String[] getAllNames()
Deprecated.This API is ICU internal only.Return all names available- Returns:
- String[] an array of all available names
-
-