-
Notifications
You must be signed in to change notification settings - Fork 6
Core module java rewrite #341
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
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
cc69523
Add support for java protobuf generation and port java files from pro…
nk2IsHere a8d6951
Port java part of core to java module
nk2IsHere f43448a
Port most of scala parts to java module
nk2IsHere 82723e4
Port some of tests
nk2IsHere bec285b
Split out Rdf
nk2IsHere bfe41e4
var -> final var
nk2IsHere 8ddb579
Comments pt 1
nk2IsHere fc0ad1d
Refactor proto encoder decoder to use handlers for decoding
nk2IsHere 2f7df9f
Finish all tests to compilable state
nk2IsHere bd2126a
Reformat
nk2IsHere 5c7f99f
Update tests to not fail pt 1
nk2IsHere c1891d5
Update tests to not fail pt 2
nk2IsHere 8a194d0
All tests pass
nk2IsHere a3ae706
Fix compilation of java core
nk2IsHere 42f4aba
Restore documentation
nk2IsHere c188aa5
Add factories
nk2IsHere 5530fb0
Move to eu.neverblink
nk2IsHere 9cf0c90
Update docs for ProtoHandler
nk2IsHere 6462ff7
Remove sinces
nk2IsHere 70e381c
Force jelly transcoder to be non-overridable
nk2IsHere 671dd49
Refactor to remove triples, graphs and quads as nodes
nk2IsHere c277a32
Generify proto encoder
nk2IsHere eca4893
Add triple or quad statement handler
nk2IsHere 15e354e
Comments
nk2IsHere 0cbfa27
Comments 2
nk2IsHere eb66018
Comments 3
nk2IsHere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
core-java/src/main/java/eu/neverblink/jelly/core/JellyConstants.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package eu.neverblink.jelly.core; | ||
|
|
||
| public class JellyConstants { | ||
|
|
||
| private JellyConstants() {} | ||
|
|
||
| public static final String JELLY_NAME = "Jelly"; | ||
| public static final String JELLY_FILE_EXTENSION = "jelly"; | ||
| public static final String JELLY_CONTENT_TYPE = "application/x-jelly-rdf"; | ||
|
|
||
| public static final int PROTO_VERSION_1_0_X = 1; | ||
| public static final int PROTO_VERSION_1_1_X = 2; | ||
| public static final int PROTO_VERSION = PROTO_VERSION_1_1_X; | ||
|
|
||
| public static final String PROTO_SEMANTIC_VERSION_1_0_0 = "1.0.0"; // First protocol version | ||
| public static final String PROTO_SEMANTIC_VERSION_1_1_0 = "1.1.0"; // Protocol version with namespace declarations | ||
| public static final String PROTO_SEMANTIC_VERSION_1_1_1 = "1.1.1"; // Protocol version with metadata in RdfStreamFrame | ||
| public static final String PROTO_SEMANTIC_VERSION = PROTO_SEMANTIC_VERSION_1_1_1; | ||
| } |
120 changes: 120 additions & 0 deletions
120
core-java/src/main/java/eu/neverblink/jelly/core/JellyConverterFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| package eu.neverblink.jelly.core; | ||
|
|
||
| import eu.neverblink.jelly.core.internal.ProtoDecoderImpl; | ||
| import eu.neverblink.jelly.core.internal.ProtoEncoderImpl; | ||
| import eu.neverblink.jelly.core.proto.v1.RdfStreamOptions; | ||
|
|
||
| /** | ||
| * "Main" interface to be implemented by RDF conversion modules (e.g., for Jena and RDF4J). | ||
| * Exposes factory methods for building protobuf encoders and decoders. | ||
| * <p> | ||
| * This should typically be implemented as an object. You should also provide a package-scoped given for your | ||
| * implementation so that users can easily make use of the connector in the stream package. | ||
| * | ||
| * @param <TNode> Type of RDF nodes in the RDF library | ||
| * @param <TDatatype> Type of RDF datatypes in the RDF library | ||
| * @param <TEncoderConverter> Implementation of ProtoEncoderConverter for a given RDF library. | ||
| * @param <TDecoderConverter> Implementation of ProtoDecoderConverter for a given RDF library. | ||
| */ | ||
| public abstract class JellyConverterFactory< | ||
| TNode, | ||
| TDatatype, | ||
| TEncoderConverter extends ProtoEncoderConverter<TNode>, | ||
| TDecoderConverter extends ProtoDecoderConverter<TNode, TDatatype> | ||
| > { | ||
|
|
||
| /** | ||
| * To be implemented by subclasses. Returns an instance of ProtoEncoderConverter for the RDF library. | ||
| */ | ||
| protected abstract TEncoderConverter encoderConverter(); | ||
|
|
||
| /** | ||
| * To be implemented by subclasses. Returns an instance of ProtoDecoderConverter for the RDF library. | ||
| */ | ||
| protected abstract TDecoderConverter decoderConverter(); | ||
|
|
||
| /** | ||
| * Create a new ProtoEncoder. | ||
| * @param params Parameters for the encoder. | ||
| * @return encoder | ||
| */ | ||
| public final ProtoEncoder<TNode> encoder(ProtoEncoder.Params params) { | ||
| return new ProtoEncoderImpl<>(encoderConverter(), params); | ||
| } | ||
|
|
||
| /** | ||
| * Create a new TriplesDecoder. | ||
| * @param supportedOptions maximum supported options for the decoder. If not provided, this.defaultSupportedOptions | ||
| * will be used. If you want to modify this (e.g., to specify an expected logical stream | ||
| * type), you should always use this.defaultSupportedOptions.withXxx. | ||
| * namespace prefix (without a colon), the second is the IRI node. | ||
| * @param tripleHandler the handler to use for decoding triples | ||
| * @return decoder | ||
| */ | ||
| public final ProtoDecoder<TNode, TDatatype> triplesDecoder( | ||
| RdfHandler.TripleHandler<TNode> tripleHandler, | ||
| RdfStreamOptions supportedOptions | ||
| ) { | ||
| return new ProtoDecoderImpl.TriplesDecoder<>(decoderConverter(), tripleHandler, supportedOptions); | ||
| } | ||
|
|
||
| /** | ||
| * Create a new QuadsDecoder. | ||
| * @param supportedOptions maximum supported options for the decoder. If not provided, this.defaultSupportedOptions | ||
| * will be used. If you want to modify this (e.g., to specify an expected logical stream | ||
| * type), you should always use this.defaultSupportedOptions.toBuilder().setXxx.build();. | ||
| * @param quadHandler the handler to use for decoding quads | ||
| * @return decoder | ||
| */ | ||
| public final ProtoDecoder<TNode, TDatatype> quadsDecoder( | ||
| RdfHandler.QuadHandler<TNode> quadHandler, | ||
| RdfStreamOptions supportedOptions | ||
| ) { | ||
| return new ProtoDecoderImpl.QuadsDecoder<>(decoderConverter(), quadHandler, supportedOptions); | ||
| } | ||
|
|
||
| /** | ||
| * Create a new GraphsAsQuadsDecoder. | ||
| * @param supportedOptions maximum supported options for the decoder. If not provided, this.defaultSupportedOptions | ||
| * will be used. If you want to modify this (e.g., to specify an expected logical stream | ||
| * type), you should always use this.defaultSupportedOptions.toBuilder().setXxx.build();. | ||
| * @param graphHandler the handler to use for decoding graphs | ||
| * @return decoder | ||
| */ | ||
| public final ProtoDecoder<TNode, TDatatype> graphsAsQuadsDecoder( | ||
| RdfHandler.QuadHandler<TNode> graphHandler, | ||
| RdfStreamOptions supportedOptions | ||
| ) { | ||
| return new ProtoDecoderImpl.GraphsAsQuadsDecoder<>(decoderConverter(), graphHandler, supportedOptions); | ||
| } | ||
|
|
||
| /** | ||
| * Create a new GraphsDecoder. | ||
| * @param supportedOptions maximum supported options for the decoder. If not provided, this.defaultSupportedOptions | ||
| * will be used. If you want to modify this (e.g., to specify an expected logical stream | ||
| * type), you should always use this.defaultSupportedOptions.toBuilder().setXxx.build();. | ||
| * @param graphHandler the handler to use for decoding graphs | ||
| * @return decoder | ||
| */ | ||
| public final ProtoDecoder<TNode, TDatatype> graphsDecoder( | ||
| RdfHandler.GraphHandler<TNode> graphHandler, | ||
| RdfStreamOptions supportedOptions | ||
| ) { | ||
| return new ProtoDecoderImpl.GraphsDecoder<>(decoderConverter(), graphHandler, supportedOptions); | ||
| } | ||
|
|
||
| /** | ||
| * Create a new AnyStatementDecoder. | ||
| * @param supportedOptions maximum supported options for the decoder. If not provided, this.defaultSupportedOptions | ||
| * will be used. If you want to modify this (e.g., to specify an expected logical stream | ||
| * type), you should always use this.defaultSupportedOptions.toBuilder().setXxx.build();. | ||
| * @param anyStatementHandler the handler to use for decoding any statements | ||
| * @return decoder | ||
| */ | ||
| public final ProtoDecoder<TNode, TDatatype> anyStatementDecoder( | ||
| RdfHandler.AnyStatementHandler<TNode> anyStatementHandler, | ||
| RdfStreamOptions supportedOptions | ||
| ) { | ||
| return new ProtoDecoderImpl.AnyStatementDecoder<>(decoderConverter(), anyStatementHandler, supportedOptions); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.