com.buck.common.codec.spi
Class CodecProvider

java.lang.Object
  extended by com.buck.common.codec.spi.CodecProvider
Direct Known Subclasses:
FastCodecProvider

public abstract class CodecProvider
extends Object

Codec service-provider class.

A codec provider is a concrete subclass of this class that has a zero-argument constructor and some number of associated codec implementation classes. Codec 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. Codec providers are looked up via the current thread's context class loader.

A codec provider identifies itself with a provider-configuration file named com.buck.common.codec.spi.CodecProvider in the resource directory META-INF/services. The file should contain a list of fully-qualified concrete codec-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 codec 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.

Author:
Robert J. Buck
See Also:
Codec

Constructor Summary
protected CodecProvider()
          Initializes a new codec provider.
 
Method Summary
abstract  Codec codecForName(String codecName)
          Retrieves a codec for the given codec name.
abstract  Iterator<Codec> codecs()
          Creates an iterator that iterates over the codecs supported by this provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodecProvider

protected CodecProvider()
Initializes a new codec provider.

Throws:
SecurityException - If a security manager has been installed and it denies RuntimePermission("codecProvider")
Method Detail

codecs

public abstract Iterator<Codec> codecs()
Creates an iterator that iterates over the codecs supported by this provider. This method is used in the implementation of the Codec.availableCodecs method.

Returns:
The new iterator

codecForName

public abstract Codec codecForName(String codecName)
Retrieves a codec for the given codec name.

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


Copyright © 2013. All Rights Reserved.