/** * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static byte[] safeEncode(byte[] data, int offset, int length) { ChunkEncoder enc = ChunkEncoderFactory.safeInstance(length); byte[] result = encode(enc, data, offset, length); enc.close(); return result; }
/** * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static byte[] safeEncode(byte[] data, int offset, int length) { ChunkEncoder enc = ChunkEncoderFactory.safeInstance(length); byte[] result = encode(enc, data, offset, length); enc.close(); return result; }
/** * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static byte[] safeEncode(byte[] data, int offset, int length, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.safeInstance(length, bufferRecycler); byte[] result = encode(enc, data, offset, length); enc.close(); return result; }
/** * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static byte[] safeEncode(byte[] data, int offset, int length) { ChunkEncoder enc = ChunkEncoderFactory.safeInstance(length); byte[] result = encode(enc, data, offset, length); enc.close(); return result; }
/** * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static byte[] safeEncode(byte[] data, int offset, int length, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.safeInstance(length, bufferRecycler); byte[] result = encode(enc, data, offset, length); enc.close(); return result; }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalNonAllocatingInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static int appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr) { ChunkEncoder enc = ChunkEncoderFactory.optimalNonAllocatingInstance(inputLength); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalNonAllocatingInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static int appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr) { ChunkEncoder enc = ChunkEncoderFactory.optimalNonAllocatingInstance(inputLength); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
/** * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static byte[] safeEncode(byte[] data, int offset, int length, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.safeInstance(length, bufferRecycler); byte[] result = encode(enc, data, offset, length); enc.close(); return result; }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalNonAllocatingInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static int appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.optimalNonAllocatingInstance(inputLength, bufferRecycler); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
@Override public void close() throws IOException { _bufferPosition = _bufferLength = 0; byte[] buf = _encodedBytes; if (buf != null) { _encodedBytes = null; _recycler.releaseEncodeBuffer(buf); } if (_encoder != null) { _encoder.close(); } _closeInput(); }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static int safeAppendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr) { ChunkEncoder enc = ChunkEncoderFactory.safeNonAllocatingInstance(inputLength); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static int safeAppendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.safeNonAllocatingInstance(inputLength, bufferRecycler); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
/** * Method for compressing given input data using LZF encoding and * block structure (compatible with lzf command line utility). * Result consists of a sequence of chunks. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static byte[] encode(byte[] data, int offset, int length, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.optimalInstance(length, bufferRecycler); byte[] result = encode(enc, data, offset, length); enc.close(); // important for buffer reuse! return result; }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static int safeAppendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr) { ChunkEncoder enc = ChunkEncoderFactory.safeNonAllocatingInstance(inputLength); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Note that {@link ChunkEncoder} instance used is one produced by * {@link ChunkEncoderFactory#optimalNonAllocatingInstance}, which typically * is "unsafe" instance if one can be used on current JVM. */ public static int appendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.optimalNonAllocatingInstance(inputLength, bufferRecycler); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static int safeAppendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.safeNonAllocatingInstance(inputLength, bufferRecycler); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
@Override public void close() throws IOException { _bufferPosition = _bufferLength = 0; byte[] buf = _encodedBytes; if (buf != null) { _encodedBytes = null; _recycler.releaseEncodeBuffer(buf); } if (_encoder != null) { _encoder.close(); } _closeInput(); }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static int safeAppendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr) { ChunkEncoder enc = ChunkEncoderFactory.safeNonAllocatingInstance(inputLength); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
/** * Alternate version that accepts pre-allocated output buffer. *<p> * Method that will use "safe" {@link ChunkEncoder}, as produced by * {@link ChunkEncoderFactory#safeInstance}, for encoding. Safe here * means that it does not use any non-compliant features beyond core JDK. */ public static int safeAppendEncoded(byte[] input, int inputPtr, int inputLength, byte[] outputBuffer, int outputPtr, BufferRecycler bufferRecycler) { ChunkEncoder enc = ChunkEncoderFactory.safeNonAllocatingInstance(inputLength, bufferRecycler); int len = appendEncoded(enc, input, inputPtr, inputLength, outputBuffer, outputPtr); enc.close(); return len; }
@Override public void close() throws IOException { _bufferPosition = _bufferLength = 0; byte[] buf = _encodedBytes; if (buf != null) { _encodedBytes = null; _recycler.releaseEncodeBuffer(buf); } if (_encoder != null) { _encoder.close(); } _closeInput(); }