You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commonsrdf.apache.org by st...@apache.org on 2016/09/28 13:52:10 UTC

[18/36] incubator-commonsrdf git commit: contentType(String) also throws IllegalArgumentException

contentType(String) also throws IllegalArgumentException

Added checkContentType() for subclasses


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

Branch: refs/heads/master
Commit: 1b5f3160f590867d48247bba953cf39ca663456b
Parents: dc7589f
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Fri Apr 8 12:00:45 2016 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Fri Apr 8 12:00:45 2016 +0100

----------------------------------------------------------------------
 .../org/apache/commons/rdf/api/RDFParserBuilder.java  |  2 +-
 .../commons/rdf/simple/AbstractRDFParserBuilder.java  | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/1b5f3160/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 ee566c7..1425263 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
@@ -141,7 +141,7 @@ public interface RDFParserBuilder {
 	 *             If the contentType has an invalid syntax, or this
 	 *             RDFParserBuilder does not support the specified contentType.
 	 */
-	RDFParserBuilder contentType(String contentType);
+	RDFParserBuilder contentType(String contentType) throws IllegalArgumentException;
 
 	/**
 	 * Specify which {@link Graph} to add triples to.

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/1b5f3160/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 2430d26..98790ca 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
@@ -180,7 +180,7 @@ public abstract class AbstractRDFParserBuilder implements RDFParserBuilder, Clon
 	}
 
 	@Override
-	public RDFParserBuilder contentType(String contentType) {
+	public RDFParserBuilder contentType(String contentType) throws IllegalArgumentException {
 		AbstractRDFParserBuilder c = clone();
 		c.contentType = Optional.ofNullable(contentType);
 		c.contentTypeSyntax = c.contentType.flatMap(RDFSyntax::byMediaType);
@@ -344,6 +344,7 @@ public abstract class AbstractRDFParserBuilder implements RDFParserBuilder, Clon
 	protected AbstractRDFParserBuilder prepareForParsing() throws IOException, IllegalStateException {
 		checkSource();
 		checkBaseRequired();
+		checkContentType();
 		// We'll make a clone of our current state which will be passed to
 		// parseSynchronously()
 		AbstractRDFParserBuilder c = clone();
@@ -365,6 +366,17 @@ public abstract class AbstractRDFParserBuilder implements RDFParserBuilder, Clon
 
 		return c;
 	}
+	
+	/**
+	 * Subclasses can override this method to check compatibility with the
+	 * contentType setting.
+	 * 
+	 * @throws IllegalStateException
+	 *             if the {@link #getContentType()} or
+	 *             {@link #getContentTypeSyntax()} is not compatible or invalid
+	 */
+	protected void checkContentType() throws IllegalStateException {
+	}
 
 	/**
 	 * Guess RDFSyntax from a local file's extension.