public abstract class Codec extends Object
UDELTA5
, UNSIGNED5
, BYTE1
, CHAR3
) that are
used in the implementation of many bands; but there are a variety of other ones, and indeed the specification assumes
that other combinations of values can result in more specific and efficient formats. There are also a sequence of
canonical encodings defined by the Pack200 specification, which allow a Codec to be referred to by canonical number.
CodecEncoding.getCodec(int, InputStream, Codec)
)Modifier and Type | Field and Description |
---|---|
static BHSDCodec |
BCI5
BCI5 = (5,4): Used for storing branching information in bytecode.
|
static BHSDCodec |
BRANCH5
BRANCH5 = (5,4,2): Used for storing branching information in bytecode.
|
static BHSDCodec |
BYTE1
BYTE1 = (1,256): Used for storing plain bytes.
|
static BHSDCodec |
CHAR3
CHAR3 = (3,128): Used for storing text (UTF-8) strings.
|
static BHSDCodec |
DELTA5
DELTA5 = (5,64,1,1): Used for the majority of numerical codings where there is a correlated sequence of signed
values.
|
int |
lastBandLength |
static BHSDCodec |
MDELTA5
MDELTA5 = (5,64,2,1): Used for the majority of numerical codings where there is a correlated sequence of signed
values, but where most of them are expected to be non-negative.
|
static BHSDCodec |
SIGNED5
SIGNED5 = (5,64,1): Used for small signed values.
|
static BHSDCodec |
UDELTA5
UDELTA5 = (5,64,0,1): Used for the majority of numerical codings where there is a correlated sequence of unsigned
values.
|
static BHSDCodec |
UNSIGNED5
UNSIGNED5 = (5,64): Used for small unsigned values.
|
Constructor and Description |
---|
Codec() |
Modifier and Type | Method and Description |
---|---|
abstract int |
decode(InputStream in)
Decode a sequence of bytes from the given input stream, returning the value as a long.
|
abstract int |
decode(InputStream in,
long last)
Decode a sequence of bytes from the given input stream, returning the value as a long.
|
int[] |
decodeInts(int n,
InputStream in)
Decodes a sequence of
n values from in . |
int[] |
decodeInts(int n,
InputStream in,
int firstValue)
Decodes a sequence of
n values from in . |
abstract byte[] |
encode(int value)
Encode a single value into a sequence of bytes.
|
byte[] |
encode(int[] ints)
Encode a sequence of integers into a byte array
|
abstract byte[] |
encode(int value,
int last)
Encode a single value into a sequence of bytes.
|
public static final BHSDCodec BCI5
public static final BHSDCodec BRANCH5
public static final BHSDCodec CHAR3
public static final BHSDCodec DELTA5
public static final BHSDCodec MDELTA5
public static final BHSDCodec UDELTA5
public static final BHSDCodec UNSIGNED5
public int lastBandLength
public Codec()
public abstract int decode(InputStream in) throws IOException, Pack200Exception
in
- the input stream to read fromIOException
- if there is a problem reading from the underlying input streamPack200Exception
- if the encoding is a delta encodingpublic abstract byte[] encode(int value, int last) throws Pack200Exception
value
- the value to encodelast
- the previous value encoded (for delta encodings)Pack200Exception
- TODOpublic abstract byte[] encode(int value) throws Pack200Exception
value
- the value to encodePack200Exception
- TODOpublic abstract int decode(InputStream in, long last) throws IOException, Pack200Exception
long last = 0; while (condition) { last = codec.decode(in, last); // do something with last }
in
- the input stream to read fromlast
- the previous value read, which must be supplied if the codec is a delta encodingIOException
- if there is a problem reading from the underlying input streamPack200Exception
- if there is a problem decoding the value or that the value is invalidpublic int[] decodeInts(int n, InputStream in) throws IOException, Pack200Exception
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.n
- the number of values to decodein
- the input stream to read fromint
values corresponding to values decodedIOException
- if there is a problem reading from the underlying input streamPack200Exception
- if there is a problem decoding the value or that the value is invalidpublic int[] decodeInts(int n, InputStream in, int firstValue) throws IOException, Pack200Exception
n
values from in
.n
- the number of values to decodein
- the input stream to read fromfirstValue
- the first value in the band if it has already been readint
values corresponding to values decoded, with firstValue as the first value
in the array.IOException
- if there is a problem reading from the underlying input streamPack200Exception
- if there is a problem decoding the value or that the value is invalidpublic byte[] encode(int[] ints) throws Pack200Exception
ints
- the values to encodePack200Exception
- if there is a problem encoding any of the valuesCopyright © 2002–2020 The Apache Software Foundation. All rights reserved.