public class PopulationCodec extends Codec
Constructor and Description |
---|
PopulationCodec(Codec favouredCodec,
Codec tokenCodec,
Codec unvafouredCodec) |
PopulationCodec(Codec favouredCodec,
int l,
Codec unfavouredCodec) |
Modifier and Type | Method and Description |
---|---|
int |
decode(InputStream in)
Decode a sequence of bytes from the given input stream, returning the value as a long.
|
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 . |
byte[] |
encode(int value)
Encode a single value into a sequence of bytes.
|
byte[] |
encode(int[] favoured,
int[] tokens,
int[] unfavoured) |
byte[] |
encode(int value,
int last)
Encode a single value into a sequence of bytes.
|
int[] |
getFavoured() |
Codec |
getFavouredCodec() |
Codec |
getTokenCodec() |
Codec |
getUnfavouredCodec() |
decodeInts, encode
public PopulationCodec(Codec favouredCodec, Codec tokenCodec, Codec unvafouredCodec)
public PopulationCodec(Codec favouredCodec, int l, Codec unfavouredCodec)
public int decode(InputStream in) throws IOException, Pack200Exception
Codec
decode
in class Codec
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 int decode(InputStream in, long last) throws IOException, Pack200Exception
Codec
long last = 0; while (condition) { last = codec.decode(in, last); // do something with last }
decode
in class Codec
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
Codec
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.decodeInts
in class Codec
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[] getFavoured()
public Codec getFavouredCodec()
public Codec getUnfavouredCodec()
public byte[] encode(int value, int last) throws Pack200Exception
Codec
encode
in class Codec
value
- the value to encodelast
- the previous value encoded (for delta encodings)Pack200Exception
- TODOpublic byte[] encode(int value) throws Pack200Exception
Codec
encode
in class Codec
value
- the value to encodePack200Exception
- TODOpublic byte[] encode(int[] favoured, int[] tokens, int[] unfavoured) throws Pack200Exception
Pack200Exception
public Codec getTokenCodec()
Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.