Package htsjdk.samtools.cram.encoding
Class AbstractBitCodec<T>
- java.lang.Object
-
- htsjdk.samtools.cram.encoding.AbstractBitCodec<T>
-
- All Implemented Interfaces:
BitCodec<T>
- Direct Known Subclasses:
ByteArrayStopEncoding.ByteArrayStopCodec
public abstract class AbstractBitCodec<T> extends Object implements BitCodec<T>
-
-
Constructor Summary
Constructors Constructor Description AbstractBitCodec()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract longnumberOfBits(T object)Calculate the number of bits that the object would take in bit serialized form.abstract Tread(BitInputStream bitInputStream)Read a single object from the bit stream.abstract Tread(BitInputStream bitInputStream, int valueLen)Read a array of specified length from the bit stream.voidreadInto(BitInputStream bitInputStream, byte[] array, int offset, int valueLen)Read a array of specified length from the bit stream into a given byte array.voidskip(BitInputStream bitInputStream)Skip the next object in the bit stream.voidskip(BitInputStream bitInputStream, int length)Skip the next length objects in the bit stream.abstract longwrite(BitOutputStream bitOutputStream, T object)Write an object into the bit stream
-
-
-
Method Detail
-
read
public abstract T read(BitInputStream bitInputStream) throws IOException
Description copied from interface:BitCodecRead a single object from the bit stream.- Specified by:
readin interfaceBitCodec<T>- Parameters:
bitInputStream- the bit input stream to rad from- Returns:
- an object from the stream
- Throws:
IOException- as per java IO contract
-
read
public abstract T read(BitInputStream bitInputStream, int valueLen) throws IOException
Description copied from interface:BitCodecRead a array of specified length from the bit stream.- Specified by:
readin interfaceBitCodec<T>- Parameters:
bitInputStream- the bit input stream to rad from param valueLen the number of elements to read- Returns:
- an object from the stream
- Throws:
IOException- as per java IO contract
-
readInto
public void readInto(BitInputStream bitInputStream, byte[] array, int offset, int valueLen) throws IOException
Description copied from interface:BitCodecRead a array of specified length from the bit stream into a given byte array. This method is a way to optimize byte array IO operations by bypassing abstraction. Leaky, I know.- Specified by:
readIntoin interfaceBitCodec<T>- Parameters:
bitInputStream- the bit input stream to rad fromarray- the array to read intooffset- offset in the arrayvalueLen- number of elements to read- Throws:
IOException- as per java IO contract
-
skip
public void skip(BitInputStream bitInputStream) throws IOException
Description copied from interface:BitCodecSkip the next object in the bit stream.- Specified by:
skipin interfaceBitCodec<T>- Parameters:
bitInputStream- the bit stream to operate on- Throws:
IOException- as per java IO contract
-
skip
public void skip(BitInputStream bitInputStream, int length) throws IOException
Description copied from interface:BitCodecSkip the next length objects in the bit stream.- Specified by:
skipin interfaceBitCodec<T>- Parameters:
bitInputStream- the bit stream to operate onlength- the number of objects to skip- Throws:
IOException- as per java IO contract
-
write
public abstract long write(BitOutputStream bitOutputStream, T object) throws IOException
Description copied from interface:BitCodecWrite an object into the bit stream- Specified by:
writein interfaceBitCodec<T>- Parameters:
bitOutputStream- the output bit stream to write toobject- the object to write- Returns:
- the number of bits written out
- Throws:
IOException- as per java IO contract
-
numberOfBits
public abstract long numberOfBits(T object)
Description copied from interface:BitCodecCalculate the number of bits that the object would take in bit serialized form.- Specified by:
numberOfBitsin interfaceBitCodec<T>- Parameters:
object- an object- Returns:
- the number of bits
-
-