Package htsjdk.samtools.cram.compression

# Class CompressionUtils

java.lang.Object
htsjdk.samtools.cram.compression.CompressionUtils

public class CompressionUtils extends Object

## Constructor Summary

Constructors
Constructor
Description
`CompressionUtils()`

## Method Summary

Modifier and Type
Method
Description
`static ByteBuffer`
`allocateByteBuffer(int bufferSize)`
`static ByteBuffer`
`allocateOutputBuffer(int inSize)`
`static ByteBuffer`
`decodePack(ByteBuffer inBuffer, byte[] packMappingTable, int numSymbols, int uncompressedPackOutputLength)`
`static ByteBuffer`
`encodePack(ByteBuffer inBuffer, ByteBuffer outBuffer, int[] frequencyTable, int[] packMappingTable, int numSymbols)`
`static int`
`readUint7(ByteBuffer cp)`
`static ByteBuffer`
`slice(ByteBuffer inputBuffer)`
`static byte[]`
`toByteArray(ByteBuffer buffer)`
Return a byte array with a size that matches the limit of the provided ByteBuffer.
`static ByteBuffer`
`wrap(byte[] inputBytes)`
`static void`
`writeUint7(int i, ByteBuffer cp)`

### Methods inherited from class java.lang.Object

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

## Constructor Details

### CompressionUtils

public CompressionUtils()

## Method Details

### writeUint7

public static void writeUint7(int i, ByteBuffer cp)

### readUint7

public static int readUint7(ByteBuffer cp)

### encodePack

public static ByteBuffer encodePack(ByteBuffer inBuffer, ByteBuffer outBuffer, int[] frequencyTable, int[] packMappingTable, int numSymbols)

### decodePack

public static ByteBuffer decodePack(ByteBuffer inBuffer, byte[] packMappingTable, int numSymbols, int uncompressedPackOutputLength)

### allocateOutputBuffer

public static ByteBuffer allocateOutputBuffer(int inSize)

### allocateByteBuffer

public static ByteBuffer allocateByteBuffer(int bufferSize)

### wrap

public static ByteBuffer wrap(byte[] inputBytes)

### slice

public static ByteBuffer slice(ByteBuffer inputBuffer)

### toByteArray

public static byte[] toByteArray(ByteBuffer buffer)
Return a byte array with a size that matches the limit of the provided ByteBuffer. If the ByteBuffer is backed by a byte array that matches the limit of the ByteBuffer, the backing array will be returned directly. Otherwise, copy the contents of the ByteBuffer into a new byte array and return the new byte array.

Parameters:
  `buffer` - input ByteBuffer which is the source of the byte array
Returns:
  A byte array. If the ByteBuffer is backed by a byte array that matches the limit of the ByteBuffer, return the backing array directly. Otherwise, copy the contents of the ByteBuffer into a new byte array.