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 class
GZipCompressor.ByteGZipCompressor
Byte compress is a special case, the only one that does not extends GZipCompress because it can write the buffer directly.static class
GZipCompressor.DoubleGZipCompressor
static class
GZipCompressor.FloatGZipCompressor
static class
GZipCompressor.IntGZipCompressor
static class
GZipCompressor.LongGZipCompressor
static class
GZipCompressor.ShortGZipCompressor
private class
GZipCompressor.TypeConversion<B extends java.nio.Buffer>
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
buffer
private static int
DEFAULT_GZIP_BUFFER_SIZE
private static int
MINIMAL_GZIP_BUFFER_SIZE
protected T
nioBuffer
protected int
primitiveSize
private byte[]
sizeArray
private java.nio.IntBuffer
sizeBuffer
-
Constructor Summary
Constructors Constructor Description GZipCompressor(int primitiveSize)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
compress(T pixelData, java.nio.ByteBuffer compressed)
compress the buffer into the byte buffer.protected java.util.zip.GZIPInputStream
createGZipInputStream(java.nio.ByteBuffer compressed)
protected java.util.zip.GZIPOutputStream
createGZipOutputStream(int length, java.nio.ByteBuffer compressed)
void
decompress(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 void
getPixel(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 void
setPixel(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:ICompressor
compress the buffer into the byte buffer. Attention enough space must already be allocated.- Specified by:
compress
in 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:ICompressor
Decompress the byte buffer and restore the buffer from it, again enough space must already be allocated.- Specified by:
decompress
in 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)
-
-