Class Block


  • public class Block
    extends Object
    Class representing CRAM block concept and some methods to operate with block content. CRAM block is used to hold some (usually homogeneous) binary data. An external compression can be applied to the content of a block. The class provides some instantiation static methods, for example to read a block from an input stream. Blocks can be written out to an output stream, this may be considered as a way to serialize/deserialize blocks.
    • Constructor Detail

      • Block

        public Block()
    • Method Detail

      • readFromInputStream

        public static Block readFromInputStream​(int major,
                                                InputStream inputStream)
                                         throws IOException
        Deserialize the block from the InputStream. The reading is parametrized by the major CRAM version number.
        Parameters:
        major - CRAM version major number
        inputStream - input stream to read the block from
        Returns:
        a new Block object with fields and content from the input stream
        Throws:
        IOException - as per java IO contract
      • buildNewSliceHeaderBlock

        public static Block buildNewSliceHeaderBlock​(byte[] rawContent)
        Create a new slice header block with the given uncompressed content. The block wil have RAW (no compression) and MAPPED_SLICE content type.
        Parameters:
        rawContent - the content of the block
        Returns:
        a new mapped slice Block object
      • buildNewCore

        public static Block buildNewCore​(byte[] rawContent)
        Create a new core block with the given uncompressed content. The block wil have RAW (no compression) and CORE content type.
        Parameters:
        rawContent - the content of the block
        Returns:
        a new core Block object
      • buildNewFileHeaderBlock

        public static Block buildNewFileHeaderBlock​(byte[] rawContent)
        Create a new core block with the given uncompressed content. The block wil have RAW (no compression) and CORE content type.
        Parameters:
        rawContent - the content of the block
        Returns:
        a new core Block object
      • setRawContent

        public void setRawContent​(byte[] raw)
      • getRawContent

        public byte[] getRawContent()
      • getRawContentSize

        public int getRawContentSize()
      • setContent

        public void setContent​(byte[] raw,
                               byte[] compressed)
      • write

        public void write​(int major,
                          OutputStream outputStream)
                   throws IOException
        Write the block out to the the specified OutputStream. The method is parametrized with CRAM major version number.
        Parameters:
        major - CRAM version major number
        outputStream - output stream to write to
        Throws:
        IOException - as per java IO contract
      • getContentId

        public int getContentId()
      • setContentId

        public void setContentId​(int contentId)
      • getCompressedContentSize

        public int getCompressedContentSize()