GitHub user stain opened a pull request:

    https://github.com/apache/incubator-commonsrdf/pull/21

    Add RDFParserBuilder interface

    This pull request proposes a `RDFParserBuilder` interface - a "Builder for 
parsing an RDF source into a Graph".
    
    The javadocs explain the approach:
    
    * 
http://stain.github.io/incubator-commonsrdf/rdfparserbuilder/org/apache/commons/rdf/api/RDFParserBuilder.html
    * 
http://stain.github.io/incubator-commonsrdf/rdfparserbuilder/org/apache/commons/rdf/simple/AbstractRDFParserBuilder.html
    
    `AbstractRDFParserBuilder` is here part of `simple` (but has no 
implementation in there as Simple has no parsers) - and basically takes care of 
handling the 'builder' aspect in an immutable way - but also does some more 
generic checking and thread handling which implementations may override.
    
    It could be that these two aspects of AbstractRDFParserBuilder could be 
split, and a neutral bean-like builder abstract class could be added to `api`, 
and the more checker-helper-things to another abstract subclass in `simple`.
    
    
    I think once we agree on the style it's easier to do the equivalent Writer 
interface - but feel free to contribute to the `parser-writer-interface` branch!
    
    Example implementations:
    
    - [jsonld 
branch](https://github.com/apache/incubator-commonsrdf/blob/jsonld-java/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdParserBuilder.java)
    - [stain/jena 
branch](https://github.com/stain/incubator-commonsrdf/blob/jena/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFParserBuilder.java)
  (builds on Andy's https://github.com/afs/commonsrdf-jena)
    
    Example usage:
    
    ```java
    IRI iri = factory.createIRI("http://example.com/example.jsonld";);
    Graph g = new JsonLdParserBuilder()
                                
.contentType(RDFSyntax.JSONLD).source(iri).parse()
                                .get(10, TimeUnit.SECONDS);
    ```
    
    Some things to discuss:
    
    - Should this merge the `quad` branch from #19 and add 
`intoDataset(Dataset)`?  Would the return type from `parse()` then be a 
`Future<GraphOrDataset>`? (Or would a `ParseResult` wrapper be better?)
    - How can `RDFParserBuilder` implementations be discovered? Another 
`ServiceLoader`, or part of `RDFTermFactory` (which then need to change name to 
just `RDFFactory` ?)
    - Should there be a kind of `canHandle(RDFSyntax)` method, or would you ask 
for the parser with `rdfFactory.getParser(RDFSyntax.JSONLD)` instead?  (Note: 
sometimes the content type is not known in advance, e.g. URIs on the internet)
    - Should there be a concrete implementation that calls down to more 
lower-level parser interfaces? E.g. equivalent to Jena's `RDFDataMgr`?
    
    Note - my branch with jsonld-java is a bit of an outlier as it's not a 
complete RDF framework and mainly does JSON-LD - however N-Quad and Turtle 
support is already part of jsonld-java - however I'm not sure if that is just 
for parsing or writing.  We would expect most of the bigger frameworks to do 
most of the standard syntaxes we enumerated in 
[RDFSyntax](https://commonsrdf.incubator.apache.org/apidocs/org/apache/commons/rdf/api/RDFSyntax.html)

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/apache/incubator-commonsrdf 
parser-writer-interface

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-commonsrdf/pull/21.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #21
    
----
commit 5993d9323c3db1946b9115eeca7fbe2d62435f86
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-03-27T18:39:57Z

    RDFParserBuilder

commit 0693671569bcfec02ec616fb6d88901da7c602a3
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-03-27T19:11:00Z

    charset fun

commit 366759224381711c943b4d39590cee214a12d3ee
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-03-27T19:25:55Z

    javadoc syntax

commit 4aacf85cb328f96fd619e98337980f65b894d6e4
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-03-27T20:32:26Z

    javadoc typos

commit dcf43835742e90dcc7668b5ecaca44415e4bbc23
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-03-27T20:47:26Z

    More source() docs

commit 5e41513aaa4a5f71e979a65a7e221e64cf7cd4d1
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-03-27T20:57:18Z

    about asynchronous stuff

commit 6f1f669a38a05e61d40cbbfd1572e0127244669b
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-03-28T01:06:16Z

    RDFParserBuilder javadoc on exceptions

commit 8d548d5005eef1ebf373bf666f31af039ad58c04
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-04-01T16:05:34Z

    An abstract implementation of RDFParserBuilder

commit 8dfc3f4eef9afda61cecf088be42c8a9ee547865
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-04-02T23:22:48Z

    Test AbstractRDFParserBuilder

commit 478b20e27b2e24494d20d6edbf7a80c3604a7879
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-04-02T23:53:48Z

    Add guessRDFSyntax() convenience method

commit 528af9976ce03280578f82531a95a49a3546b238
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-04-03T00:47:16Z

    Some AbstractRDFParserBuilder tests

commit b1597ff7bac433f23a78b0eacbf5a5b5e7ffb089
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-04-03T01:47:31Z

    BlankNode RDFTermFactory warning

commit c3fd214abd8c291635deb4ba9bf7881c166931a0
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-04-03T01:47:34Z

    javadoc typos

commit b4342b94fa6ff992986bf6141325f97d6d6a4583
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-04-03T01:54:28Z

    more about builder pattern

commit df35ebca2329019ae9468176eb6467b7ce0ba9bf
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-04-03T02:11:28Z

    DFParserBuilder javadoc on error conditions

commit 13a6b07d864e7a4693139f5f75e85dd66c09b5fd
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-04-03T02:12:08Z

    javadoc typos

commit dc7589fa454ce0401c7576052ddacda269b07f6b
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-04-04T14:50:31Z

    Merge branch 'master' into parser-writer-interface

commit 1b5f3160f590867d48247bba953cf39ca663456b
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-04-08T11:00:45Z

    contentType(String) also throws IllegalArgumentException
    
    Added checkContentType() for subclasses

commit d153b4cb6837ba52b3a119bb3846bfc02bfb8ae9
Author: Stian Soiland-Reyes <[email protected]>
Date:   2016-04-12T08:11:26Z

    RDFParseException instead of ParseException
    
    as ParseException requires location, and don't
    support getCause()

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to