|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.buck.common.codec.Codec
public abstract class Codec
A named mapping between encoded sequences of bytes and raw binary data. This class defines methods for creating decoders and encoders and for retrieving the various names associated with a codec. Instances of this class are immutable.
Codecs are named by strings composed of the following characters:
Codecs supported by the Codecs Library support the following standard codecs. Consult the release documentation for your implementation to see if any other codecs are supported. The behavior of such optional codecs may differ between implementations.
Codec
Description
Base16 Defined in RFC 4648, this codec, referred to as "base16" or "hex", is the standard case-insensitive hex encoding. Unlike base32 or base64, base16 requires no special padding since a full code word is always available. Base32 Defined in RFC 4648, this codec, referred to as "base32", uses an alphabet that may be handled by humans; where the characters "0" and "O" are easily confused, as are "1", "l", and "I", the base32 alphabet omits 0 (zero) and 1 (one). Base32 Extended Hex Alphabet Defined in RFC 4648, this codec, referred to as "base32hex", uses an alphabet that causes confusion by humans due to its use of 0 (zero) and 1 (one). However, one property with this alphabet, which the base64 and base32 alphabets lack, is that encoded data maintains its sort order when the encoded data is compared bit-wise. Base64 Defined in RFC 4648, this codec, referred to as "base64", the encoding is designed to represent arbitrary sequences of octets in a form that allows the use of both upper- and lowercase letters but that need not be human readable. Base64 URL Defined in RFC 4648, this codec, referred to as "base64url", is identical to base64, except that it uses an alphabet that is safe for use in URL and filenames. Percent Encoded Defined in RFC 3986, this codec, referred to as "percent-encoded", is similar to URL Encoded, except that it uses an alphabet that is safe for use in URI, according to RFC 3986. Percent-encoding may only be applied to octets prior to producing a URI from its component parts. When encoding URI, percent encoding is preferable over URL encoded schemes. Quoted Printable Defined in RFC 2045, this codec, referred to as "quoted-printable", is intended to represent data that largely consists of octets that correspond to printable characters in the US-ASCII character set. It encodes the data in such a way that the resulting octets are unlikely to be modified by mail transport. If the data being encoded are mostly US-ASCII text, the encoded form of the data remains largely recognizable by humans. URL Encoded Defined in HTML 2.0 Forms, this codec, referred to as "x-www-form-urlencoded", is used primarily for HTML form submission.
| Constructor Summary | |
|---|---|
protected |
Codec(String canonicalName,
String[] aliases)
Initializes a new codec with the given canonical name and alias set. |
| Method Summary | |
|---|---|
Set<String> |
aliases()
Returns a set containing this codec's aliases. |
static SortedMap<String,Codec> |
availableCodecs()
Constructs a sorted map from canonical codec names to codec objects. |
int |
compareTo(Codec that)
Compares this codec to another. |
boolean |
equals(Object ob)
Tells whether or not this object is equal to another. |
static Codec |
forName(String codecName)
Returns a codec object for the named codec. |
int |
hashCode()
Computes a hashcode for this codec. |
static boolean |
isSupported(String codecName)
Tells whether the named codec is supported. |
String |
name()
Returns this codec's canonical name. |
abstract CodecDecoder |
newDecoder()
Constructs a new decoder for this codec. |
abstract CodecEncoder |
newEncoder()
Constructs a new encoder for this codec. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected Codec(String canonicalName,
String[] aliases)
canonicalName - The canonical name of this codecaliases - An array of this codec's aliases, or null if it has
no aliases
IllegalCodecNameException - If the canonical name or any of the
aliases are illegal| Method Detail |
|---|
public static Codec forName(String codecName)
codecName - The name of the requested codec; may be either a
canonical name or an alias
IllegalCodecNameException - If the given codec name is illegal
UnsupportedCodecException - If no support for the given codec is
available in this instance of the
virtual machine; the name is legal.public static boolean isSupported(String codecName)
codecName - The name of the requested codec; may be either a
canonical name or an alias
IllegalCodecNameException - If the given codec name is illegalpublic final Set<String> aliases()
public final int compareTo(Codec that)
Codecs are ordered by their canonical names, without regard to case.
compareTo in interface Comparable<Codec>that - The codec to which this codec is to be compared
public final int hashCode()
hashCode in class Objectpublic final boolean equals(Object ob)
Two codecs are equal if, and only if, they have the same canonical names. A codec is never equal to any other type of object.
equals in class Objectpublic final String name()
public static SortedMap<String,Codec> availableCodecs()
The map returned by this method will have one entry for each codec for which support is available in the current Java virtual machine. If two or more supported codecs have the same canonical name then the resulting map will contain just one of them; which one it will contain is not specified.
The invocation of this method, and the
subsequent use of the resulting map, may cause time-consuming disk or
network I/O operations to occur. This method is provided for
applications that need to enumerate all of the available codecs, for
example to allow user codec selection. This method is not used by the
forName method, which instead employs an efficient
incremental lookup algorithm.
This method may return different
results at different times if new codec providers are dynamically made
available to the current Java virtual machine. In the absence of such
changes, the codecs returned by this method are exactly those that can be
retrieved via the forName method.
public abstract CodecDecoder newDecoder()
public abstract CodecEncoder newEncoder()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||