Package htsjdk.samtools.cram.io
Class ITF8
- java.lang.Object
-
- htsjdk.samtools.cram.io.ITF8
-
public class ITF8 extends Object
Methods to read and write int values as per ITF8 specification in CRAM.
-
-
Constructor Summary
Constructors Constructor Description ITF8()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intreadUnsignedITF8(byte[] data)Reads an unsigned (32 bit) integer from an array of bytes.static intreadUnsignedITF8(InputStream inputStream)Reads an unsigned (32 bit) integer from anInputStream.static intreadUnsignedITF8(ByteBuffer buffer)Reads an unsigned (32 bit) integer from aByteBuffer.static byte[]writeUnsignedITF8(int value)Writes an unsigned (32 bit) integer to a byte new array encoded as ITF8.static intwriteUnsignedITF8(int value, OutputStream outputStream)Writes an unsigned (32 bit) integer to anOutputStreamencoded as ITF8.static voidwriteUnsignedITF8(int value, ByteBuffer buffer)Writes an unsigned (32 bit) integer to anOutputStreamencoded as ITF8.
-
-
-
Method Detail
-
readUnsignedITF8
public static int readUnsignedITF8(InputStream inputStream) throws IOException
Reads an unsigned (32 bit) integer from anInputStream. The sign bit should be interpreted as a value bit.- Parameters:
inputStream- the stream to read from- Returns:
- the value read
- Throws:
IOException- as per java IO contract
-
writeUnsignedITF8
public static int writeUnsignedITF8(int value, OutputStream outputStream) throws IOExceptionWrites an unsigned (32 bit) integer to anOutputStreamencoded as ITF8. The sign bit is interpreted as a value bit.- Parameters:
value- the value to be written outoutputStream- the stream to write to- Returns:
- number of bits written
- Throws:
IOException- as per java IO contract
-
readUnsignedITF8
public static int readUnsignedITF8(byte[] data)
Reads an unsigned (32 bit) integer from an array of bytes. The sign bit should be interpreted as a value bit.- Parameters:
data- the bytes to read from- Returns:
- the value read
-
writeUnsignedITF8
public static byte[] writeUnsignedITF8(int value)
Writes an unsigned (32 bit) integer to a byte new array encoded as ITF8. The sign bit is interpreted as a value bit.- Parameters:
value- the value to be written out- Returns:
- the bytes holding ITF8 representation of the value
-
readUnsignedITF8
public static int readUnsignedITF8(ByteBuffer buffer)
Reads an unsigned (32 bit) integer from aByteBuffer. The sign bit should be interpreted as a value bit.- Parameters:
buffer- the bytes to read from- Returns:
- unsigned integer value from the buffer
-
writeUnsignedITF8
public static void writeUnsignedITF8(int value, ByteBuffer buffer)Writes an unsigned (32 bit) integer to anOutputStreamencoded as ITF8. The sign bit is interpreted as a value bit.- Parameters:
value- the value to be written outbuffer- theByteBufferto write to
-
-