Top Description Fields Constructors Methods
org.apache.commons.compress.harmony.pack200

public Class CodecEncoding

extends Object
Class Inheritance
Imports
java.io.EOFException, .IOException, .InputStream, java.util.Arrays, .HashMap, .Map

CodecEncoding is used to get the right Codec for a given meta-encoding.

Field Summary

Modifier and TypeField and Description
private static final BHSDCodec[]
canonicalCodec

The canonical encodings are defined to allow a single byte to represent one of the standard encodings.

private static Map<BHSDCodec, Integer>
private static final int[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static BHSDCodec
getCanonicalCodec(final int i)

public static Codec

Returns:

the corresponding codec, or null if the default should be used
getCodec
(final int
the canonical encoding value
value
,
final InputStream
the input stream to read additional byte headers from
in
,
final Codec
TODO
defaultCodec
)

Gets the codec specified by the given value byte and optional byte header.

public static int[]
getSpecifier(final Codec codec, final Codec defaultForBand)

public static int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

canonicalCodecback to summary
private static final BHSDCodec[] canonicalCodec

The canonical encodings are defined to allow a single byte to represent one of the standard encodings. The following values are defined in the Pack200 specification, and this array cannot be changed.

canonicalCodecsToSpecifiersback to summary
private static Map<BHSDCodec, Integer> canonicalCodecsToSpecifiers
EMPTY_INT_ARRAYback to summary
private static final int[] EMPTY_INT_ARRAY

Constructor Detail

CodecEncodingback to summary
public CodecEncoding()

Method Detail

getCanonicalCodecback to summary
public static BHSDCodec getCanonicalCodec(final int i)
getCodecback to summary
public static Codec getCodec(final int value, final InputStream in, final Codec defaultCodec) throws IOException, Pack200Exception

Gets the codec specified by the given value byte and optional byte header. If the value is >= 116, then bytes may be consumed from the secondary input stream, which is taken to be the contents of the band_headers byte array. Since the values from this are consumed and not repeated, the input stream should be reused for subsequent encodings. This does not therefore close the input stream.

Parameters
value:int

the canonical encoding value

in:InputStream

the input stream to read additional byte headers from

defaultCodec:Codec

TODO

Returns:Codec

the corresponding codec, or null if the default should be used

Exceptions
IOException:
if there is a problem reading from the input stream (which in reality, is never, since the band_headers are likely stored in a byte array and accessed via a ByteArrayInputStream. However, an EOFException could occur if things go wrong)
Pack200Exception:
TODO
getSpecifierback to summary
public static int[] getSpecifier(final Codec codec, final Codec defaultForBand)
getSpecifierForDefaultCodecback to summary
public static int getSpecifierForDefaultCodec(final BHSDCodec defaultCodec)