Skip to content

Commit

Permalink
Make EncoderJNI and EncoderJNI.Wrapper public (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
deshanxiao committed Dec 28, 2023
1 parent 3575fd7 commit f2e0978
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* JNI wrapper for brotli encoder.
*/
@Upstream
class EncoderJNI {
public class EncoderJNI {
private static native ByteBuffer nativeCreate(long[] context);
private static native void nativePush(long[] context, int length);
private static native ByteBuffer nativePull(long[] context);
Expand Down Expand Up @@ -73,12 +73,12 @@ static PreparedDictionary prepareDictionary(ByteBuffer dictionary, int sharedDic
return new PreparedDictionaryImpl(dictionaryData, dictionary);
}

static class Wrapper {
public static class Wrapper {
protected final long[] context = new long[5];
private final ByteBuffer inputBuffer;
private boolean fresh = true;

Wrapper(int inputBufferSize, int quality, int lgwin, Encoder.Mode mode)
public Wrapper(int inputBufferSize, int quality, int lgwin, Encoder.Mode mode)
throws IOException {
if (inputBufferSize <= 0) {
throw new IOException("buffer size must be positive");
Expand All @@ -97,7 +97,7 @@ static class Wrapper {
this.context[4] = 0;
}

boolean attachDictionary(ByteBuffer dictionary) {
public boolean attachDictionary(ByteBuffer dictionary) {
if (!dictionary.isDirect()) {
throw new IllegalArgumentException("only direct buffers allowed");
}
Expand All @@ -110,7 +110,7 @@ boolean attachDictionary(ByteBuffer dictionary) {
return nativeAttachDictionary(context, dictionary);
}

void push(Operation op, int length) {
public void push(Operation op, int length) {
if (length < 0) {
throw new IllegalArgumentException("negative block length");
}
Expand All @@ -128,27 +128,27 @@ void push(Operation op, int length) {
nativePush(context, length);
}

boolean isSuccess() {
public boolean isSuccess() {
return context[1] != 0;
}

boolean hasMoreOutput() {
public boolean hasMoreOutput() {
return context[2] != 0;
}

boolean hasRemainingInput() {
public boolean hasRemainingInput() {
return context[3] != 0;
}

boolean isFinished() {
public boolean isFinished() {
return context[4] != 0;
}

ByteBuffer getInputBuffer() {
public ByteBuffer getInputBuffer() {
return inputBuffer;
}

ByteBuffer pull() {
public ByteBuffer pull() {
if (context[0] == 0) {
throw new IllegalStateException("brotli encoder is already destroyed");
}
Expand All @@ -162,7 +162,7 @@ ByteBuffer pull() {
/**
* Releases native resources.
*/
void destroy() {
public void destroy() {
if (context[0] == 0) {
throw new IllegalStateException("brotli encoder is already destroyed");
}
Expand Down

0 comments on commit f2e0978

Please sign in to comment.