commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [7/8] incubator-commonsrdf git commit: COMMONSRDF-39 JenaRDFParser moved to package ...jena.experimental
Date Wed, 28 Sep 2016 13:27:30 GMT
COMMONSRDF-39 JenaRDFParser moved to package ...jena.experimental


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

Branch: refs/heads/jena
Commit: 4416acc1bdbcb8192475c93aeaec8dae73e6f1cc
Parents: 2eb821d
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Wed Sep 28 14:25:07 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Wed Sep 28 14:25:07 2016 +0100

----------------------------------------------------------------------
 .../commons/rdf/jena/JenaRDFParserBuilder.java  | 103 ------------------
 .../rdf/jena/experimental/JenaRDFParser.java    | 105 +++++++++++++++++++
 .../rdf/jena/experimental/package-info.java     |  34 ++++++
 3 files changed, 139 insertions(+), 103 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/4416acc1/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFParserBuilder.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFParserBuilder.java b/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFParserBuilder.java
deleted file mode 100644
index 2149932..0000000
--- a/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFParserBuilder.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.rdf.jena;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.util.function.Consumer;
-
-import org.apache.commons.rdf.api.IRI;
-import org.apache.commons.rdf.api.QuadLike;
-import org.apache.commons.rdf.api.RDFParserBuilder;
-import org.apache.commons.rdf.api.RDFTerm;
-import org.apache.commons.rdf.api.RDFTermFactory;
-import org.apache.commons.rdf.api.TripleLike;
-import org.apache.commons.rdf.simple.AbstractRDFParserBuilder;
-import org.apache.jena.graph.Graph;
-import org.apache.jena.riot.Lang;
-import org.apache.jena.riot.RDFDataMgr;
-import org.apache.jena.riot.system.StreamRDF;
-import org.apache.jena.riot.system.StreamRDFLib;
-
-public class JenaRDFParserBuilder extends AbstractRDFParserBuilder<JenaRDFParserBuilder>
implements RDFParserBuilder {
-
-	private Consumer<TripleLike<RDFTerm, RDFTerm, RDFTerm>> generalizedConsumerTriple;
-	private Consumer<QuadLike<RDFTerm, RDFTerm, RDFTerm, RDFTerm>> generalizedConsumerQuad;
-
-	protected RDFTermFactory createRDFTermFactory() {
-		return new JenaRDFTermFactory();
-	}
-
-	public JenaRDFParserBuilder targetGeneralizedTriple(Consumer<TripleLike<RDFTerm,RDFTerm,RDFTerm>>
consumer) {
-		JenaRDFParserBuilder c = this.clone();
-		c.resetTarget();		
-		c.generalizedConsumerTriple = consumer;
-		return c;
-	}
-
-	public JenaRDFParserBuilder targetGeneralizedQuad(Consumer<QuadLike<RDFTerm,RDFTerm,RDFTerm,RDFTerm>>
consumer) {
-		JenaRDFParserBuilder c = this.clone();
-		c.resetTarget();		
-		c.generalizedConsumerQuad = consumer;
-		return c;
-	}
-	
-	@Override
-	protected void resetTarget() {		
-		super.resetTarget();
-		this.generalizedConsumerTriple = null;
-		this.generalizedConsumerQuad = null;
-	}
-	
-	@Override
-	protected void parseSynchronusly() throws IOException {
-		StreamRDF dest;
-		if (getTargetGraph().isPresent() && getTargetGraph().get() instanceof JenaGraph)
{
-			Graph jenaGraph = ((JenaGraph) getTargetGraph().get()).asJenaGraph();
-			dest = StreamRDFLib.graph(jenaGraph);
-		} else if (generalizedConsumerQuad != null) {				
-			dest = getJenaFactory().streamJenaToGeneralizedQuad(generalizedConsumerQuad);			
-		} else if (generalizedConsumerTriple != null) {				
-			dest = getJenaFactory().streamJenaToGeneralizedTriple(generalizedConsumerTriple);			
-		} else {
-			dest = JenaRDFTermFactory.streamJenaToCommonsRDF(getRdfTermFactory().get(), getTarget());
-		}
-
-		Lang lang = getContentTypeSyntax().flatMap(JenaRDFTermFactory::rdfSyntaxToLang).orElse(null);
-		String baseStr = getBase().map(IRI::getIRIString).orElse(null);
-
-		if (getSourceIri().isPresent()) {
-			RDFDataMgr.parse(dest, getSourceIri().get().toString(), baseStr, lang, null);
-		} else if (getSourceFile().isPresent()) {
-			try (InputStream s = Files.newInputStream(getSourceFile().get())) {
-				RDFDataMgr.parse(dest, s, baseStr, lang, null);
-			}
-		} else {
-			RDFDataMgr.parse(dest, getSourceInputStream().get(), baseStr, lang, null);
-		}
-	}
-
-	private JenaRDFTermFactory getJenaFactory() {
-		return (JenaRDFTermFactory) getRdfTermFactory()
-				.filter(JenaRDFTermFactory.class::isInstance)
-				.orElseGet(this::createRDFTermFactory);		
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/4416acc1/jena/src/main/java/org/apache/commons/rdf/jena/experimental/JenaRDFParser.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/experimental/JenaRDFParser.java
b/jena/src/main/java/org/apache/commons/rdf/jena/experimental/JenaRDFParser.java
new file mode 100644
index 0000000..873f1cf
--- /dev/null
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/experimental/JenaRDFParser.java
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.rdf.jena.experimental;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.util.function.Consumer;
+
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.QuadLike;
+import org.apache.commons.rdf.api.RDFTerm;
+import org.apache.commons.rdf.api.RDFTermFactory;
+import org.apache.commons.rdf.api.TripleLike;
+import org.apache.commons.rdf.experimental.RDFParser;
+import org.apache.commons.rdf.jena.JenaGraph;
+import org.apache.commons.rdf.jena.JenaRDFTermFactory;
+import org.apache.commons.rdf.simple.experimental.AbstractRDFParser;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.riot.Lang;
+import org.apache.jena.riot.RDFDataMgr;
+import org.apache.jena.riot.system.StreamRDF;
+import org.apache.jena.riot.system.StreamRDFLib;
+
+public class JenaRDFParser extends AbstractRDFParser<JenaRDFParser> implements RDFParser
{
+
+	private Consumer<TripleLike<RDFTerm, RDFTerm, RDFTerm>> generalizedConsumerTriple;
+	private Consumer<QuadLike<RDFTerm, RDFTerm, RDFTerm, RDFTerm>> generalizedConsumerQuad;
+
+	protected RDFTermFactory createRDFTermFactory() {
+		return new JenaRDFTermFactory();
+	}
+
+	public JenaRDFParser targetGeneralizedTriple(Consumer<TripleLike<RDFTerm,RDFTerm,RDFTerm>>
consumer) {
+		JenaRDFParser c = this.clone();
+		c.resetTarget();		
+		c.generalizedConsumerTriple = consumer;
+		return c;
+	}
+
+	public JenaRDFParser targetGeneralizedQuad(Consumer<QuadLike<RDFTerm,RDFTerm,RDFTerm,RDFTerm>>
consumer) {
+		JenaRDFParser c = this.clone();
+		c.resetTarget();		
+		c.generalizedConsumerQuad = consumer;
+		return c;
+	}
+	
+	@Override
+	protected void resetTarget() {		
+		super.resetTarget();
+		this.generalizedConsumerTriple = null;
+		this.generalizedConsumerQuad = null;
+	}
+	
+	@Override
+	protected void parseSynchronusly() throws IOException {
+		StreamRDF dest;
+		if (getTargetGraph().isPresent() && getTargetGraph().get() instanceof JenaGraph)
{
+			Graph jenaGraph = ((JenaGraph) getTargetGraph().get()).asJenaGraph();
+			dest = StreamRDFLib.graph(jenaGraph);
+		} else if (generalizedConsumerQuad != null) {				
+			dest = getJenaFactory().streamJenaToGeneralizedQuad(generalizedConsumerQuad);			
+		} else if (generalizedConsumerTriple != null) {				
+			dest = getJenaFactory().streamJenaToGeneralizedTriple(generalizedConsumerTriple);			
+		} else {
+			dest = JenaRDFTermFactory.streamJenaToCommonsRDF(getRdfTermFactory().get(), getTarget());
+		}
+
+		Lang lang = getContentTypeSyntax().flatMap(JenaRDFTermFactory::rdfSyntaxToLang).orElse(null);
+		String baseStr = getBase().map(IRI::getIRIString).orElse(null);
+
+		if (getSourceIri().isPresent()) {
+			RDFDataMgr.parse(dest, getSourceIri().get().toString(), baseStr, lang, null);
+		} else if (getSourceFile().isPresent()) {
+			try (InputStream s = Files.newInputStream(getSourceFile().get())) {
+				RDFDataMgr.parse(dest, s, baseStr, lang, null);
+			}
+		} else {
+			RDFDataMgr.parse(dest, getSourceInputStream().get(), baseStr, lang, null);
+		}
+	}
+
+	private JenaRDFTermFactory getJenaFactory() {
+		return (JenaRDFTermFactory) getRdfTermFactory()
+				.filter(JenaRDFTermFactory.class::isInstance)
+				.orElseGet(this::createRDFTermFactory);		
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/4416acc1/jena/src/main/java/org/apache/commons/rdf/jena/experimental/package-info.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/experimental/package-info.java
b/jena/src/main/java/org/apache/commons/rdf/jena/experimental/package-info.java
new file mode 100644
index 0000000..9fe39f4
--- /dev/null
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/experimental/package-info.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Experimental Commons RDF Jena implementations.
+ * <p>
+ * Classes in this package should be considered <strong>at
+ * risk</strong>; they might change or be removed in the next minor update of
+ * Commons RDF.
+ * <p>
+ * When a class has stabilized, it will move to the
+ * {@link org.apache.commons.rdf.jena} package.
+ * <p>
+ * <ul>
+ * <li>{@link JenaRDFParser} - a Jena-backed
+ * implementations of 
+ * {@link org.apache.commons.rdf.api.experimental.RDFParser}.</li>
+ * </ul>
+ */
+package org.apache.commons.rdf.jena.experimental;
\ No newline at end of file


Mime
View raw message