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

public Class RunCodec

extends Codec
Class Inheritance
Imports
java.io.IOException, .InputStream, java.util.Arrays, org.apache.commons.compress.utils.ExactMath

A run codec is a grouping of two nested codecs; K values are decoded from the first codec, and the remaining codes are decoded from the remaining codec. Note that since this codec maintains state, the instances are not reusable.

Field Summary

Modifier and TypeField and Description
private final Codec
private final Codec
private int
k

private int
Inherited from org.apache.commons.compress.harmony.pack200.Codec:
BCI5BRANCH5BYTE1CHAR3DELTA5lastBandLengthMDELTA5SIGNED5UDELTA5UNSIGNED5

Constructor Summary

AccessConstructor and Description
public
RunCodec(final int k, final Codec aCodec, final Codec bCodec)

Method Summary

Modifier and TypeMethod and Description
public int
decode(final InputStream
the input stream to read from
in
)

Implements abstract org.apache.commons.compress.harmony.pack200.Codec.decode.

Decodes a sequence of bytes from the given input stream, returning the value as a long.
public int
decode(final InputStream
the input stream to read from
in
,
final long
the previous value read, which must be supplied if the codec is a delta encoding
last
)

Implements abstract org.apache.commons.compress.harmony.pack200.Codec.decode.

Decodes a sequence of bytes from the given input stream, returning the value as a long.
public int[]
decodeInts(final int
the number of values to decode
n
,
final InputStream
the input stream to read from
in
)

Overrides org.apache.commons.compress.harmony.pack200.Codec.decodeInts.

Decodes a sequence of n values from in.
public byte[]
encode(final int
the value to encode
value
)

Implements abstract org.apache.commons.compress.harmony.pack200.Codec.encode.

Encodes a single value into a sequence of bytes.
public byte[]
encode(final int
the value to encode
value
,
final int
the previous value encoded (for delta encodings)
last
)

Implements abstract org.apache.commons.compress.harmony.pack200.Codec.encode.

Encodes a single value into a sequence of bytes.
public Codec
public Codec
public int
getK()

private int
normalise(int value, final Codec codecUsed)

private void
normalise(final int[] band, final Codec codecUsed)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.apache.commons.compress.harmony.pack200.Codec:
checkdecodeIntsencode

Field Detail

aCodecback to summary
private final Codec aCodec
bCodecback to summary
private final Codec bCodec
kback to summary
private int k
lastback to summary
private int last

Constructor Detail

RunCodecback to summary
public RunCodec(final int k, final Codec aCodec, final Codec bCodec) throws Pack200Exception

Method Detail

decodeback to summary
public int decode(final InputStream in) throws IOException, Pack200Exception

Implements abstract org.apache.commons.compress.harmony.pack200.Codec.decode.

Doc from org.apache.commons.compress.harmony.pack200.Codec.decode.

Decodes a sequence of bytes from the given input stream, returning the value as a long. Note that this method can only be applied for non-delta encodings.

Parameters
in:InputStream

the input stream to read from

Returns:int

the value as a long

Annotations
@Override
Exceptions
IOException:
if there is a problem reading from the underlying input stream
Pack200Exception:
if the encoding is a delta encoding
decodeback to summary
public int decode(final InputStream in, final long last) throws IOException, Pack200Exception

Implements abstract org.apache.commons.compress.harmony.pack200.Codec.decode.

Doc from org.apache.commons.compress.harmony.pack200.Codec.decode.

Decodes a sequence of bytes from the given input stream, returning the value as a long. If this encoding is a delta encoding (d=1) then the previous value must be passed in as a parameter. If it is a non-delta encoding, then it does not matter what value is passed in, so it makes sense for the value to be passed in by default using code similar to:

long last = 0;
while (condition) {
    last = codec.decode(in, last);
    // do something with last
}
Parameters
in:InputStream

the input stream to read from

last:long

the previous value read, which must be supplied if the codec is a delta encoding

Returns:int

the value as a long

Annotations
@Override
Exceptions
IOException:
if there is a problem reading from the underlying input stream
Pack200Exception:
if there is a problem decoding the value or that the value is invalid
decodeIntsback to summary
public int[] decodeInts(final int n, final InputStream in) throws IOException, Pack200Exception

Overrides org.apache.commons.compress.harmony.pack200.Codec.decodeInts.

Doc from org.apache.commons.compress.harmony.pack200.Codec.decodeInts.

Decodes a sequence of n values from in. This should probably be used in most cases, since some codecs (such as PopulationCodec) only work when the number of values to be read is known.

Parameters
n:int

the number of values to decode

in:InputStream

the input stream to read from

Returns:int[]

an array of int values corresponding to values decoded

Annotations
@Override
Exceptions
IOException:
if there is a problem reading from the underlying input stream
Pack200Exception:
if there is a problem decoding the value or that the value is invalid
encodeback to summary
public byte[] encode(final int value) throws Pack200Exception

Implements abstract org.apache.commons.compress.harmony.pack200.Codec.encode.

Doc from org.apache.commons.compress.harmony.pack200.Codec.encode.

Encodes a single value into a sequence of bytes. Note that this method can only be used for non-delta encodings.

Parameters
value:int

the value to encode

Returns:byte[]

the encoded bytes

Annotations
@Override
Exceptions
Pack200Exception:
TODO
encodeback to summary
public byte[] encode(final int value, final int last) throws Pack200Exception

Implements abstract org.apache.commons.compress.harmony.pack200.Codec.encode.

Doc from org.apache.commons.compress.harmony.pack200.Codec.encode.

Encodes a single value into a sequence of bytes.

Parameters
value:int

the value to encode

last:int

the previous value encoded (for delta encodings)

Returns:byte[]

the encoded bytes

Annotations
@Override
Exceptions
Pack200Exception:
TODO
getACodecback to summary
public Codec getACodec()
getBCodecback to summary
public Codec getBCodec()
getKback to summary
public int getK()
normaliseback to summary
private int normalise(int value, final Codec codecUsed)
normaliseback to summary
private void normalise(final int[] band, final Codec codecUsed)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override