public class Block
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
NO_CONTENT_ID
Only external blocks have meaningful Content IDs
Other blocks are required to have a Content ID of 0
|
| Modifier | Constructor and Description |
|---|---|
protected |
Block(BlockCompressionMethod compressionMethod,
BlockContentType contentType,
int contentId,
byte[] compressedContent,
int uncompressedLength)
Protected constructor of a generic Block, to be called by static factory methods and subclasses.
|
| Modifier and Type | Method and Description |
|---|---|
static Block |
createExternalBlock(BlockCompressionMethod compressionMethod,
int contentId,
byte[] compressedContent,
int uncompressedLength)
Create a new external data block with the given compression method, uncompressed content, and content ID.
|
static Block |
createRawCompressionHeaderBlock(byte[] rawContent)
Create a new compression header block with the given uncompressed content.
|
static Block |
createRawCoreDataBlock(byte[] rawContent)
Create a new core data block with the given uncompressed content.
|
static Block |
createRawFileHeaderBlock(byte[] rawContent)
Create a new file header block with the given uncompressed content.
|
static Block |
createRawSliceHeaderBlock(byte[] rawContent)
Create a new slice header block with the given uncompressed content.
|
byte[] |
getCompressedContent() |
int |
getCompressedContentSize() |
BlockCompressionMethod |
getCompressionMethod() |
int |
getContentId()
Return the External Content ID for this block.
|
BlockContentType |
getContentType()
Identifies whether this is a header or data block, and which kind
|
byte[] |
getUncompressedContent()
Uncompress the stored block content (if not RAW) and return the uncompressed content.
|
int |
getUncompressedContentSize() |
static Block |
read(int major,
java.io.InputStream inputStream)
Deserialize the Block from the
InputStream. |
java.lang.String |
toString() |
void |
write(int major,
java.io.OutputStream outputStream)
Write the block out to the the specified
OutputStream. |
public static final int NO_CONTENT_ID
protected Block(BlockCompressionMethod compressionMethod, BlockContentType contentType, int contentId, byte[] compressedContent, int uncompressedLength)
compressionMethod - the block compression method. Can be RAW, if uncompressedcontentType - whether this is a header or data block, and which kindcontentId - the External Block Content ID, or NO_CONTENT_ID for non-External blockcompressedContent - the compressed form of the data to be stored in this blockuncompressedLength - the length of the content stored in this block when uncompressedpublic static Block createRawFileHeaderBlock(byte[] rawContent)
rawContent - the uncompressed content of the blockBlock objectpublic static Block createRawCompressionHeaderBlock(byte[] rawContent)
rawContent - the uncompressed content of the blockBlock objectpublic static Block createRawSliceHeaderBlock(byte[] rawContent)
rawContent - the uncompressed content of the blockBlock objectpublic static Block createRawCoreDataBlock(byte[] rawContent)
rawContent - the uncompressed content of the blockBlock objectpublic static Block createExternalBlock(BlockCompressionMethod compressionMethod, int contentId, byte[] compressedContent, int uncompressedLength)
compressionMethod - the compression method used in this blockcontentId - the external identifier for the blockcompressedContent - the content of this block, in compressed modeuncompressedLength - the length of the content stored in this block when uncompressedpublic final BlockCompressionMethod getCompressionMethod()
public final BlockContentType getContentType()
public int getContentId()
public final byte[] getUncompressedContent()
CRAMException - The uncompressed length did not match what was expected.public int getUncompressedContentSize()
public final byte[] getCompressedContent()
public final int getCompressedContentSize()
public static Block read(int major, java.io.InputStream inputStream)
InputStream. The reading is parameterized by the major CRAM version number.major - CRAM version major numberinputStream - input stream to read the block fromBlock object with fields and content from the input streampublic final void write(int major,
java.io.OutputStream outputStream)
OutputStream.
The method is parameterized with the CRAM major version number.major - CRAM version major numberoutputStream - output stream to write topublic java.lang.String toString()
toString in class java.lang.Object