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

(feat) lib: expose api() and handle() #11

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
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
23 changes: 22 additions & 1 deletion lib/src/main/java/org/pcre4j/Pcre2Code.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@
public class Pcre2Code {

private static final Cleaner cleaner = Cleaner.create();

/**
* The compiled pattern handle
*/
/* package-private */ final long handle;

/**
* The PCRE2 API reference to use across the entire lifecycle of the object
*/
private final IPcre2 api;
/* package-private */ final IPcre2 api;

/**
* The cleaner to free the compiled pattern
*/
Expand Down Expand Up @@ -120,6 +123,24 @@
throw new Pcre2PatternInfoSizeError(Pcre2PatternInfo.valueOf(IPcre2.INFO_FRAMESIZE).orElseThrow(), infoSize);
}

/**
* Get the PCRE2 API backing this compiled pattern
*
* @return the PCRE2 API
*/
public IPcre2 api() {
return api;

Check warning on line 132 in lib/src/main/java/org/pcre4j/Pcre2Code.java

View check run for this annotation

Codecov / codecov/patch

lib/src/main/java/org/pcre4j/Pcre2Code.java#L132

Added line #L132 was not covered by tests
}

/**
* Get the handle of the compiled pattern
*
* @return the handle of the compiled pattern
*/
public long handle() {
return handle;

Check warning on line 141 in lib/src/main/java/org/pcre4j/Pcre2Code.java

View check run for this annotation

Codecov / codecov/patch

lib/src/main/java/org/pcre4j/Pcre2Code.java#L141

Added line #L141 was not covered by tests
}

/**
* Get the number of highest backreference
*
Expand Down
23 changes: 22 additions & 1 deletion lib/src/main/java/org/pcre4j/Pcre2CompileContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
public class Pcre2CompileContext {

private static final Cleaner cleaner = Cleaner.create();

/**
* The compile context handle
*/
/* package-private */ final long handle;

/**
* The PCRE2 API reference to use across the entire lifecycle of the object
*/
private final IPcre2 api;
/* package-private */ final IPcre2 api;

/**
* The cleaner to free the resources
*/
Expand All @@ -54,6 +57,24 @@
this.cleanable = cleaner.register(this, new Pcre2CompileContext.Clean(api, handle));
}

/**
* Get the PCRE2 API backing this compile context
*
* @return the PCRE2 API
*/
public IPcre2 api() {
return api;

Check warning on line 66 in lib/src/main/java/org/pcre4j/Pcre2CompileContext.java

View check run for this annotation

Codecov / codecov/patch

lib/src/main/java/org/pcre4j/Pcre2CompileContext.java#L66

Added line #L66 was not covered by tests
}

/**
* Get the handle of the compile context
*
* @return the handle of the compile context
*/
public long handle() {
return handle;

Check warning on line 75 in lib/src/main/java/org/pcre4j/Pcre2CompileContext.java

View check run for this annotation

Codecov / codecov/patch

lib/src/main/java/org/pcre4j/Pcre2CompileContext.java#L75

Added line #L75 was not covered by tests
}

private record Clean(IPcre2 api, long compileContext) implements Runnable {
@Override
public void run() {
Expand Down
20 changes: 19 additions & 1 deletion lib/src/main/java/org/pcre4j/Pcre2GeneralContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* The PCRE2 API reference to use across the entire lifecycle of the object
*/
private final IPcre2 api;
/* package-private */ final IPcre2 api;
/**
* The cleaner to free the resources
*/
Expand All @@ -50,6 +50,24 @@
this.cleanable = cleaner.register(this, new Pcre2GeneralContext.Clean(api, handle));
}

/**
* Get the PCRE2 API backing this general context
*
* @return the PCRE2 API
*/
public IPcre2 api() {
return api;

Check warning on line 59 in lib/src/main/java/org/pcre4j/Pcre2GeneralContext.java

View check run for this annotation

Codecov / codecov/patch

lib/src/main/java/org/pcre4j/Pcre2GeneralContext.java#L59

Added line #L59 was not covered by tests
}

/**
* Get the handle of the general context
*
* @return the handle of the general context
*/
public long handle() {
return handle;

Check warning on line 68 in lib/src/main/java/org/pcre4j/Pcre2GeneralContext.java

View check run for this annotation

Codecov / codecov/patch

lib/src/main/java/org/pcre4j/Pcre2GeneralContext.java#L68

Added line #L68 was not covered by tests
}

private record Clean(IPcre2 api, long generalContext) implements Runnable {
@Override
public void run() {
Expand Down
20 changes: 19 additions & 1 deletion lib/src/main/java/org/pcre4j/Pcre2MatchContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* The PCRE2 API reference to use across the entire lifecycle of the object
*/
private final IPcre2 api;
/* package-private */ final IPcre2 api;
/**
* The cleaner to free the resources
*/
Expand All @@ -54,6 +54,24 @@
this.cleanable = cleaner.register(this, new Pcre2MatchContext.Clean(api, handle));
}

/**
* Get the PCRE2 API backing this match context
*
* @return the PCRE2 API
*/
public IPcre2 api() {
return api;

Check warning on line 63 in lib/src/main/java/org/pcre4j/Pcre2MatchContext.java

View check run for this annotation

Codecov / codecov/patch

lib/src/main/java/org/pcre4j/Pcre2MatchContext.java#L63

Added line #L63 was not covered by tests
}

/**
* Get the handle of the match context
*
* @return the handle of the match context
*/
public long handle() {
return handle;

Check warning on line 72 in lib/src/main/java/org/pcre4j/Pcre2MatchContext.java

View check run for this annotation

Codecov / codecov/patch

lib/src/main/java/org/pcre4j/Pcre2MatchContext.java#L72

Added line #L72 was not covered by tests
}

private record Clean(IPcre2 api, long matchContext) implements Runnable {
@Override
public void run() {
Expand Down
22 changes: 21 additions & 1 deletion lib/src/main/java/org/pcre4j/Pcre2MatchData.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
* The match data handle
*/
/* package-private */ final long handle;

/**
* The PCRE2 API reference to use across the entire lifecycle of the object
*/
private final IPcre2 api;
/* package-private */ final IPcre2 api;

/**
* The cleaner to free the resources
*/
Expand Down Expand Up @@ -79,6 +81,24 @@
this.cleanable = cleaner.register(this, new Pcre2MatchData.Clean(api, handle));
}

/**
* Get the PCRE2 API backing this match data
*
* @return the PCRE2 API
*/
public IPcre2 api() {
return api;

Check warning on line 90 in lib/src/main/java/org/pcre4j/Pcre2MatchData.java

View check run for this annotation

Codecov / codecov/patch

lib/src/main/java/org/pcre4j/Pcre2MatchData.java#L90

Added line #L90 was not covered by tests
}

/**
* Get the handle of the match data
*
* @return the handle of the match data
*/
public long handle() {
return handle;

Check warning on line 99 in lib/src/main/java/org/pcre4j/Pcre2MatchData.java

View check run for this annotation

Codecov / codecov/patch

lib/src/main/java/org/pcre4j/Pcre2MatchData.java#L99

Added line #L99 was not covered by tests
}

/**
* Get number of the offset pairs in the output vector
*
Expand Down