commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [31/50] incubator-commonsrdf git commit: Expose ParserConfig
Date Fri, 07 Oct 2016 15:01:34 GMT
Expose ParserConfig


Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/444c8003
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/444c8003
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/444c8003

Branch: refs/heads/master
Commit: 444c80037d97aacda3585a7c0f3cfef43577e6af
Parents: 49feb7c
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Tue Oct 4 02:38:53 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Tue Oct 4 02:38:53 2016 +0100

----------------------------------------------------------------------
 .../rdf/rdf4j/experimental/RDF4JParser.java     | 28 +++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/444c8003/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
index 88f79e1..959b46b 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
@@ -102,6 +102,7 @@ public class RDF4JParser extends AbstractRDFParser<RDF4JParser>
implements RDFPa
 	}
 
 	private RDF4JTermFactory rdf4jTermFactory;
+	private ParserConfig parserConfig = new ParserConfig();
 
 	@Override
 	protected RDF4JTermFactory createRDFTermFactory() {
@@ -123,7 +124,7 @@ public class RDF4JParser extends AbstractRDFParser<RDF4JParser>
implements RDFPa
 		Optional<RDFFormat> formatByMimeType = getContentType().flatMap(Rio::getParserFormatForMIMEType);
 		String base = getBase().map(IRI::getIRIString).orElse(null);
 				
-		ParserConfig parserConfig = new ParserConfig();
+		ParserConfig parserConfig = getParserConfig();
 		// TODO: Should we need to set anything?
 		RDFLoader loader = new RDFLoader(parserConfig, rdf4jTermFactory.getValueFactory());
 		RDFHandler rdfHandler = makeRDFHandler();		
@@ -159,6 +160,31 @@ public class RDF4JParser extends AbstractRDFParser<RDF4JParser>
implements RDFPa
 		loader.load(getSourceInputStream().get(), base, formatByMimeType.orElse(null), rdfHandler);
 	}
 
+	/**
+	 * Get the RDF4J {@link ParserConfig} to use.
+	 * <p>
+	 * If no parser config is set, the default configuration is provided.
+	 * <p>
+	 * <strong>Note:</strong> The parser config is mutable - changes in the 
+	 * returned config is reflected in this instance of the parser.
+	 * To avoid mutation, create a new {@link ParserConfig} and set
+	 * {@link #setParserConfig(ParserConfig)}.
+	 * 
+	 * @return The RDF4J {@link ParserConfig}
+	 */
+	public ParserConfig getParserConfig() {
+		return parserConfig;
+	}
+
+	/**
+	 * Set an RDF4J {@link ParserConfig} to use
+	 * 
+	 * @param parserConfig Parser configuration
+	 */
+	public void setParserConfig(ParserConfig parserConfig) {
+		this.parserConfig = parserConfig;
+	}
+
 	protected RDFHandler makeRDFHandler() {
 
 		// TODO: Can we join the below DF4JDataset and RDF4JGraph cases


Mime
View raw message