commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [26/50] incubator-commonsrdf git commit: code cleanup
Date Tue, 04 Oct 2016 01:30:47 GMT
code cleanup


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

Branch: refs/heads/rdf4j
Commit: ca11a42bc8e5022181d725fb53cdc4a7aa4dd8a3
Parents: ea48c83
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Fri Sep 9 14:40:39 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Fri Sep 9 14:40:39 2016 +0100

----------------------------------------------------------------------
 .../commons/rdf/jsonldjava/JsonLdDataset.java   |  20 +--
 .../commons/rdf/jsonldjava/JsonLdGraph.java     |  26 ++--
 .../commons/rdf/jsonldjava/JsonLdGraphLike.java | 149 ++++++++++---------
 .../rdf/jsonldjava/JsonLdRDFTermFactory.java    | 120 +++++++--------
 .../commons/rdf/jsonldjava/package-info.java    |   4 +-
 5 files changed, 164 insertions(+), 155 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ca11a42b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdDataset.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdDataset.java
b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdDataset.java
index e18dfaf..0e9422f 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdDataset.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdDataset.java
@@ -33,16 +33,16 @@ import com.github.jsonldjava.core.RDFDataset;
 
 public class JsonLdDataset extends JsonLdGraphLike<org.apache.commons.rdf.api.Quad>
