Class GZipCompressor<T extends java.nio.Buffer>
- java.lang.Object
-
- nom.tam.fits.compression.algorithm.gzip.GZipCompressor<T>
-
- All Implemented Interfaces:
ICompressor<T>
- Direct Known Subclasses:
GZip2Compressor,GZipCompressor.ByteGZipCompressor,GZipCompressor.DoubleGZipCompressor,GZipCompressor.FloatGZipCompressor,GZipCompressor.IntGZipCompressor,GZipCompressor.LongGZipCompressor,GZipCompressor.ShortGZipCompressor
public abstract class GZipCompressor<T extends java.nio.Buffer> extends java.lang.Object implements ICompressor<T>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGZipCompressor.ByteGZipCompressorByte compress is a special case, the only one that does not extends GZipCompress because it can write the buffer directly.static classGZipCompressor.DoubleGZipCompressorstatic classGZipCompressor.FloatGZipCompressorstatic classGZipCompressor.IntGZipCompressorstatic classGZipCompressor.LongGZipCompressorstatic classGZipCompressor.ShortGZipCompressorprivate classGZipCompressor.TypeConversion<B extends java.nio.Buffer>
-
Field Summary
Fields Modifier and Type Field Description protected byte[]bufferprivate static intDEFAULT_GZIP_BUFFER_SIZEprivate static intMINIMAL_GZIP_BUFFER_SIZEprotected TnioBufferprotected intprimitiveSizeprivate byte[]sizeArrayprivate java.nio.IntBuffersizeBuffer
-
Constructor Summary
Constructors Constructor Description GZipCompressor(int primitiveSize)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancompress(T pixelData, java.nio.ByteBuffer compressed)compress the buffer into the byte buffer.protected java.util.zip.GZIPInputStreamcreateGZipInputStream(java.nio.ByteBuffer compressed)protected java.util.zip.GZIPOutputStreamcreateGZipOutputStream(int length, java.nio.ByteBuffer compressed)voiddecompress(java.nio.ByteBuffer compressed, T pixelData)Decompress the byte buffer and restore the buffer from it, again enough space must already be allocated.protected abstract voidgetPixel(T pixelData, byte[] pixelBytes)private <B extends java.nio.Buffer>
PrimitiveType<B>getPrimitiveType(int size)private GZipCompressor.TypeConversion<java.nio.Buffer>getTypeConverter(java.nio.ByteBuffer compressed, int nrOfPrimitiveElements)protected abstract voidsetPixel(T pixelData, byte[] pixelBytes)
-
-
-
Field Detail
-
DEFAULT_GZIP_BUFFER_SIZE
private static final int DEFAULT_GZIP_BUFFER_SIZE
- See Also:
- Constant Field Values
-
MINIMAL_GZIP_BUFFER_SIZE
private static final int MINIMAL_GZIP_BUFFER_SIZE
- See Also:
- Constant Field Values
-
primitiveSize
protected final int primitiveSize
-
buffer
protected byte[] buffer
-
nioBuffer
protected T extends java.nio.Buffer nioBuffer
-
sizeArray
private final byte[] sizeArray
-
sizeBuffer
private final java.nio.IntBuffer sizeBuffer
-
-
Method Detail
-
compress
public boolean compress(T pixelData, java.nio.ByteBuffer compressed)
Description copied from interface:ICompressorcompress the buffer into the byte buffer. Attention enough space must already be allocated.- Specified by:
compressin interfaceICompressor<T extends java.nio.Buffer>- Parameters:
pixelData- the buffer to compress.compressed- the compressed data- Returns:
- true if the compression succeeded.
-
decompress
public void decompress(java.nio.ByteBuffer compressed, T pixelData)Description copied from interface:ICompressorDecompress the byte buffer and restore the buffer from it, again enough space must already be allocated.- Specified by:
decompressin interfaceICompressor<T extends java.nio.Buffer>- Parameters:
compressed- the compressed datapixelData- the buffer to fill with the uncompressed data.
-
getPrimitiveType
private <B extends java.nio.Buffer> PrimitiveType<B> getPrimitiveType(int size)
-
getTypeConverter
private GZipCompressor.TypeConversion<java.nio.Buffer> getTypeConverter(java.nio.ByteBuffer compressed, int nrOfPrimitiveElements)
-
createGZipInputStream
protected java.util.zip.GZIPInputStream createGZipInputStream(java.nio.ByteBuffer compressed) throws java.io.IOException- Throws:
java.io.IOException
-
createGZipOutputStream
protected java.util.zip.GZIPOutputStream createGZipOutputStream(int length, java.nio.ByteBuffer compressed) throws java.io.IOException- Throws:
java.io.IOException
-
getPixel
protected abstract void getPixel(T pixelData, byte[] pixelBytes)
-
setPixel
protected abstract void setPixel(T pixelData, byte[] pixelBytes)
-
-