Class BaseCodec

java.lang.Object
loci.formats.codec.BaseCodec
All Implemented Interfaces:
Codec
Direct Known Subclasses:
JPEGXRCodec, NikonCodec, TargaRLECodec, WrappedCodec

public abstract class BaseCodec extends Object implements Codec
BaseCodec contains default implementation and testing for classes implementing the Codec interface, and acts as a base class for any of the compression classes. Base 1D compression and decompression methods are not implemented here, and are left as abstract. 2D methods do simple concatenation and call to the 1D methods
Author:
Eric Kjellman egkjellman at wisc.edu
  • Field Summary

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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    compress(byte[][] data, CodecOptions options)
    2D data block encoding default implementation.
    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
    Main testing method default implementation.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface loci.formats.codec.Codec

    compress
  • Field Details

    • LOGGER

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

    • BaseCodec

      public BaseCodec()
  • Method Details

    • test

      public void test() throws FormatException
      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:
      FormatException - Can only occur if there is a bug in the compress method.
    • compress

      public byte[] compress(byte[][] data, CodecOptions options) throws FormatException
      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:
      FormatException - If input is not a compressed data block of the appropriate type.
    • decompress

      public byte[] decompress(byte[] data) throws FormatException
      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:
      FormatException - If data is not valid compressed data for this decompressor.
    • decompress

      public byte[] decompress(byte[][] data) throws FormatException
      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:
      FormatException - If data is not valid compressed data for this decompressor.
    • decompress

      public byte[] decompress(byte[] data, CodecOptions options) throws FormatException
      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:
      FormatException - If data is not valid.
    • decompress

      public abstract byte[] decompress(loci.common.RandomAccessInputStream in, CodecOptions options) throws FormatException, 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:
      FormatException - If data is not valid compressed data for this decompressor.
      IOException
    • decompress

      public byte[] decompress(byte[][] data, CodecOptions options) throws FormatException
      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:
      FormatException - If input is not a compressed data block of the appropriate type.