implements Dataset {
 
-	JsonLdDataset(String bnodePrefix) {
-		super(bnodePrefix);
+	public JsonLdDataset(RDFDataset rdfDataSet) {
+		super(rdfDataSet);
 	}
 
 	JsonLdDataset(RDFDataset rdfDataset, String bnodePrefix) {
 		super(rdfDataset, bnodePrefix);
 	}
 
-	public JsonLdDataset(RDFDataset rdfDataSet) {
-		super(rdfDataSet);
+	JsonLdDataset(String bnodePrefix) {
+		super(bnodePrefix);
 	}
 
 	@Override
@@ -56,14 +56,9 @@ public class JsonLdDataset extends JsonLdGraphLike<org.apache.commons.rdf.api.Qu
 	}
 	
 	@Override
-	public void remove(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI
predicate, RDFTerm object) {
-		super.remove(graphName, subject, predicate, object);
-	}	
-
-	@Override
 	public Graph getGraph() {
 		return new JsonLdGraph(rdfDataSet, Optional.empty(), bnodePrefix);
-	}
+	}	
 
 	@Override
 	public Optional<Graph> getGraph(BlankNodeOrIRI graphName) {
@@ -83,6 +78,11 @@ public class JsonLdDataset extends JsonLdGraphLike<org.apache.commons.rdf.api.Qu
 	}
 
 	@Override
+	public void remove(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI
predicate, RDFTerm object) {
+		super.remove(graphName, subject, predicate, object);
+	}
+
+	@Override
 	public Stream<? extends Quad> stream(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI
subject, IRI predicate,
 			RDFTerm object) {		
 		return filteredGraphs(graphName)

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ca11a42b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraph.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraph.java
b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraph.java
index 22d5291..b8dc869 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraph.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraph.java
@@ -32,11 +32,6 @@ public class JsonLdGraph extends JsonLdGraphLike<org.apache.commons.rdf.api.Trip
 
 	private final Optional<BlankNodeOrIRI> graphName;
 
-	JsonLdGraph(String bnodePrefix) {
-		super(bnodePrefix);
-		this.graphName = Optional.empty();
-	}
-	
 	public JsonLdGraph(RDFDataset rdfDataSet) {
 		super(rdfDataSet);
 		this.graphName = Optional.empty();
@@ -46,6 +41,11 @@ public class JsonLdGraph extends JsonLdGraphLike<org.apache.commons.rdf.api.Trip
 		super(rdfDataSet, bnodePrefix);
 		this.graphName = graphName;
 	}
+	
+	JsonLdGraph(String bnodePrefix) {
+		super(bnodePrefix);
+		this.graphName = Optional.empty();
+	}
 
 
 	@Override
@@ -64,6 +64,13 @@ public class JsonLdGraph extends JsonLdGraphLike<org.apache.commons.rdf.api.Trip
 	}
 
 	@Override
+	public long size() {
+		String g = graphName.map(this::asJsonLdString).orElse("@default");
+		return Optional.ofNullable(rdfDataSet.getQuads(g))
+				.map(List::size).orElse(0);
+	}
+
+	@Override
 	public Stream<JsonLdTriple> stream(BlankNodeOrIRI subject, IRI predicate,
 			RDFTerm object) {		
 		return filteredGraphs(graphName)
@@ -71,17 +78,10 @@ public class JsonLdGraph extends JsonLdGraphLike<org.apache.commons.rdf.api.Trip
 				.filter(quadFilter(subject, predicate, object))
 				.map(factory::createTriple);
 	}
-
+	
 	@Override
 	JsonLdTriple asTripleOrQuad(com.github.jsonldjava.core.RDFDataset.Quad jsonldQuad) {
 		return factory.createTriple(jsonldQuad);
 	}
-	
-	@Override
-	public long size() {
-		String g = graphName.map(this::asJsonLdString).orElse("@default");
-		return Optional.ofNullable(rdfDataSet.getQuads(g))
-				.map(List::size).orElse(0);
-	}
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ca11a42b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphLike.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphLike.java
b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphLike.java
index 1da7506..2047a6e 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphLike.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphLike.java
@@ -39,6 +39,13 @@ import com.github.jsonldjava.core.RDFDataset;
 import com.github.jsonldjava.core.RDFDataset.Node;
 import com.github.jsonldjava.core.RDFDataset.Quad;
 
+/**
+ * Common abstract {@link GraphLike}.
+ * <p>
+ * Specialised by {@link JsonLdGraph}, {@link JsonLdUnionGraph} and {@link JsonLdDataset}.

+ *
+ * @param <T> specialisation of {@link TripleLike}, e.g. {@link Triple} or {@link Quad}
+ */
 abstract class JsonLdGraphLike<T extends TripleLike<BlankNodeOrIRI, IRI, RDFTerm>>
 	implements GraphLike<T, BlankNodeOrIRI, IRI, RDFTerm> {
 	
@@ -48,35 +55,34 @@ abstract class JsonLdGraphLike<T extends TripleLike<BlankNodeOrIRI,
IRI, RDFTerm
 	private static UUID SALT = UUID.randomUUID();
 	
 	/**
-	 * The underlying JSON-LD {@link RDFDataset}.
-	 */
-	RDFDataset rdfDataSet;
-
-	/**
 	 * Prefix to use in blank node identifiers
 	 */
 	final String bnodePrefix;
 
-	protected JsonLdRDFTermFactory factory;
-	
-	JsonLdGraphLike(String bnodePrefix) {
-		this(new RDFDataset(), bnodePrefix);
-	}
+	final JsonLdRDFTermFactory factory;
 
+	/**
+	 * The underlying JSON-LD {@link RDFDataset}.
+	 * <p>
+	 * Note: This is NOT final as it is reset to <code>null</code> by {@link #close()}
+	 * (to free memory).
+	 */
+	RDFDataset rdfDataSet;
+	
 	JsonLdGraphLike(RDFDataset rdfDataSet) {
 		this(rdfDataSet, "urn:uuid:" + SALT + "#" +  "g"+ System.identityHashCode(rdfDataSet));
 	}
-	
+
 	JsonLdGraphLike(RDFDataset rdfDataset, String bnodePrefix) {
 		rdfDataSet = rdfDataset;
 		this.bnodePrefix = bnodePrefix;
 		this.factory = new JsonLdRDFTermFactory(bnodePrefix);
 	}
 	
-	public RDFDataset getRdfDataSet() {
-		return rdfDataSet;
+	JsonLdGraphLike(String bnodePrefix) {
+		this(new RDFDataset(), bnodePrefix);
 	}
-
+	
 	@Override
 	public void add(T tripleOrQuad) {
 		String g = graphNameAsJsonLdString(tripleOrQuad);
@@ -94,6 +100,48 @@ abstract class JsonLdGraphLike<T extends TripleLike<BlankNodeOrIRI,
IRI, RDFTerm
 			rdfDataSet.addQuad(s,p,literal.getLexicalForm(), datatype, language, g);
 		}
 	}
+
+	@Override
+	public void clear() {
+		rdfDataSet.clear();
+	}
+	
+	public void close() {
+		// Drop the memory reference, but don't clear it
+		rdfDataSet = null;			
+	}	
+
+	@Override
+	public boolean contains(T tripleOrQuad) {		
+		return stream().anyMatch(Predicate.isEqual(tripleOrQuad));
+	}
+
+	public RDFDataset getRdfDataSet() {
+		return rdfDataSet;
+	}
+	
+	@Override
+	public void remove(T t) {
+		if (t instanceof org.apache.commons.rdf.api.Quad) {
+			org.apache.commons.rdf.api.Quad q = (org.apache.commons.rdf.api.Quad) t;
+			remove(q.getGraphName(), q.getSubject(), q.getPredicate(), q.getObject());
+		} else {
+			remove(Optional.empty(), t.getSubject(), t.getPredicate(), t.getObject());
+		}
+	}
+	
+	@Override
+	public long size() {		
+		return rdfDataSet.graphNames().parallelStream().map(rdfDataSet::getQuads).collect(Collectors.summingLong(List::size));
+	}
+	
+	@Override
+	public Stream<? extends T> stream() {
+		return rdfDataSet.graphNames().parallelStream()
+				.map(rdfDataSet::getQuads)
+				.flatMap(List<RDFDataset.Quad>::parallelStream)
+				.map(this::asTripleOrQuad);
+	}
 	
 	void add(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
{
 		String g = asJsonLdString(graphName);
@@ -109,17 +157,8 @@ abstract class JsonLdGraphLike<T extends TripleLike<BlankNodeOrIRI,
IRI, RDFTerm
 			rdfDataSet.addQuad(s,p,literal.getLexicalForm(), datatype, language, g);
 		}		
 	}
-	
 
-	private String graphNameAsJsonLdString(T tripleOrQuad) {
-		if (tripleOrQuad instanceof org.apache.commons.rdf.api.Quad) {
-			org.apache.commons.rdf.api.Quad quad = (org.apache.commons.rdf.api.Quad)tripleOrQuad;
-			return quad.getGraphName().map(this::asJsonLdString).orElse("@default");			
-		}
-		return "@default";
-	}
-
-	protected String asJsonLdString(BlankNodeOrIRI blankNodeOrIRI) {
+	String asJsonLdString(BlankNodeOrIRI blankNodeOrIRI) {
 		if (blankNodeOrIRI == null) {
 			return null;
 		}
@@ -142,28 +181,6 @@ abstract class JsonLdGraphLike<T extends TripleLike<BlankNodeOrIRI,
IRI, RDFTerm
 		}
 	}
 	
-	@Override
-	public void clear() {
-		rdfDataSet.clear();
-	}
-	
-	public void close() {
-		// Drop the memory reference, but don't clear it
-		rdfDataSet = null;			
-	}
-	
-	@Override
-	public boolean contains(T tripleOrQuad) {		
-		return stream().anyMatch(Predicate.isEqual(tripleOrQuad));
-	}
-
-
-	// This will be made public in JsonLdDataset
-	// and is used by the other  methods.
-	boolean contains(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI s, IRI p, RDFTerm
o) {
-		return filteredGraphs(graphName).flatMap(List::stream).anyMatch(quadFilter(s,p,o));
-	}
-	
 	/**
 	 * Convert JsonLd Quad to a Commons RDF {@link Triple} or {@link org.apache.commons.rdf.api.Quad}
 	 * 
@@ -174,30 +191,11 @@ abstract class JsonLdGraphLike<T extends TripleLike<BlankNodeOrIRI,
IRI, RDFTerm
 	 * @return converted {@link TripleLike}
 	 */
 	abstract T asTripleOrQuad(RDFDataset.Quad jsonldQuad);
-	
-	@Override
-	public Stream<? extends T> stream() {
-		return rdfDataSet.graphNames().parallelStream()
-				.map(rdfDataSet::getQuads)
-				.flatMap(List<RDFDataset.Quad>::parallelStream)
-				.map(this::asTripleOrQuad);
-	}
-
-	@Override
-	public void remove(T t) {
-		if (t instanceof org.apache.commons.rdf.api.Quad) {
-			org.apache.commons.rdf.api.Quad q = (org.apache.commons.rdf.api.Quad) t;
-			remove(q.getGraphName(), q.getSubject(), q.getPredicate(), q.getObject());
-		} else {
-			remove(Optional.empty(), t.getSubject(), t.getPredicate(), t.getObject());
-		}
-	}
 
 	// This will be made public in JsonLdDataset
-	// and is used by the other remove methods.
-	void remove(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate,
RDFTerm object) {
-		// remove the quads which match our filter (which could have nulls as wildcards) 
-		filteredGraphs(graphName).forEach(t -> t.removeIf(quadFilter(subject, predicate, object)));
+	// and is used by the other  methods.
+	boolean contains(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI s, IRI p, RDFTerm
o) {
+		return filteredGraphs(graphName).flatMap(List::stream).anyMatch(quadFilter(s,p,o));
 	}
 
 	Stream<List<Quad>> filteredGraphs(Optional<BlankNodeOrIRI> graphName)
{
@@ -210,6 +208,14 @@ abstract class JsonLdGraphLike<T extends TripleLike<BlankNodeOrIRI,
IRI, RDFTerm
 				// remove the quads which match our filter (which could have nulls as wildcards) 
 				.map(rdfDataSet::getQuads);
 	}
+
+	String graphNameAsJsonLdString(T tripleOrQuad) {
+		if (tripleOrQuad instanceof org.apache.commons.rdf.api.Quad) {
+			org.apache.commons.rdf.api.Quad quad = (org.apache.commons.rdf.api.Quad)tripleOrQuad;
+			return quad.getGraphName().map(this::asJsonLdString).orElse("@default");			
+		}
+		return "@default";
+	}
 	
 	
 	Predicate<RDFDataset.Quad> quadFilter(BlankNodeOrIRI subject, IRI predicate, RDFTerm
object) {
@@ -231,9 +237,10 @@ abstract class JsonLdGraphLike<T extends TripleLike<BlankNodeOrIRI,
IRI, RDFTerm
 		};
 	}
 	
-	@Override
-	public long size() {		
-		return rdfDataSet.graphNames().parallelStream().map(rdfDataSet::getQuads).collect(Collectors.summingLong(List::size));
+	// NOTE: This is made public in JsonLdDataset and is used by the other remove methods.
+	void remove(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate,
RDFTerm object) {
+		// remove the quads which match our filter (which could have nulls as wildcards) 
+		filteredGraphs(graphName).forEach(t -> t.removeIf(quadFilter(subject, predicate, object)));
 	}
 	
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ca11a42b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java
b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java
index be271ea..15bc466 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java
@@ -52,19 +52,52 @@ public final class JsonLdRDFTermFactory implements RDFTermFactory {
 		this.bnodePrefix = bnodePrefix;
 	}
 	
-	@Override
-	public Graph createGraph() throws UnsupportedOperationException {
-		return new JsonLdGraph(bnodePrefix);
+	public Node asJsonLdNode(RDFTerm term) {
+		if (term instanceof JsonLdTerm) {
+			// Return original Node
+			return ((JsonLdTerm)term).asNode();
+		}
+		if (term instanceof IRI) {
+			return new RDFDataset.IRI( ((IRI)term).getIRIString() );
+		}
+		if (term instanceof BlankNode) {
+			
+			String ref = ((BlankNode)term).uniqueReference();
+			if (ref.startsWith(bnodePrefix)) {
+				// one of our own (but no longer a JsonLdBlankNode),
+				// we can recover the label after our unique prefix
+				return new RDFDataset.BlankNode(ref.replace(bnodePrefix, ""));
+			} 
+			// The "foreign" unique reference might not be a valid bnode string, 
+			// we'll convert to a UUID
+			UUID uuid = UUID.nameUUIDFromBytes(ref.getBytes(StandardCharsets.UTF_8));
+			return new RDFDataset.BlankNode( "_:" + uuid );
+		}
+		if (term instanceof Literal) {
+			Literal literal = (Literal) term;
+			return new RDFDataset.Literal(literal.getLexicalForm(), literal.getDatatype().getIRIString(),

+					literal.getLanguageTag().orElse(null));
+		}
+		throw new IllegalArgumentException("RDFTerm not instanceof IRI, BlankNode or Literal: "
+ term);
 	}
 	
-	@Override
-	public Dataset createDataset() throws UnsupportedOperationException {
-		return new JsonLdDataset(bnodePrefix);
+	public RDFDataset.Quad asJsonLdQuad(RDFTerm subject, RDFTerm predicate, RDFTerm object)
{
+		return asJsonLdQuad(null, subject, predicate, object);
 	}
 	
-	@Override
-	public JsonLdIRI createIRI(String iri) {
-		return new JsonLdIRI.JsonLdIRIImpl(iri);
+	public RDFDataset.Quad asJsonLdQuad(RDFTerm graphName, RDFTerm subject, RDFTerm predicate,
RDFTerm object) {
+		String graph = null;
+		return new RDFDataset.Quad(asJsonLdNode(subject), asJsonLdNode(predicate), asJsonLdNode(object),
graph);
+	}
+	
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public RDFDataset.Quad asJsonLdQuad(TripleLike tripleOrQuad) {
+		RDFTerm g = null;	
+		if (tripleOrQuad instanceof QuadLike) {
+			QuadLike quadLike = (QuadLike) tripleOrQuad;
+			g = (RDFTerm) quadLike.getGraphName().orElse(null);
+		}		
+		return asJsonLdQuad(g, tripleOrQuad.getSubject(), tripleOrQuad.getPredicate(), tripleOrQuad.getObject());
 	}
 	
 	@Override
@@ -81,22 +114,18 @@ public final class JsonLdRDFTermFactory implements RDFTermFactory {
 	}
 	
 	@Override
-	public JsonLdTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
{
-		return new JsonLdTripleImpl(asJsonLdQuad(subject, predicate, object), bnodePrefix);
-	}
-	
-	public JsonLdTriple createTriple(final RDFDataset.Quad quad) {
-		return new JsonLdTripleImpl(quad, bnodePrefix);
+	public Dataset createDataset() throws UnsupportedOperationException {
+		return new JsonLdDataset(bnodePrefix);
 	}
 
-	public JsonLdQuad createQuad(final RDFDataset.Quad quad) {
-		return new JsonLdQuadImpl(quad, bnodePrefix);
+	@Override
+	public Graph createGraph() throws UnsupportedOperationException {
+		return new JsonLdGraph(bnodePrefix);
 	}
 	
 	@Override
-	public JsonLdQuad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate,
RDFTerm object)
-			throws IllegalArgumentException, UnsupportedOperationException {
-		return new JsonLdQuadImpl(asJsonLdQuad(graphName, subject, predicate, object), bnodePrefix);
+	public JsonLdIRI createIRI(String iri) {
+		return new JsonLdIRI.JsonLdIRIImpl(iri);
 	}
 	
 	@Override
@@ -114,53 +143,24 @@ public final class JsonLdRDFTermFactory implements RDFTermFactory {
 		return new JsonLdLiteralImpl(new RDFDataset.Literal(literal, Types.RDF_LANGSTRING.getIRIString(),
language));
 	}
 
-	public Node asJsonLdNode(RDFTerm term) {
-		if (term instanceof JsonLdTerm) {
-			// Return original Node
-			return ((JsonLdTerm)term).asNode();
-		}
-		if (term instanceof IRI) {
-			return new RDFDataset.IRI( ((IRI)term).getIRIString() );
-		}
-		if (term instanceof BlankNode) {
-			
-			String ref = ((BlankNode)term).uniqueReference();
-			if (ref.startsWith(bnodePrefix)) {
-				// one of our own (but no longer a JsonLdBlankNode),
-				// we can recover the label after our unique prefix
-				return new RDFDataset.BlankNode(ref.replace(bnodePrefix, ""));
-			} 
-			// The "foreign" unique reference might not be a valid bnode string, 
-			// we'll convert to a UUID
-			UUID uuid = UUID.nameUUIDFromBytes(ref.getBytes(StandardCharsets.UTF_8));
-			return new RDFDataset.BlankNode( "_:" + uuid );
-		}
-		if (term instanceof Literal) {
-			Literal literal = (Literal) term;
-			return new RDFDataset.Literal(literal.getLexicalForm(), literal.getDatatype().getIRIString(),

-					literal.getLanguageTag().orElse(null));
-		}
-		throw new IllegalArgumentException("RDFTerm not instanceof IRI, BlankNode or Literal: "
+ term);
+	@Override
+	public JsonLdQuad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate,
RDFTerm object)
+			throws IllegalArgumentException, UnsupportedOperationException {
+		return new JsonLdQuadImpl(asJsonLdQuad(graphName, subject, predicate, object), bnodePrefix);
 	}
 	
 
-	public RDFDataset.Quad asJsonLdQuad(RDFTerm subject, RDFTerm predicate, RDFTerm object)
{
-		return asJsonLdQuad(null, subject, predicate, object);
+	public JsonLdQuad createQuad(final RDFDataset.Quad quad) {
+		return new JsonLdQuadImpl(quad, bnodePrefix);
 	}
 
-	public RDFDataset.Quad asJsonLdQuad(RDFTerm graphName, RDFTerm subject, RDFTerm predicate,
RDFTerm object) {
-		String graph = null;
-		return new RDFDataset.Quad(asJsonLdNode(subject), asJsonLdNode(predicate), asJsonLdNode(object),
graph);
+	@Override
+	public JsonLdTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
{
+		return new JsonLdTripleImpl(asJsonLdQuad(subject, predicate, object), bnodePrefix);
 	}
 	
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public RDFDataset.Quad asJsonLdQuad(TripleLike tripleOrQuad) {
-		RDFTerm g = null;	
-		if (tripleOrQuad instanceof QuadLike) {
-			QuadLike quadLike = (QuadLike) tripleOrQuad;
-			g = (RDFTerm) quadLike.getGraphName().orElse(null);
-		}		
-		return asJsonLdQuad(g, tripleOrQuad.getSubject(), tripleOrQuad.getPredicate(), tripleOrQuad.getObject());
+	public JsonLdTriple createTriple(final RDFDataset.Quad quad) {
+		return new JsonLdTripleImpl(quad, bnodePrefix);
 	}
 	
 	JsonLdTerm asTerm(final Node node, String blankNodePrefix) {	

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ca11a42b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java
b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java
index 760ccd4..b9b4acb 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java
@@ -18,8 +18,10 @@
 /**
  * Integration with jsonld-java
  * 
- * @see org.apache.commons.rdf.jsonldjava.JsonLdGraph
  * @see org.apache.commons.rdf.jsonldjava.JsonLdRDFTermFactory
+ * @see org.apache.commons.rdf.jsonldjava.JsonLdGraph
+ * @see org.apache.commons.rdf.jsonldjava.JsonLdUnionGraph
+ * @see org.apache.commons.rdf.jsonldjava.JsonLdDataset
  * 
  */
 package org.apache.commons.rdf.jsonldjava;
\ No newline at end of file


Mime
View raw message