# Class BCF2Decoder

java.lang.Object
htsjdk.variant.bcf2.BCF2Decoder

public final class BCF2Decoder extends Object

## Constructor Summary

Constructors
Modifier
Constructor
Description
``
`BCF2Decoder()`
`protected`
`BCF2Decoder(byte[] recordBytes)`
Create a new decoder ready to read BCF2 data from the byte[] recordBytes, for testing purposes

## Method Summary

Modifier and Type
Method
Description
`boolean`
`blockIsFullyDecoded()`
`final int`
`decodeInt(byte typeDescriptor, int missingValue)`
Decode an int from the stream.
`final int`
`decodeInt(BCF2Type type)`
`final int[]`
`decodeIntArray(byte typeDescriptor, int size)`
`final int[]`
`decodeIntArray(int size, BCF2Type type, int[] maybeDest)`
Low-level reader for int[] Requires a typeDescriptor so the function knows how many elements to read, and how they are encoded.
`final int`
`decodeNumberOfElements(byte typeDescriptor)`
`final Object`
`decodeSingleValue(BCF2Type type)`
`final Object`
`decodeTypedValue()`
`final Object`
`decodeTypedValue(byte typeDescriptor)`
`final Object`
`decodeTypedValue(byte typeDescriptor, int size)`
`int`
`getBlockSize()`
The size of the current block in bytes
`byte[]`
`getRecordBytes()`
Returns the byte[] for the block of data we are currently decoding
`final int`
`readBlockSize(InputStream inputStream)`
Read the size of the next block from inputStream
`void`
`readNextBlock(int blockSizeInBytes, InputStream stream)`
Reads the next record from input stream and prepare this decoder to decode values from it
`final byte`
`readTypeDescriptor()`
`void`
`setRecordBytes(byte[] recordBytes)`
Use the recordBytes[] to read BCF2 records from now on
`void`
`skipNextBlock(int blockSizeInBytes, InputStream stream)`
Skips the next record from input stream, invalidating current block data

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### BCF2Decoder

public BCF2Decoder()

### BCF2Decoder

protected BCF2Decoder(byte[] recordBytes)
Create a new decoder ready to read BCF2 data from the byte[] recordBytes, for testing purposes

Parameters:
  `recordBytes` -

## Method Details

### readNextBlock

public void readNextBlock(int blockSizeInBytes, InputStream stream)
Reads the next record from input stream and prepare this decoder to decode values from it

Parameters:
  `stream` -

### skipNextBlock

public void skipNextBlock(int blockSizeInBytes, InputStream stream)
Skips the next record from input stream, invalidating current block data

Parameters:
  `stream` -

### getRecordBytes

public byte[] getRecordBytes()
Returns the byte[] for the block of data we are currently decoding

Returns:

### getBlockSize

public int getBlockSize()
The size of the current block in bytes

Returns:

### blockIsFullyDecoded

public boolean blockIsFullyDecoded()

### setRecordBytes

public void setRecordBytes(byte[] recordBytes)
Use the recordBytes[] to read BCF2 records from now on

Parameters:
  `recordBytes` -

### decodeTypedValue

public final Object decodeTypedValue() throws IOException

Throws:
  `IOException`

### decodeTypedValue

public final Object decodeTypedValue(byte typeDescriptor) throws IOException

Throws:
  `IOException`

### decodeTypedValue

public final Object decodeTypedValue(byte typeDescriptor, int size) throws IOException

Throws:
  `IOException`

### decodeSingleValue

public final Object decodeSingleValue(BCF2Type type) throws IOException

Throws:
  `IOException`

### decodeNumberOfElements

public final int decodeNumberOfElements(byte typeDescriptor) throws IOException

Throws:
  `IOException`

### decodeInt

public final int decodeInt(byte typeDescriptor, int missingValue) throws IOException
Decode an int from the stream. If the value in the stream is missing, returns missingValue. Requires the typeDescriptor indicate an inline single element event

Parameters:
  `typeDescriptor` -
Returns:
Throws:
  `IOException`

### decodeInt

public final int decodeInt(BCF2Type type) throws IOException

Throws:
  `IOException`

### decodeIntArray

public final int[] decodeIntArray(int size, BCF2Type type, int[] maybeDest) throws IOException
Low-level reader for int[] Requires a typeDescriptor so the function knows how many elements to read, and how they are encoded. If size == 0 => result is null If size > 0 => result depends on the actual values in the stream -- If the first element read is MISSING, result is null (all values are missing) -- Else result = int[N] where N is the first N non-missing values decoded

Parameters:
  `maybeDest` - if not null we'll not allocate space for the vector, but instead use the externally allocated array of ints to store values. If the size of this vector is < the actual size of the elements, we'll be forced to use freshly allocated arrays. Also note that padded int elements are still forced to do a fresh allocation as well.
Returns:
  see description
Throws:
  `IOException`

### decodeIntArray

public final int[] decodeIntArray(byte typeDescriptor, int size) throws IOException

Throws:
  `IOException`

### readBlockSize

public final int readBlockSize(InputStream inputStream) throws IOException
Read the size of the next block from inputStream

Parameters:
  `inputStream` -
Returns:
Throws:
  `IOException`

### readTypeDescriptor

public final byte readTypeDescriptor() throws IOException

Throws:
  `IOException`