Quad-support for RDFParserBuildler This changes intoGraph() to target(?)
where ? can be a Graph, Dataset or Consumer<Quad> similarly parse() returns a Future<ParseResult> rather than Future<Graph> - as there might not be any Graph Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/defdbd91 Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/defdbd91 Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/defdbd91 Branch: refs/heads/jsonld-java Commit: defdbd9160561ae93e8558a8f2c6cc27507b22bb Parents: bb90a6e Author: Stian Soiland-Reyes <st...@apache.org> Authored: Wed Apr 13 16:50:31 2016 +0100 Committer: Stian Soiland-Reyes <st...@apache.org> Committed: Wed Apr 13 16:50:31 2016 +0100 ---------------------------------------------------------------------- .../commons/rdf/api/RDFParserBuilder.java | 174 ++++++++++++++----- .../rdf/simple/AbstractRDFParserBuilder.java | 61 ++++--- .../simple/AbstractRDFParserBuilderTest.java | 40 +++-- .../rdf/simple/DummyRDFParserBuilder.java | 34 ++-- 4 files changed, 209 insertions(+), 100 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/defdbd91/api/src/main/java/org/apache/commons/rdf/api/RDFParserBuilder.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/commons/rdf/api/RDFParserBuilder.java b/api/src/main/java/org/apache/commons/rdf/api/RDFParserBuilder.java index 1425263..0494502 100644 --- a/api/src/main/java/org/apache/commons/rdf/api/RDFParserBuilder.java +++ b/api/src/main/java/org/apache/commons/rdf/api/RDFParserBuilder.java @@ -22,58 +22,71 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.util.concurrent.Future; +import java.util.function.Consumer; /** - * Builder for parsing an RDF source into a Graph. + * Builder for parsing an RDF source into a target (e.g. a Graph/Dataset). * <p> * This interface follows the * <a href="https://en.wikipedia.org/wiki/Builder_pattern">Builder pattern</a>, * allowing to set parser settings like {@link #contentType(RDFSyntax)} and * {@link #base(IRI)}. A caller MUST call one of the <code>source</code> methods * (e.g. {@link #source(IRI)}, {@link #source(Path)}, - * {@link #source(InputStream)}) before calling {@link #parse()} on the returned + * {@link #source(InputStream)}), and MUST call one of the <code>target</code> + * methods (e.g. {@link #target(Consumer)}, {@link #target(Dataset)}, + * {@link #target(Graph)}) before calling {@link #parse()} on the returned * RDFParserBuilder - however methods can be called in any order. * <p> - * The call to {@link #parse()} returns a {@link Future}, allowing asynchronous parse - * operations. This can be combined with {@link #intoGraph(Graph)} - * allowing access to the graph before parsing has completed, - * however callers are still recommended to to check - * {@link Future#get()} for any exceptions thrown during parsing. + * The call to {@link #parse()} returns a {@link Future}, allowing asynchronous + * parse operations. Callers are recommended to check {@link Future#get()} to + * ensure parsing completed successfully, or catch exceptions thrown during + * parsing. * <p> * Setting a method that has already been set will override any existing value * in the returned builder - irregardless of the parameter type (e.g. * {@link #source(IRI)} will override a previous {@link #source(Path)}. Settings - * can be unset by passing <code>null</code> - this may require casting, e.g. - * <code>contentType( (RDFSyntax) null )</code> to undo a previous call to - * {@link #contentType(RDFSyntax)}. + * can be unset by passing <code>null</code> - note that this may + * require casting, e.g. <code>contentType( (RDFSyntax) null )</code> + * to undo a previous call to {@link #contentType(RDFSyntax)}. * <p> * It is undefined if a RDFParserBuilder is mutable or thread-safe, so callers * should always use the returned modified RDFParserBuilder from the builder - * methods. The builder may return itself, or a cloned builder with the modified - * settings applied. Implementations are however encouraged to be - * immutable and thread-safe and document this, - * as an example starting point, see + * methods. The builder may return itself after modification, + * or a cloned builder with the modified settings applied. + * Implementations are however encouraged to be immutable, + * thread-safe and document this. As an example starting point, see * {@link org.apache.commons.rdf.simple.AbstractRDFParserBuilder}. * <p> * Example usage: * </p> * * <pre> - * // Retrieve populated graph from the Future - * Graph g1 = ExampleRDFParserBuilder.source("http://example.com/graph.rdf").parse().get(30, TimeUnit.Seconds); - * // Or parsing into an existing Graph: - * ExampleRDFParserBuilder.source(Paths.get("/tmp/graph.ttl").contentType(RDFSyntax.TURTLE).intoGraph(g1).parse(); + * Graph g1 = rDFTermFactory.createGraph(); + * new ExampleRDFParserBuilder() + * .source(Paths.get("/tmp/graph.ttl")) + * .contentType(RDFSyntax.TURTLE) + * .target(g1) + * .parse().get(30, TimeUnit.Seconds); * </pre> - * * */ public interface RDFParserBuilder { + /** + * The result of {@link RDFParserBuilder#parse()} indicating + * parsing completed. + * <p> + * This is a marker interface that may be subclassed to include + * parser details, e.g. warning messages or triple counts. + */ + public interface ParseResult { + } + /** * Specify which {@link RDFTermFactory} to use for generating * {@link RDFTerm}s. * <p> - * This option may be used together with {@link #intoGraph(Graph)} to + * This option may be used together with {@link #target(Graph)} to * override the implementation's default factory and graph. * <p> * <strong>Warning:</strong> Using the same {@link RDFTermFactory} for @@ -82,7 +95,7 @@ public interface RDFParserBuilder { * use the {@link RDFTermFactory#createBlankNode(String)} method * from the parsed blank node labels. * - * @see #intoGraph(Graph) + * @see #target(Graph) * @param rdfTermFactory * {@link RDFTermFactory} to use for generating RDFTerms. * @return An {@link RDFParserBuilder} that will use the specified @@ -144,30 +157,97 @@ public interface RDFParserBuilder { RDFParserBuilder contentType(String contentType) throws IllegalArgumentException; /** - * Specify which {@link Graph} to add triples to. - * <p> - * The default (if this option has not been set) is that each call to - * {@link #parse()} return a new {@link Graph}, which is created using - * {@link RDFTermFactory#createGraph()} if - * {@link #rdfTermFactory(RDFTermFactory)} has been set. - * <p> - * It is undefined if any triples are added to the specified - * {@link Graph} if the {@link Future#get()} returned from - * {@link #parse()} throws any exceptions. (However - * implementations are free to prevent this using transaction - * mechanisms or similar). However, if {@link Future#get()} - * does not indicatean exception, the - * parser implementation SHOULD have inserted all parsed triples - * to the specified graph. + * Specify a {@link Graph} to add parsed triples to. + * <p> + * If the source supports datasets (e.g. the {@link #contentType(RDFSyntax)} + * set has {@link RDFSyntax#supportsDataset} is true)), then only quads in + * the <em>default graph</em> will be added to the Graph as {@link Triple}s. + * <p> + * It is undefined if any triples are added to the specified {@link Graph} + * if {@link #parse()} throws any exceptions. (However implementations are + * free to prevent this using transaction mechanisms or similar). If + * {@link Future#get()} does not indicate an exception, the parser + * implementation SHOULD have inserted all parsed triples to the specified + * graph. + * <p> + * Calling this method will override any earlier targets set with + * {@link #target(Graph)}, {@link #target(Consumer)} or + * {@link #target(Dataset)}. + * <p> + * The default implementation of this method calls {@link #target(Consumer)} + * with a {@link Consumer} that does {@link Graph#add(Triple)} with + * {@link Quad#asTriple()} if the quad is in the default graph. * * @param graph - * The {@link Graph} to add triples into. + * The {@link Graph} to add triples to. * @return An {@link RDFParserBuilder} that will insert triples into the * specified graph. */ - RDFParserBuilder intoGraph(Graph graph); + default RDFParserBuilder target(Graph graph) { + return target(q -> { + if (! q.getGraphName().isPresent()) { + graph.add(q.asTriple()); + } + }); + } /** + * Specify a {@link Dataset} to add parsed quads to. + * <p> + * It is undefined if any quads are added to the specified + * {@link Dataset} if {@link #parse()} throws any exceptions. + * (However implementations are free to prevent this using transaction + * mechanisms or similar). On the other hand, if {@link #parse()} + * does not indicate an exception, the + * implementation SHOULD have inserted all parsed quads + * to the specified dataset. + * <p> + * Calling this method will override any earlier targets set with + * {@link #target(Graph)}, {@link #target(Consumer)} or {@link #target(Dataset)}. + * <p> + * The default implementation of this method calls {@link #target(Consumer)} + * with a {@link Consumer} that does {@link Dataset#add(Quad)}. + * + * @param dataset + * The {@link Dataset} to add quads to. + * @return An {@link RDFParserBuilder} that will insert triples into the + * specified dataset. + */ + default RDFParserBuilder target(Dataset dataset) { + return target(dataset::add); + } + + /** + * Specify a consumer for parsed quads. + * <p> + * It is undefined if any quads are consumed if {@link #parse()} throws any + * exceptions. On the other hand, if {@link #parse()} does not indicate an + * exception, the implementation SHOULD have produced all parsed quads to + * the specified consumer. + * <p> + * Calling this method will override any earlier targets set with + * {@link #target(Graph)}, {@link #target(Consumer)} or + * {@link #target(Dataset)}. + * <p> + * The consumer is not assumed to be thread safe - only one + * {@link Consumer#accept(Object)} is delivered at a time for a given + * {@link RDFParserBuilder#parse()} call. + * <p> + * This method is typically called with a functional consumer, for example: + * <pre> + * List<Quad> quads = new ArrayList<Quad>; + * parserBuilder.target(quads::add).parse(); + * </pre> + * + * @param consumer + * A {@link Consumer} of {@link Quad}s + * @return An {@link RDFParserBuilder} that will call the consumer for into + * the specified dataset. + * @return + */ + RDFParserBuilder target(Consumer<Quad> consumer); + + /** * Specify a base IRI to use for parsing any relative IRI references. * <p> * Setting this option will override any protocol-specific base IRI (e.g. @@ -345,6 +425,11 @@ public interface RDFParserBuilder { * method) MUST have been called before calling this method, otherwise an * {@link IllegalStateException} will be thrown. * <p> + * A target method (e.g. {@link #target(Consumer)}, {@link #target(Dataset)} + * , {@link #target(Graph)} or an equivalent subclass method) MUST have been + * called before calling this method, otherwise an + * {@link IllegalStateException} will be thrown. + * <p> * It is undefined if this method is thread-safe, however the * {@link RDFParserBuilder} may be reused (e.g. setting a different source) * as soon as the {@link Future} has been returned from this method. @@ -357,12 +442,15 @@ public interface RDFParserBuilder { * synchronous implementation MAY be blocking on the <code>parse()</code> * call and return a Future that is already {@link Future#isDone()}. * <p> - * If {@link #intoGraph(Graph)} has been specified, this SHOULD be the same - * {@link Graph} instance returned from {@link Future#get()} once parsing has - * completed successfully. + * The returned {@link Future} contains a {@link ParseResult}. + * Implementations may subclass this interface to provide any + * parser details, e.g. list of warnings. <code>null</code> is a + * possible return value if no details are available, but + * parsing succeeded. * <p> * If an exception occurs during parsing, (e.g. {@link IOException} or - * {@link java.text.ParseException}), it should be indicated as the + * {@link org.apache.commons.rdf.simple.AbstractRDFParserBuilder.RDFParseException}), + * it should be indicated as the * {@link java.util.concurrent.ExecutionException#getCause()} in the * {@link java.util.concurrent.ExecutionException} thrown on * {@link Future#get()}. @@ -380,5 +468,5 @@ public interface RDFParserBuilder { * If the builder is in an invalid state, e.g. a * <code>source</code> has not been set. */ - Future<Graph> parse() throws IOException, IllegalStateException; + Future<? extends ParseResult> parse() throws IOException, IllegalStateException; } http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/defdbd91/simple/src/main/java/org/apache/commons/rdf/simple/AbstractRDFParserBuilder.java ---------------------------------------------------------------------- diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/AbstractRDFParserBuilder.java b/simple/src/main/java/org/apache/commons/rdf/simple/AbstractRDFParserBuilder.java index ab37eef..9544928 100644 --- a/simple/src/main/java/org/apache/commons/rdf/simple/AbstractRDFParserBuilder.java +++ b/simple/src/main/java/org/apache/commons/rdf/simple/AbstractRDFParserBuilder.java @@ -26,9 +26,10 @@ import java.util.Optional; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.function.Consumer; -import org.apache.commons.rdf.api.Graph; import org.apache.commons.rdf.api.IRI; +import org.apache.commons.rdf.api.Quad; import org.apache.commons.rdf.api.RDFParserBuilder; import org.apache.commons.rdf.api.RDFSyntax; import org.apache.commons.rdf.api.RDFTermFactory; @@ -111,15 +112,14 @@ public abstract class AbstractRDFParserBuilder implements RDFParserBuilder, Clon } /** - * Get the set {@link Graph} to insert into, if any. + * Get the target to consume parsed Quads. * <p> * From the call to {@link #parseSynchronusly()}, this - * method is always {@link Optional#isPresent()} - * with a new {@link Graph} instance, and - * will be the value returned from {@link #parse()}. + * method is always {@link Optional#isPresent()}. + * */ - public Optional<Graph> getIntoGraph() { - return intoGraph; + public Consumer<Quad> getTarget() { + return target; } /** @@ -167,11 +167,11 @@ public abstract class AbstractRDFParserBuilder implements RDFParserBuilder, Clon private Optional<RDFTermFactory> rdfTermFactory = Optional.empty(); private Optional<RDFSyntax> contentTypeSyntax = Optional.empty(); private Optional<String> contentType = Optional.empty(); - private Optional<Graph> intoGraph = Optional.empty(); private Optional<IRI> base = Optional.empty(); private Optional<InputStream> sourceInputStream = Optional.empty(); private Optional<Path> sourceFile = Optional.empty(); private Optional<IRI> sourceIri = Optional.empty(); + private Consumer<Quad> target; @Override public AbstractRDFParserBuilder clone() { @@ -206,13 +206,6 @@ public abstract class AbstractRDFParserBuilder implements RDFParserBuilder, Clon } @Override - public RDFParserBuilder intoGraph(Graph graph) { - AbstractRDFParserBuilder c = clone(); - c.intoGraph = Optional.ofNullable(graph); - return c; - } - - @Override public RDFParserBuilder base(IRI base) { AbstractRDFParserBuilder c = clone(); c.base = Optional.ofNullable(base); @@ -361,8 +354,10 @@ public abstract class AbstractRDFParserBuilder implements RDFParserBuilder, Clon */ protected AbstractRDFParserBuilder prepareForParsing() throws IOException, IllegalStateException { checkSource(); - checkBaseRequired(); + checkBaseRequired(); checkContentType(); + checkTarget(); + // We'll make a clone of our current state which will be passed to // parseSynchronously() AbstractRDFParserBuilder c = clone(); @@ -371,10 +366,6 @@ public abstract class AbstractRDFParserBuilder implements RDFParserBuilder, Clon if (!c.rdfTermFactory.isPresent()) { c.rdfTermFactory = Optional.of(createRDFTermFactory()); } - // No graph? We'll create one. - if (!c.intoGraph.isPresent()) { - c.intoGraph = c.rdfTermFactory.map(RDFTermFactory::createGraph); - } // sourceFile, but no base? Let's follow any symlinks and use // the file:/// URI if (c.sourceFile.isPresent() && !c.base.isPresent()) { @@ -386,6 +377,19 @@ public abstract class AbstractRDFParserBuilder implements RDFParserBuilder, Clon } /** + * Subclasses can override this method to check the target is + * valid. + * <p> + * The default implementation throws an IllegalStateException if the + * target has not been set. + */ + protected void checkTarget() { + if (target == null) { + throw new IllegalStateException("target has not been set"); + } + } + + /** * Subclasses can override this method to check compatibility with the * contentType setting. * @@ -441,13 +445,11 @@ public abstract class AbstractRDFParserBuilder implements RDFParserBuilder, Clon * <p> * This is called by {@link #parse()} to set * {@link #rdfTermFactory(RDFTermFactory)} if it is - * {@link Optional#empty()}, and therefore used also for - * creating a new {@link Graph} if - * {@link #getIntoGraph()} is {@link Optional#empty()}. + * {@link Optional#empty()}. * <p> * As parsed blank nodes might be made with * {@link RDFTermFactory#createBlankNode(String)}, - * each call to this method should return + * each call to this method SHOULD return * a new RDFTermFactory instance. * * @return A new {@link RDFTermFactory} @@ -457,12 +459,19 @@ public abstract class AbstractRDFParserBuilder implements RDFParserBuilder, Clon } @Override - public Future<Graph> parse() throws IOException, IllegalStateException { + public Future<ParseResult> parse() throws IOException, IllegalStateException { final AbstractRDFParserBuilder c = prepareForParsing(); return threadpool.submit(() -> { c.parseSynchronusly(); - return c.intoGraph.get(); + return null; }); } + @Override + public RDFParserBuilder target(Consumer<Quad> consumer) { + AbstractRDFParserBuilder c = clone(); + c.target = consumer; + return c; + } + } http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/defdbd91/simple/src/test/java/org/apache/commons/rdf/simple/AbstractRDFParserBuilderTest.java ---------------------------------------------------------------------- diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/AbstractRDFParserBuilderTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/AbstractRDFParserBuilderTest.java index d23e1c8..439bacb 100644 --- a/simple/src/test/java/org/apache/commons/rdf/simple/AbstractRDFParserBuilderTest.java +++ b/simple/src/test/java/org/apache/commons/rdf/simple/AbstractRDFParserBuilderTest.java @@ -17,7 +17,10 @@ */ package org.apache.commons.rdf.simple; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -102,9 +105,10 @@ public class AbstractRDFParserBuilderTest { } @Test - public void parseFile() throws Exception { - RDFParserBuilder parser = dummyParser.source(testNt); - Graph g = parser.parse().get(5, TimeUnit.SECONDS); + public void parseFile() throws Exception { + Graph g = factory.createGraph(); + RDFParserBuilder parser = dummyParser.source(testNt).target(g); + parser.parse().get(5, TimeUnit.SECONDS); checkGraph(g); // FIXME: this could potentially break if the equivalent of /tmp includes // international characters @@ -148,8 +152,12 @@ public class AbstractRDFParserBuilderTest { @Test public void parseFileContentType() throws Exception { - RDFParserBuilder parser = dummyParser.source(testNt).contentType(RDFSyntax.NTRIPLES); - Graph g = parser.parse().get(5, TimeUnit.SECONDS); + Graph g = factory.createGraph(); + RDFParserBuilder parser = dummyParser + .source(testNt) + .contentType(RDFSyntax.NTRIPLES) + .target(g); + parser.parse().get(5, TimeUnit.SECONDS); checkGraph(g); // FIXME: this could potentially break if the equivalent of /tmp includes // international characters @@ -183,8 +191,9 @@ public class AbstractRDFParserBuilderTest { public void parseInputStreamWithBase() throws Exception { InputStream inputStream = new ByteArrayInputStream(new byte[0]); IRI base = dummyParser.createRDFTermFactory().createIRI("http://www.example.org/test.rdf"); - RDFParserBuilder parser = dummyParser.source(inputStream).base(base); - Graph g = parser.parse().get(5, TimeUnit.SECONDS); + Graph g = factory.createGraph(); + RDFParserBuilder parser = dummyParser.source(inputStream).base(base).target(g); + parser.parse().get(5, TimeUnit.SECONDS); checkGraph(g); assertEquals("<http://www.example.org/test.rdf>", firstPredicate(g, "base")); // in our particular debug output, @@ -197,8 +206,9 @@ public class AbstractRDFParserBuilderTest { @Test public void parseInputStreamWithNQuads() throws Exception { InputStream inputStream = new ByteArrayInputStream(new byte[0]); - RDFParserBuilder parser = dummyParser.source(inputStream).contentType(RDFSyntax.NQUADS); - Graph g = parser.parse().get(5, TimeUnit.SECONDS); + Graph g = factory.createGraph(); + RDFParserBuilder parser = dummyParser.source(inputStream).contentType(RDFSyntax.NQUADS).target(g); + parser.parse().get(5, TimeUnit.SECONDS); checkGraph(g); assertNull(firstPredicate(g, "base")); // in our particular debug output, @@ -211,8 +221,9 @@ public class AbstractRDFParserBuilderTest { @Test public void parseIRI() throws Exception { IRI iri = dummyParser.createRDFTermFactory().createIRI("http://www.example.net/test.ttl"); - RDFParserBuilder parser = dummyParser.source(iri); - Graph g = parser.parse().get(5, TimeUnit.SECONDS); + Graph g = factory.createGraph(); + RDFParserBuilder parser = dummyParser.source(iri).target(g); + parser.parse().get(5, TimeUnit.SECONDS); checkGraph(g); assertEquals("<http://www.example.net/test.ttl>", firstPredicate(g, "source")); // No base - assuming the above IRI is always @@ -228,8 +239,9 @@ public class AbstractRDFParserBuilderTest { @Test public void parseIRIBaseContentType() throws Exception { IRI iri = dummyParser.createRDFTermFactory().createIRI("http://www.example.net/test.ttl"); - RDFParserBuilder parser = dummyParser.source(iri).base(iri).contentType(RDFSyntax.TURTLE); - Graph g = parser.parse().get(5, TimeUnit.SECONDS); + Graph g = factory.createGraph(); + RDFParserBuilder parser = dummyParser.source(iri).base(iri).contentType(RDFSyntax.TURTLE).target(g); + parser.parse().get(5, TimeUnit.SECONDS); checkGraph(g); assertEquals("<http://www.example.net/test.ttl>", firstPredicate(g, "source")); assertEquals("<http://www.example.net/test.ttl>", firstPredicate(g, "base")); http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/defdbd91/simple/src/test/java/org/apache/commons/rdf/simple/DummyRDFParserBuilder.java ---------------------------------------------------------------------- diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/DummyRDFParserBuilder.java b/simple/src/test/java/org/apache/commons/rdf/simple/DummyRDFParserBuilder.java index cc62f0c..0cb7093 100644 --- a/simple/src/test/java/org/apache/commons/rdf/simple/DummyRDFParserBuilder.java +++ b/simple/src/test/java/org/apache/commons/rdf/simple/DummyRDFParserBuilder.java @@ -18,11 +18,11 @@ package org.apache.commons.rdf.simple; import java.io.IOException; -import java.text.ParseException; import java.util.UUID; +import java.util.function.Consumer; -import org.apache.commons.rdf.api.Graph; import org.apache.commons.rdf.api.IRI; +import org.apache.commons.rdf.api.Quad; import org.apache.commons.rdf.api.RDFParserBuilder; import org.apache.commons.rdf.api.RDFTermFactory; @@ -49,47 +49,47 @@ public class DummyRDFParserBuilder extends AbstractRDFParserBuilder { protected void parseSynchronusly() throws IOException, IllegalStateException, RDFParseException { // From parseSynchronusly both of these are always present RDFTermFactory factory = getRdfTermFactory().get(); - Graph graph = getIntoGraph().get(); + Consumer<Quad> t = getTarget(); // well - each parsing is unique. This should hopefully // catch any accidental double parsing IRI parsing = factory.createIRI("urn:uuid:" + UUID.randomUUID()); - graph.add(parsing, factory.createIRI("http://example.com/greeting"), - factory.createLiteral("Hello world")); + t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/greeting"), + factory.createLiteral("Hello world"))); // Now we'll expose the finalized AbstractRDFParserBuilder settings // so they can be inspected by the junit test if (getSourceIri().isPresent()) { - graph.add(parsing, + t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/source"), - getSourceIri().get()); + getSourceIri().get())); } if (getSourceFile().isPresent()) { - graph.add(parsing, + t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/source"), - factory.createIRI(getSourceFile().get().toUri().toString())); + factory.createIRI(getSourceFile().get().toUri().toString()))); } if (getSourceInputStream().isPresent()) { - graph.add(parsing, + t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/source"), - factory.createBlankNode()); + factory.createBlankNode())); } if (getBase().isPresent()) { - graph.add(parsing, + t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/base"), - getBase().get()); + getBase().get())); } if (getContentType().isPresent()) { - graph.add(parsing, + t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/contentType"), - factory.createLiteral(getContentType().get())); + factory.createLiteral(getContentType().get()))); } if (getContentTypeSyntax().isPresent()) { - graph.add(parsing, + t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/contentTypeSyntax"), - factory.createLiteral(getContentTypeSyntax().get().name())); + factory.createLiteral(getContentTypeSyntax().get().name()))); } }