commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [16/17] commons-rdf git commit: AbstractParserFactory -> AbstractParserBuilder
Date Thu, 15 Feb 2018 01:55:11 GMT
AbstractParserFactory -> AbstractParserBuilder


Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/0e43e6e2
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/0e43e6e2
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/0e43e6e2

Branch: refs/heads/fluent-parser
Commit: 0e43e6e288c632f53275893a1807e891f2f48568
Parents: 10928ea
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Thu Feb 15 01:25:57 2018 +0000
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Thu Feb 15 01:25:57 2018 +0000

----------------------------------------------------------------------
 .../rdf/api/io/AbstractParserBuilder.java       | 188 +++++++++++++++++++
 .../rdf/api/io/AbstractParserFactory.java       | 188 -------------------
 .../org/apache/commons/rdf/api/io/Parser.java   |   1 +
 3 files changed, 189 insertions(+), 188 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/0e43e6e2/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserBuilder.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserBuilder.java
b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserBuilder.java
new file mode 100644
index 0000000..c51cabb
--- /dev/null
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserBuilder.java
@@ -0,0 +1,188 @@
+/*
+ * 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.api.io;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.nio.file.Path;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.RDF;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.fluentparser.Async;
+import org.apache.commons.rdf.api.fluentparser.NeedSourceBased;
+import org.apache.commons.rdf.api.fluentparser.NeedSourceOrBase;
+import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDF;
+import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDFOrSyntax;
+import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
+import org.apache.commons.rdf.api.fluentparser.Sync;
+
+@SuppressWarnings({ "unchecked", "rawtypes" })
+public final class AbstractParserBuilder implements Cloneable, Serializable, NeedTargetOrRDF,
NeedTargetOrRDFOrSyntax,
+		NeedSourceOrBase, NeedSourceBased, OptionalTarget, Sync, Async {
+
+	private static final long serialVersionUID = 1L;
+
+	public AbstractParserBuilder(RDF rdf) {
+		
+	}
+	
+	@Override
+	public AbstractParserBuilder clone() {
+		try {
+			AbstractParserBuilder c = (AbstractParserBuilder) super.clone();
+			c.config = (ParserConfigImpl) config.clone();
+			return c;
+		} catch (CloneNotSupportedException e) {
+			throw new IllegalStateException("AbstractParserBuilder was not Cloneable", e);
+		}
+	}
+
+	private boolean mutable = false;
+	private ParserConfigImpl config = new ParserConfigImpl();
+
+	@Override
+	public NeedTargetOrRDF syntax(RDFSyntax syntax) {
+		AbstractParserBuilder c = mutable();
+		c.config.withSyntax(syntax);
+		return c;
+	}
+
+	private AbstractParserBuilder mutable(boolean mutable) {
+		if (this.mutable == mutable) {
+			return this;
+		} else {
+			AbstractParserBuilder c = clone();
+			c.mutable = mutable;
+			return c;
+		}
+	}
+
+	private AbstractParserBuilder mutable() {
+		return mutable(true);
+	}
+
+	@Override
+	public AbstractParserBuilder build() {
+		return mutable(false);
+	}
+
+	@Override
+	public NeedSourceOrBase target(Dataset dataset) {
+		return target(dataset::add);
+
+	}
+
+	@Override
+	public NeedSourceOrBase<Graph> target(Graph graph) {
+		return target(q -> {
+			if (q.getGraphName().isPresent()) {
+				// Only add if q is in default graph
+				graph.add(q.asTriple());
+			}
+		});
+	}
+
+	@Override
+	public <T> NeedSourceOrBase<T> target(ParserTarget<T> target) {
+		AbstractParserBuilder c = mutable();
+		c.config.withTarget(target);
+		return c;
+	}
+
+	@Override
+	public NeedSourceBased base(IRI iri) {
+		AbstractParserBuilder c = mutable();
+		c.config.withBase(iri);
+		return c;
+	}
+
+	@Override
+	public NeedSourceBased base(String iri) {
+		AbstractParserBuilder c = mutable();
+		c.config.withBase(new IRIImpl(iri));
+		return c;
+	}
+
+	@Override
+	public Sync source(final IRI iri) {
+		return source(new IRIParserSource(iri));
+	}
+
+	public Sync source(Path path) {
+		return source(new PathParserSource(path));
+	}
+
+	@Override
+	public OptionalTarget<Dataset> rdf(RDF rdf) {
+		AbstractParserBuilder c = mutable();
+		c.config.withRDF(rdf);
+		return c;
+	}
+
+	@Override
+	public Sync source(ParserSource source) {
+		AbstractParserBuilder c = mutable();
+		c.config.withSource(source);
+		return c;
+	}
+
+	@Override
+	public Sync source(String iri) {
+		return source(new IRIImpl(iri));
+	}
+
+	@Override
+	public AbstractParserBuilder option(Option option, Object value) {
+		AbstractParserBuilder c = mutable();
+		c.config.withOption(option, value);
+		return c;
+	}
+
+	@Override
+	public Future parseAsync() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Async async() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Async async(ExecutorService executor) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Parsed parse() {
+		return null;
+	}
+
+	@Override
+	public Sync source(InputStream is) {
+		return source(new InputParserSource(is));
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/0e43e6e2/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
deleted file mode 100644
index 141b2f1..0000000
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/AbstractParserFactory.java
+++ /dev/null
@@ -1,188 +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.api.io;
-
-import java.io.InputStream;
-import java.io.Serializable;
-import java.nio.file.Path;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.Graph;
-import org.apache.commons.rdf.api.IRI;
-import org.apache.commons.rdf.api.RDF;
-import org.apache.commons.rdf.api.RDFSyntax;
-import org.apache.commons.rdf.api.fluentparser.Async;
-import org.apache.commons.rdf.api.fluentparser.NeedSourceBased;
-import org.apache.commons.rdf.api.fluentparser.NeedSourceOrBase;
-import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDF;
-import org.apache.commons.rdf.api.fluentparser.NeedTargetOrRDFOrSyntax;
-import org.apache.commons.rdf.api.fluentparser.OptionalTarget;
-import org.apache.commons.rdf.api.fluentparser.Sync;
-
-@SuppressWarnings({ "unchecked", "rawtypes" })
-public final class AbstractParserFactory implements Cloneable, Serializable, NeedTargetOrRDF,
NeedTargetOrRDFOrSyntax,
-		NeedSourceOrBase, NeedSourceBased, OptionalTarget, Sync, Async {
-
-	private static final long serialVersionUID = 1L;
-
-	public AbstractParserFactory(RDF rdf) {
-		
-	}
-	
-	@Override
-	public AbstractParserFactory clone() {
-		try {
-			AbstractParserFactory c = (AbstractParserFactory) super.clone();
-			c.config = (ParserConfigImpl) config.clone();
-			return c;
-		} catch (CloneNotSupportedException e) {
-			throw new IllegalStateException("AbstractParserFactory was not Cloneable", e);
-		}
-	}
-
-	private boolean mutable = false;
-	private ParserConfigImpl config = new ParserConfigImpl();
-
-	@Override
-	public NeedTargetOrRDF syntax(RDFSyntax syntax) {
-		AbstractParserFactory c = mutable();
-		c.config.withSyntax(syntax);
-		return c;
-	}
-
-	private AbstractParserFactory mutable(boolean mutable) {
-		if (this.mutable == mutable) {
-			return this;
-		} else {
-			AbstractParserFactory c = clone();
-			c.mutable = mutable;
-			return c;
-		}
-	}
-
-	private AbstractParserFactory mutable() {
-		return mutable(true);
-	}
-
-	@Override
-	public AbstractParserFactory build() {
-		return mutable(false);
-	}
-
-	@Override
-	public NeedSourceOrBase target(Dataset dataset) {
-		return target(dataset::add);
-
-	}
-
-	@Override
-	public NeedSourceOrBase<Graph> target(Graph graph) {
-		return target(q -> {
-			if (q.getGraphName().isPresent()) {
-				// Only add if q is in default graph
-				graph.add(q.asTriple());
-			}
-		});
-	}
-
-	@Override
-	public <T> NeedSourceOrBase<T> target(ParserTarget<T> target) {
-		AbstractParserFactory c = mutable();
-		c.config.withTarget(target);
-		return c;
-	}
-
-	@Override
-	public NeedSourceBased base(IRI iri) {
-		AbstractParserFactory c = mutable();
-		c.config.withBase(iri);
-		return c;
-	}
-
-	@Override
-	public NeedSourceBased base(String iri) {
-		AbstractParserFactory c = mutable();
-		c.config.withBase(new IRIImpl(iri));
-		return c;
-	}
-
-	@Override
-	public Sync source(final IRI iri) {
-		return source(new IRIParserSource(iri));
-	}
-
-	public Sync source(Path path) {
-		return source(new PathParserSource(path));
-	}
-
-	@Override
-	public OptionalTarget<Dataset> rdf(RDF rdf) {
-		AbstractParserFactory c = mutable();
-		c.config.withRDF(rdf);
-		return c;
-	}
-
-	@Override
-	public Sync source(ParserSource source) {
-		AbstractParserFactory c = mutable();
-		c.config.withSource(source);
-		return c;
-	}
-
-	@Override
-	public Sync source(String iri) {
-		return source(new IRIImpl(iri));
-	}
-
-	@Override
-	public AbstractParserFactory option(Option option, Object value) {
-		AbstractParserFactory c = mutable();
-		c.config.withOption(option, value);
-		return c;
-	}
-
-	@Override
-	public Future parseAsync() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Async async() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Async async(ExecutorService executor) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Parsed parse() {
-		return null;
-	}
-
-	@Override
-	public Sync source(InputStream is) {
-		return source(new InputParserSource(is));
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/0e43e6e2/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
index fc0da77..9e9a18a 100644
--- a/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
+++ b/commons-rdf-api/src/main/java/org/apache/commons/rdf/api/io/Parser.java
@@ -18,6 +18,7 @@ package org.apache.commons.rdf.api.io;
 
 public interface Parser {
 
+	@SuppressWarnings("rawtypes")
 	Parsed parse(ParserConfig config);
 
 }


Mime
View raw message