java.nio.charset.spi
Class CharsetProvider

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.nio.charset.spi.CharsetProvider

public abstract class CharsetProvider
extends Object sample code for java.lang.Object definition code for java.lang.Object

Charset service-provider class.

A charset provider is a concrete subclass of this class that has a zero-argument constructor and some number of associated charset implementation classes. Charset providers may be installed in an instance of the Java platform as extensions, that is, jar files placed into any of the usual extension directories. Providers may also be made available by adding them to the applet or application class path or by some other platform-specific means. Charset providers are looked up via the current thread's context class loader sample code for java.lang.Thread.getContextClassLoader() definition code for java.lang.Thread.getContextClassLoader() .

A charset provider identifies itself with a provider-configuration file named java.nio.charset.spi.CharsetProvider in the resource directory META-INF/services. The file should contain a list of fully-qualified concrete charset-provider class names, one per line. A line is terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a line feed. Space and tab characters surrounding each name, as well as blank lines, are ignored. The comment character is '#' ('\u0023'); on each line all characters following the first comment character are ignored. The file must be encoded in UTF-8.

If a particular concrete charset provider class is named in more than one configuration file, or is named in the same configuration file more than once, then the duplicates will be ignored. The configuration file naming a particular provider need not be in the same jar file or other distribution unit as the provider itself. The provider must be accessible from the same class loader that was initially queried to locate the configuration file; this is not necessarily the class loader that loaded the file.

Since:
1.4
See Also:
Charset sample code for java.nio.charset.Charset definition code for java.nio.charset.Charset

Constructor Summary
protected CharsetProvider sample code for java.nio.charset.spi.CharsetProvider.CharsetProvider() definition code for java.nio.charset.spi.CharsetProvider.CharsetProvider() ()
          Initializes a new charset provider.
 
Method Summary
abstract  Charset sample code for java.nio.charset.Charset definition code for java.nio.charset.Charset charsetForName sample code for java.nio.charset.spi.CharsetProvider.charsetForName(java.lang.String) definition code for java.nio.charset.spi.CharsetProvider.charsetForName(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  charsetName)
          Retrieves a charset for the given charset name.
abstract  Iterator sample code for java.util.Iterator definition code for java.util.Iterator <Charset sample code for java.nio.charset.Charset definition code for java.nio.charset.Charset > charsets sample code for java.nio.charset.spi.CharsetProvider.charsets() definition code for java.nio.charset.spi.CharsetProvider.charsets() ()
          Creates an iterator that iterates over the charsets supported by this provider.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

CharsetProvider sample code for java.nio.charset.spi.CharsetProvider() definition code for java.nio.charset.spi.CharsetProvider()

protected CharsetProvider()
Initializes a new charset provider.

Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - If a security manager has been installed and it denies RuntimePermission sample code for java.lang.RuntimePermission definition code for java.lang.RuntimePermission ("charsetProvider")
Method Detail

charsets sample code for java.nio.charset.spi.CharsetProvider.charsets() definition code for java.nio.charset.spi.CharsetProvider.charsets()

public abstract Iterator sample code for java.util.Iterator definition code for java.util.Iterator <Charset sample code for java.nio.charset.Charset definition code for java.nio.charset.Charset > charsets()
Creates an iterator that iterates over the charsets supported by this provider. This method is used in the implementation of the Charset.availableCharsets sample code for java.nio.charset.Charset.availableCharsets() definition code for java.nio.charset.Charset.availableCharsets() method.

Returns:
The new iterator

charsetForName sample code for java.nio.charset.spi.CharsetProvider.charsetForName(java.lang.String) definition code for java.nio.charset.spi.CharsetProvider.charsetForName(java.lang.String)

public abstract Charset sample code for java.nio.charset.Charset definition code for java.nio.charset.Charset  charsetForName(String sample code for java.lang.String definition code for java.lang.String  charsetName)
Retrieves a charset for the given charset name.

Parameters:
charsetName - The name of the requested charset; may be either a canonical name or an alias
Returns:
A charset object for the named charset, or null if the named charset is not supported by this provider