diff options
Diffstat (limited to 'java/org/brotli/wrapper/dec/DecoderJNI.java')
-rw-r--r-- | java/org/brotli/wrapper/dec/DecoderJNI.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/java/org/brotli/wrapper/dec/DecoderJNI.java b/java/org/brotli/wrapper/dec/DecoderJNI.java index 2319b1e..fc5225d 100644 --- a/java/org/brotli/wrapper/dec/DecoderJNI.java +++ b/java/org/brotli/wrapper/dec/DecoderJNI.java @@ -17,6 +17,7 @@ public class DecoderJNI { private static native void nativePush(long[] context, int length); private static native ByteBuffer nativePull(long[] context); private static native void nativeDestroy(long[] context); + private static native boolean nativeAttachDictionary(long[] context, ByteBuffer dictionary); public enum Status { ERROR, @@ -40,6 +41,19 @@ public class DecoderJNI { } } + public boolean attachDictionary(ByteBuffer dictionary) { + if (!dictionary.isDirect()) { + throw new IllegalArgumentException("only direct buffers allowed"); + } + if (context[0] == 0) { + throw new IllegalStateException("brotli decoder is already destroyed"); + } + if (!fresh) { + throw new IllegalStateException("decoding is already started"); + } + return nativeAttachDictionary(context, dictionary); + } + public void push(int length) { if (length < 0) { throw new IllegalArgumentException("negative block length"); |