Package ome.codecs

Class BaseCodec

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static org.slf4j.Logger LOGGER  
    • Constructor Summary

      Constructors 
      Constructor Description
      BaseCodec()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] compress​(byte[][] data, CodecOptions options)
      2D data block encoding default implementation.
      java.nio.ByteBuffer compress​(java.nio.ByteBuffer target, byte[] data, CodecOptions options)
      Compress using ByteBuffers.
      byte[] decompress​(byte[] data)
      Decompresses a block of data.
      byte[] decompress​(byte[][] data)
      Decompresses a block of data.
      byte[] decompress​(byte[][] data, CodecOptions options)
      2D data block decoding default implementation.
      byte[] decompress​(byte[] data, CodecOptions options)
      Decompresses a block of data.
      abstract byte[] decompress​(loci.common.RandomAccessInputStream in, CodecOptions options)
      Decompresses data from the given RandomAccessInputStream.
      void test()
      Main testing method default implementation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        protected static final org.slf4j.Logger LOGGER
    • Constructor Detail

      • BaseCodec

        public BaseCodec()
    • Method Detail

      • test

        public void test()
                  throws CodecException
        Main testing method default implementation. This method tests whether the data is the same after compressing and decompressing, as well as doing a basic test of the 2D methods.
        Throws:
        CodecException - Can only occur if there is a bug in the compress method.
      • compress

        public byte[] compress​(byte[][] data,
                               CodecOptions options)
                        throws CodecException
        2D data block encoding default implementation. This method simply concatenates data[0] + data[1] + ... + data[i] into a 1D block of data, then calls the 1D version of compress.
        Specified by:
        compress in interface Codec
        Parameters:
        data - The data to be compressed.
        options - Options to be used during compression, if appropriate.
        Returns:
        The compressed data.
        Throws:
        CodecException - If input is not a compressed data block of the appropriate type.
      • compress

        public java.nio.ByteBuffer compress​(java.nio.ByteBuffer target,
                                            byte[] data,
                                            CodecOptions options)
                                     throws CodecException
        Compress using ByteBuffers. This implementation just calls the byte array based compression method and wraps the result properly.
        Specified by:
        compress in interface Codec
        Parameters:
        target - A preallocated ByteBuffer that may be used for the compressed data. This may be null to force the compressor to allocate a fresh buffer.
        data - The data to be compressed.
        options - Options to be used during compression, if appropriate.
        Returns:
        The ByteBuffer holding the compressed data.
        Throws:
        CodecException - If input cannot be processed.
        See Also:
        Codec.compress(ByteBuffer, byte[], CodecOptions)
      • decompress

        public byte[] decompress​(byte[] data)
                          throws CodecException
        Description copied from interface: Codec
        Decompresses a block of data.
        Specified by:
        decompress in interface Codec
        Parameters:
        data - the data to be decompressed.
        Returns:
        The decompressed data.
        Throws:
        CodecException - If data is not valid compressed data for this decompressor.
      • decompress

        public byte[] decompress​(byte[][] data)
                          throws CodecException
        Description copied from interface: Codec
        Decompresses a block of data.
        Specified by:
        decompress in interface Codec
        Parameters:
        data - The data to be decompressed.
        Returns:
        The decompressed data.
        Throws:
        CodecException - If data is not valid compressed data for this decompressor.
      • decompress

        public byte[] decompress​(byte[] data,
                                 CodecOptions options)
                          throws CodecException
        Description copied from interface: Codec
        Decompresses a block of data.
        Specified by:
        decompress in interface Codec
        Parameters:
        data - the data to be decompressed
        options - Options to be used during decompression.
        Returns:
        the decompressed data.
        Throws:
        CodecException - If data is not valid.
      • decompress

        public abstract byte[] decompress​(loci.common.RandomAccessInputStream in,
                                          CodecOptions options)
                                   throws CodecException,
                                          java.io.IOException
        Description copied from interface: Codec
        Decompresses data from the given RandomAccessInputStream.
        Specified by:
        decompress in interface Codec
        Parameters:
        in - The stream from which to read compressed data.
        options - Options to be used during decompression.
        Returns:
        The decompressed data.
        Throws:
        CodecException - If data is not valid compressed data for this decompressor.
        java.io.IOException
      • decompress

        public byte[] decompress​(byte[][] data,
                                 CodecOptions options)
                          throws CodecException
        2D data block decoding default implementation. This method simply concatenates data[0] + data[1] + ... + data[i] into a 1D block of data, then calls the 1D version of decompress.
        Specified by:
        decompress in interface Codec
        Parameters:
        data - The data to be decompressed.
        options - Options to be used during decompression.
        Returns:
        The decompressed data.
        Throws:
        CodecException - If input is not a compressed data block of the appropriate type.