Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make EncoderJNI and EncoderJNI.Wrapper public #124

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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