commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [45/49] incubator-commonsrdf git commit: Reformat tab -> spaces
Date Fri, 28 Oct 2016 13:15:07 GMT
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
index 17cb641..2cb0876 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
@@ -42,150 +42,135 @@ import org.apache.jena.sparql.core.GraphView;
 
 class JenaDatasetImpl implements JenaDataset {
 
-	private DatasetGraph graph;
-	private UUID salt;
-	private JenaRDF factory;
-
-	JenaDatasetImpl(DatasetGraph graph, UUID salt) {
-		this.graph = graph;
-		this.salt = salt;
-		this.factory = new JenaRDF(salt);
-	}
-
-	@Override
-	public void add(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		graph.add(				
-				org.apache.jena.sparql.core.Quad.create(
-				factory.asJenaNode(graphName),
-				factory.asJenaNode(subject),				
-				factory.asJenaNode(predicate), 
-				factory.asJenaNode(object)));
-	}
-
-	@Override
-	public void add(Quad quad) {
-		graph.add(factory.asJenaQuad(quad));
-	}
-	
-	@Override
-	public DatasetGraph asJenaDatasetGraph() {		
-		return graph;
-	}
-
-	@Override
-	public void clear() {
-		graph.clear();
-	}
-
-	@Override
-	public void close() {
-		graph.close();
-	}
-
-
-	@Override
-	public boolean contains(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {		
-		return graph.contains(
-				toJenaPattern(graphName),
-				toJenaPattern(subject), 
-				toJenaPattern(predicate),
-				toJenaPattern(object));
-	}
-
-	private Node toJenaPattern(Optional<? extends RDFTerm> graphName) {
-		// In theory we could have done:
-		//   factory.toJena(graphName.orElse(internalJenaFactory::createAnyVariable))
-		// but because of generics casting rules that doesn't work :(						
-
-		if (graphName == null) {
-			return ANY;
-		}
-		// null: default graph
-		return factory.asJenaNode(graphName.orElse(null));
-	}
-
-	private Node toJenaPattern(RDFTerm term) {
-		if (term == null)
-			return ANY;
-		return factory.asJenaNode(term);
-	}
-
-	@Override
-	public boolean contains(Quad quad) {
-		return graph.contains(factory.asJenaQuad(quad));
-	}
-
-	@Override
-	public void remove(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		graph.delete(org.apache.jena.sparql.core.Quad.create(
-				toJenaPattern(graphName),
-				toJenaPattern(subject),
-				toJenaPattern(predicate), 
-				toJenaPattern(object)));
-	}
-
-	@Override
-	public void remove(Quad quad) {
-		graph.delete(factory.asJenaQuad(quad));
-	}
-
-	@Override
-	public long size() {
-		return graph.size();
-	}
-
-	@Override
-	public Stream<? extends Quad> stream() {
-		JenaRDF factory = new JenaRDF(salt);
-		return Iter.asStream(graph.find(ANY, ANY, ANY, ANY), true)
-				.map(factory::asQuad);
-	}
-
-	@Override
-	public Stream<? extends Quad> stream(Optional<BlankNodeOrIRI> g, BlankNodeOrIRI s, IRI p, RDFTerm o) {
-		JenaRDF factory = new JenaRDF(salt);
-		return Iter.asStream(graph.find(toJenaPattern(g), toJenaPattern(s), toJenaPattern(p), toJenaPattern(o)), true)
-				.map(factory::asQuad);
-	}
-
-	@Override
-	public String toString() {
-		StringWriter sw = new StringWriter();
-		RDFDataMgr.write(sw, graph, Lang.NT);
-		return sw.toString();
-	}
-
-	@Override
-	public Graph getGraph() {
-		GraphView gv = GraphView.createDefaultGraph(graph);
-		return new JenaGraphImpl(gv, salt);
-	}
-
-	@Override
-	public JenaGraph getUnionGraph() {
-		GraphView gv = GraphView.createUnionGraph(graph);
-		return new JenaGraphImpl(gv, salt);
-	}
-	
-	@Override
-	public Optional<Graph> getGraph(BlankNodeOrIRI graphName) {
-		GraphView gv = GraphView.createNamedGraph(graph, factory.asJenaNode(graphName));
-		return Optional.of(new JenaGraphImpl(gv, salt));
-	}	
-
-	@Override
-	public Stream<BlankNodeOrIRI> getGraphNames() {
-		JenaRDF factory = new JenaRDF(salt);
-		return Iter.asStream(graph.listGraphNodes()).map(node -> 
-			(BlankNodeOrIRI) factory.asRDFTerm(node));		
-	}
-
-	@Override
-	public Iterable<Quad> iterate() {
-		final JenaRDF factory = new JenaRDF(salt);
-		return Iter.asStream(graph.find(), false)
-				.map(q -> (Quad) factory.asQuad(q))
-				::iterator;
-	}
+    private DatasetGraph graph;
+    private UUID salt;
+    private JenaRDF factory;
+
+    JenaDatasetImpl(DatasetGraph graph, UUID salt) {
+        this.graph = graph;
+        this.salt = salt;
+        this.factory = new JenaRDF(salt);
+    }
+
+    @Override
+    public void add(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        graph.add(org.apache.jena.sparql.core.Quad.create(factory.asJenaNode(graphName), factory.asJenaNode(subject),
+                factory.asJenaNode(predicate), factory.asJenaNode(object)));
+    }
+
+    @Override
+    public void add(Quad quad) {
+        graph.add(factory.asJenaQuad(quad));
+    }
+
+    @Override
+    public DatasetGraph asJenaDatasetGraph() {
+        return graph;
+    }
+
+    @Override
+    public void clear() {
+        graph.clear();
+    }
+
+    @Override
+    public void close() {
+        graph.close();
+    }
+
+    @Override
+    public boolean contains(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        return graph.contains(toJenaPattern(graphName), toJenaPattern(subject), toJenaPattern(predicate),
+                toJenaPattern(object));
+    }
+
+    private Node toJenaPattern(Optional<? extends RDFTerm> graphName) {
+        // In theory we could have done:
+        // factory.toJena(graphName.orElse(internalJenaFactory::createAnyVariable))
+        // but because of generics casting rules that doesn't work :(
+
+        if (graphName == null) {
+            return ANY;
+        }
+        // null: default graph
+        return factory.asJenaNode(graphName.orElse(null));
+    }
+
+    private Node toJenaPattern(RDFTerm term) {
+        if (term == null)
+            return ANY;
+        return factory.asJenaNode(term);
+    }
+
+    @Override
+    public boolean contains(Quad quad) {
+        return graph.contains(factory.asJenaQuad(quad));
+    }
+
+    @Override
+    public void remove(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        graph.delete(org.apache.jena.sparql.core.Quad.create(toJenaPattern(graphName), toJenaPattern(subject),
+                toJenaPattern(predicate), toJenaPattern(object)));
+    }
+
+    @Override
+    public void remove(Quad quad) {
+        graph.delete(factory.asJenaQuad(quad));
+    }
+
+    @Override
+    public long size() {
+        return graph.size();
+    }
+
+    @Override
+    public Stream<? extends Quad> stream() {
+        JenaRDF factory = new JenaRDF(salt);
+        return Iter.asStream(graph.find(ANY, ANY, ANY, ANY), true).map(factory::asQuad);
+    }
+
+    @Override
+    public Stream<? extends Quad> stream(Optional<BlankNodeOrIRI> g, BlankNodeOrIRI s, IRI p, RDFTerm o) {
+        JenaRDF factory = new JenaRDF(salt);
+        return Iter.asStream(graph.find(toJenaPattern(g), toJenaPattern(s), toJenaPattern(p), toJenaPattern(o)), true)
+                .map(factory::asQuad);
+    }
+
+    @Override
+    public String toString() {
+        StringWriter sw = new StringWriter();
+        RDFDataMgr.write(sw, graph, Lang.NT);
+        return sw.toString();
+    }
+
+    @Override
+    public Graph getGraph() {
+        GraphView gv = GraphView.createDefaultGraph(graph);
+        return new JenaGraphImpl(gv, salt);
+    }
+
+    @Override
+    public JenaGraph getUnionGraph() {
+        GraphView gv = GraphView.createUnionGraph(graph);
+        return new JenaGraphImpl(gv, salt);
+    }
+
+    @Override
+    public Optional<Graph> getGraph(BlankNodeOrIRI graphName) {
+        GraphView gv = GraphView.createNamedGraph(graph, factory.asJenaNode(graphName));
+        return Optional.of(new JenaGraphImpl(gv, salt));
+    }
+
+    @Override
+    public Stream<BlankNodeOrIRI> getGraphNames() {
+        JenaRDF factory = new JenaRDF(salt);
+        return Iter.asStream(graph.listGraphNodes()).map(node -> (BlankNodeOrIRI) factory.asRDFTerm(node));
+    }
+
+    @Override
+    public Iterable<Quad> iterate() {
+        final JenaRDF factory = new JenaRDF(salt);
+        return Iter.asStream(graph.find(), false).map(q -> (Quad) factory.asQuad(q))::iterator;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedQuadLikeImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedQuadLikeImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedQuadLikeImpl.java
index df74900..65eaae5 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedQuadLikeImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedQuadLikeImpl.java
@@ -25,15 +25,14 @@ import org.apache.commons.rdf.jena.JenaGeneralizedQuadLike;
 import org.apache.jena.sparql.core.Quad;
 
 class JenaGeneralizedQuadLikeImpl extends AbstractQuadLike<RDFTerm, RDFTerm, RDFTerm, RDFTerm>
-	implements JenaGeneralizedQuadLike {
+        implements JenaGeneralizedQuadLike {
 
-	JenaGeneralizedQuadLikeImpl(RDFTerm subject, RDFTerm predicate, RDFTerm object,
-			Optional<RDFTerm> ofNullable) {
-		super(subject, predicate, object, ofNullable);
-	}
+    JenaGeneralizedQuadLikeImpl(RDFTerm subject, RDFTerm predicate, RDFTerm object, Optional<RDFTerm> ofNullable) {
+        super(subject, predicate, object, ofNullable);
+    }
 
-	JenaGeneralizedQuadLikeImpl(Quad quad, UUID salt) {
-		super(quad, salt);
-	}
+    JenaGeneralizedQuadLikeImpl(Quad quad, UUID salt) {
+        super(quad, salt);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedTripleLikeImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedTripleLikeImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedTripleLikeImpl.java
index ecaa46a..a54075a 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedTripleLikeImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedTripleLikeImpl.java
@@ -24,14 +24,14 @@ import org.apache.commons.rdf.jena.JenaGeneralizedTripleLike;
 import org.apache.jena.graph.Triple;
 
 class JenaGeneralizedTripleLikeImpl extends AbstractQuadLike<RDFTerm, RDFTerm, RDFTerm, RDFTerm>
-	implements JenaGeneralizedTripleLike {
+        implements JenaGeneralizedTripleLike {
 
-	JenaGeneralizedTripleLikeImpl(RDFTerm subject, RDFTerm predicate, RDFTerm object) {
-		super(subject, predicate, object);
-	}
+    JenaGeneralizedTripleLikeImpl(RDFTerm subject, RDFTerm predicate, RDFTerm object) {
+        super(subject, predicate, object);
+    }
 
-	JenaGeneralizedTripleLikeImpl(Triple triple, UUID salt) {
-		super(triple, salt);
-	}
+    JenaGeneralizedTripleLikeImpl(Triple triple, UUID salt) {
+        super(triple, salt);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
index fd2f6c4..c482a0f 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
@@ -37,121 +37,114 @@ import org.apache.jena.riot.RDFDataMgr;
 
 class JenaGraphImpl implements JenaGraph {
 
-	private final org.apache.jena.graph.Graph graph;
-	private final UUID salt;
-	private final transient JenaRDF factory;
-	private Model model;
-
-	JenaGraphImpl(org.apache.jena.graph.Graph graph, UUID salt) {
-		this.graph = graph;
-		this.salt = salt;
-		this.factory = new JenaRDF(salt);
-	}
-
-	JenaGraphImpl(Model model, UUID salt) {
-		this.model = model;
-		this.graph = model.getGraph();
-		this.salt = salt;
-		this.factory = new JenaRDF(salt);
-	}
-
-	@Override
-	public void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		graph.add(org.apache.jena.graph.Triple.create(
-				factory.asJenaNode(subject),
-				factory.asJenaNode(predicate), 
-				factory.asJenaNode(object)));
-	}
-
-	@Override
-	public void add(Triple triple) {
-		graph.add(factory.asJenaTriple(triple));
-	}
-
-	@Override
-	public org.apache.jena.graph.Graph asJenaGraph() {
-		return graph;
-	}
-
-	@Override
-	public void clear() {
-		graph.clear();
-	}
-
-	@Override
-	public void close() {
-		graph.close();
-	}
-
-	@Override
-	public boolean contains(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		return graph.contains(
-				factory.asJenaNode(subject), 
-				factory.asJenaNode(predicate),
-				factory.asJenaNode(object));
-	}
-
-	@Override
-	public boolean contains(Triple triple) {
-		return graph.contains(factory.asJenaTriple(triple));
-	}
-
-	@Override
-	public void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		graph.delete(org.apache.jena.graph.Triple.create(
-				factory.asJenaNode(subject),
-				factory.asJenaNode(predicate), 
-				factory.asJenaNode(object)));
-	}
-
-	@Override
-	public void remove(Triple triple) {
-		graph.delete(factory.asJenaTriple(triple));
-	}
-
-	@Override
-	public long size() {
-		return graph.size();
-	}
-
-	@Override
-	public Stream<? extends Triple> stream() {
-		JenaRDF factory = new JenaRDF(salt);
-		return Iter.asStream(graph.find(null, null, null), true).map(factory::asTriple);
-	}
-
-	@Override
-	public Stream<? extends Triple> stream(BlankNodeOrIRI s, IRI p, RDFTerm o) {
-		JenaRDF factory = new JenaRDF(salt);
-		return Iter.asStream(graph.find(toJenaAny(s), toJenaAny(p), toJenaAny(o)), true)
-				.map(factory::asTriple);
-	}
-
-	private Node toJenaAny(RDFTerm term) {
-		if (term == null)
-			return Node.ANY;
-		return factory.asJenaNode(term);
-	}
-
-	@Override
-	public String toString() {
-		StringWriter sw = new StringWriter();
-		RDFDataMgr.write(sw, graph, Lang.NT);
-		return sw.toString();
-	}
-
-	@Override
-	public Model asJenaModel() {
-		if (model == null) {
-			synchronized(this) {
-				// As Model can be used for locks, we should make sure we don't make
-				// more than one model
-				if (model == null) {
-					model = ModelFactory.createModelForGraph(graph);
-				}
-			}
-		}
-		return model;
-	}
+    private final org.apache.jena.graph.Graph graph;
+    private final UUID salt;
+    private final transient JenaRDF factory;
+    private Model model;
+
+    JenaGraphImpl(org.apache.jena.graph.Graph graph, UUID salt) {
+        this.graph = graph;
+        this.salt = salt;
+        this.factory = new JenaRDF(salt);
+    }
+
+    JenaGraphImpl(Model model, UUID salt) {
+        this.model = model;
+        this.graph = model.getGraph();
+        this.salt = salt;
+        this.factory = new JenaRDF(salt);
+    }
+
+    @Override
+    public void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        graph.add(org.apache.jena.graph.Triple.create(factory.asJenaNode(subject), factory.asJenaNode(predicate),
+                factory.asJenaNode(object)));
+    }
+
+    @Override
+    public void add(Triple triple) {
+        graph.add(factory.asJenaTriple(triple));
+    }
+
+    @Override
+    public org.apache.jena.graph.Graph asJenaGraph() {
+        return graph;
+    }
+
+    @Override
+    public void clear() {
+        graph.clear();
+    }
+
+    @Override
+    public void close() {
+        graph.close();
+    }
+
+    @Override
+    public boolean contains(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        return graph.contains(factory.asJenaNode(subject), factory.asJenaNode(predicate), factory.asJenaNode(object));
+    }
+
+    @Override
+    public boolean contains(Triple triple) {
+        return graph.contains(factory.asJenaTriple(triple));
+    }
+
+    @Override
+    public void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        graph.delete(org.apache.jena.graph.Triple.create(factory.asJenaNode(subject), factory.asJenaNode(predicate),
+                factory.asJenaNode(object)));
+    }
+
+    @Override
+    public void remove(Triple triple) {
+        graph.delete(factory.asJenaTriple(triple));
+    }
+
+    @Override
+    public long size() {
+        return graph.size();
+    }
+
+    @Override
+    public Stream<? extends Triple> stream() {
+        JenaRDF factory = new JenaRDF(salt);
+        return Iter.asStream(graph.find(null, null, null), true).map(factory::asTriple);
+    }
+
+    @Override
+    public Stream<? extends Triple> stream(BlankNodeOrIRI s, IRI p, RDFTerm o) {
+        JenaRDF factory = new JenaRDF(salt);
+        return Iter.asStream(graph.find(toJenaAny(s), toJenaAny(p), toJenaAny(o)), true).map(factory::asTriple);
+    }
+
+    private Node toJenaAny(RDFTerm term) {
+        if (term == null)
+            return Node.ANY;
+        return factory.asJenaNode(term);
+    }
+
+    @Override
+    public String toString() {
+        StringWriter sw = new StringWriter();
+        RDFDataMgr.write(sw, graph, Lang.NT);
+        return sw.toString();
+    }
+
+    @Override
+    public Model asJenaModel() {
+        if (model == null) {
+            synchronized (this) {
+                // As Model can be used for locks, we should make sure we don't
+                // make
+                // more than one model
+                if (model == null) {
+                    model = ModelFactory.createModelForGraph(graph);
+                }
+            }
+        }
+        return model;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaIRIImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaIRIImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaIRIImpl.java
index 7fbf284..e09dbaf 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaIRIImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaIRIImpl.java
@@ -25,37 +25,37 @@ import org.apache.jena.graph.NodeFactory;
 
 class JenaIRIImpl extends AbstractJenaRDFTerm implements JenaIRI {
 
-	JenaIRIImpl(Node node) {
-		super(node);
-		if (! node.isURI()) {
-			throw new IllegalArgumentException("Node is not a blank node: " + node);
-		}				
-		
-	}
-
-	JenaIRIImpl(String iriStr) {
-		super(NodeFactory.createURI(iriStr));
-	}
-
-	@Override
-	public boolean equals(Object other) {
-		if (other == this)
-			return true;
-		if (other == null)
-			return false;
-		if (!(other instanceof IRI))
-			return false;
-		IRI iri = (IRI) other;
-		return getIRIString().equals(iri.getIRIString());
-	}
-
-	@Override
-	public String getIRIString() {
-		return asJenaNode().getURI();
-	}
-
-	@Override
-	public int hashCode() {
-		return getIRIString().hashCode();
-	}
+    JenaIRIImpl(Node node) {
+        super(node);
+        if (!node.isURI()) {
+            throw new IllegalArgumentException("Node is not a blank node: " + node);
+        }
+
+    }
+
+    JenaIRIImpl(String iriStr) {
+        super(NodeFactory.createURI(iriStr));
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (other == this)
+            return true;
+        if (other == null)
+            return false;
+        if (!(other instanceof IRI))
+            return false;
+        IRI iri = (IRI) other;
+        return getIRIString().equals(iri.getIRIString());
+    }
+
+    @Override
+    public String getIRIString() {
+        return asJenaNode().getURI();
+    }
+
+    @Override
+    public int hashCode() {
+        return getIRIString().hashCode();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaLiteralImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaLiteralImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaLiteralImpl.java
index 74c6d9c..d2afbe3 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaLiteralImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaLiteralImpl.java
@@ -28,48 +28,49 @@ import org.apache.jena.graph.Node;
 
 class JenaLiteralImpl extends AbstractJenaRDFTerm implements JenaLiteral {
 
-	private static InternalJenaFactory internalJenaFactory = new InternalJenaFactory(){};
-	
-	JenaLiteralImpl(Node node) {
-		super(node);
-		if (! node.isLiteral()) {
-			throw new IllegalArgumentException("Node is not a literal: " + node);
-		}		
-	}
+    private static InternalJenaFactory internalJenaFactory = new InternalJenaFactory() {
+    };
 
-	@Override
-	public boolean equals(Object other) {
-		if (other == this)
-			return true;
-		if (other == null)
-			return false;
-		if (!(other instanceof Literal))
-			return false;
-		Literal literal = (Literal) other;
-		return getLexicalForm().equals(literal.getLexicalForm()) && getLanguageTag().equals(literal.getLanguageTag())
-				&& getDatatype().equals(literal.getDatatype());
-	}
+    JenaLiteralImpl(Node node) {
+        super(node);
+        if (!node.isLiteral()) {
+            throw new IllegalArgumentException("Node is not a literal: " + node);
+        }
+    }
 
-	@Override
-	public IRI getDatatype() {
-		return internalJenaFactory.createIRI(asJenaNode().getLiteralDatatype().getURI());
-	}
+    @Override
+    public boolean equals(Object other) {
+        if (other == this)
+            return true;
+        if (other == null)
+            return false;
+        if (!(other instanceof Literal))
+            return false;
+        Literal literal = (Literal) other;
+        return getLexicalForm().equals(literal.getLexicalForm()) && getLanguageTag().equals(literal.getLanguageTag())
+                && getDatatype().equals(literal.getDatatype());
+    }
 
-	@Override
-	public Optional<String> getLanguageTag() {
-		String x = asJenaNode().getLiteralLanguage();
-		if (x == null || x.isEmpty())
-			return Optional.empty();
-		return Optional.of(x);
-	}
+    @Override
+    public IRI getDatatype() {
+        return internalJenaFactory.createIRI(asJenaNode().getLiteralDatatype().getURI());
+    }
 
-	@Override
-	public String getLexicalForm() {
-		return asJenaNode().getLiteralLexicalForm();
-	}
+    @Override
+    public Optional<String> getLanguageTag() {
+        String x = asJenaNode().getLiteralLanguage();
+        if (x == null || x.isEmpty())
+            return Optional.empty();
+        return Optional.of(x);
+    }
 
-	@Override
-	public int hashCode() {
-		return Objects.hash(getLexicalForm(), getDatatype(), getLanguageTag());
-	}
+    @Override
+    public String getLexicalForm() {
+        return asJenaNode().getLiteralLexicalForm();
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(getLexicalForm(), getDatatype(), getLanguageTag());
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaQuadImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaQuadImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaQuadImpl.java
index 61ddf9b..e69200f 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaQuadImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaQuadImpl.java
@@ -29,38 +29,36 @@ import org.apache.commons.rdf.api.RDFTerm;
 import org.apache.commons.rdf.jena.ConversionException;
 import org.apache.commons.rdf.jena.JenaQuad;
 
-class JenaQuadImpl	extends AbstractQuadLike<BlankNodeOrIRI,IRI,RDFTerm,BlankNodeOrIRI>
-	implements JenaQuad {
+class JenaQuadImpl extends AbstractQuadLike<BlankNodeOrIRI, IRI, RDFTerm, BlankNodeOrIRI> implements JenaQuad {
 
-	JenaQuadImpl(BlankNodeOrIRI subject, IRI predicate, RDFTerm object, Optional<BlankNodeOrIRI> graphName) {
-		super(subject, predicate, object, graphName);
-	}
+    JenaQuadImpl(BlankNodeOrIRI subject, IRI predicate, RDFTerm object, Optional<BlankNodeOrIRI> graphName) {
+        super(subject, predicate, object, graphName);
+    }
 
-	JenaQuadImpl(org.apache.jena.sparql.core.Quad quad, UUID salt) {
-		super(quad, salt);
-		// Check the conversion
-		if ((graphName.isPresent() && ! (graphName.get() instanceof BlankNodeOrIRI)) ||
-			! (subject instanceof BlankNodeOrIRI) ||
-			! (predicate instanceof IRI) ||
-			! (object instanceof RDFTerm)) {
-			throw new ConversionException("Can't adapt generalized quad: " + quad);	
-		}
-	}
+    JenaQuadImpl(org.apache.jena.sparql.core.Quad quad, UUID salt) {
+        super(quad, salt);
+        // Check the conversion
+        if ((graphName.isPresent() && !(graphName.get() instanceof BlankNodeOrIRI))
+                || !(subject instanceof BlankNodeOrIRI) || !(predicate instanceof IRI)
+                || !(object instanceof RDFTerm)) {
+            throw new ConversionException("Can't adapt generalized quad: " + quad);
+        }
+    }
 
-	@Override
-	public boolean equals(Object other) {
-		if (other == this)
-			return true;
-		if (!(other instanceof Quad))
-			return false;
-		Quad quad = (Quad) other;
-		return getGraphName().equals(quad.getGraphName()) && getSubject().equals(quad.getSubject())
-				&& getPredicate().equals(quad.getPredicate()) && getObject().equals(quad.getObject());
-	}
+    @Override
+    public boolean equals(Object other) {
+        if (other == this)
+            return true;
+        if (!(other instanceof Quad))
+            return false;
+        Quad quad = (Quad) other;
+        return getGraphName().equals(quad.getGraphName()) && getSubject().equals(quad.getSubject())
+                && getPredicate().equals(quad.getPredicate()) && getObject().equals(quad.getObject());
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(getSubject(), getPredicate(), getObject(), getGraphName());
+    }
 
-	@Override
-	public int hashCode() {
-		return Objects.hash(getSubject(), getPredicate(), getObject(), getGraphName());
-	}
-	
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaTripleImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaTripleImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaTripleImpl.java
index 453300c..b9de91f 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaTripleImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaTripleImpl.java
@@ -28,40 +28,36 @@ import org.apache.commons.rdf.api.Triple;
 import org.apache.commons.rdf.jena.ConversionException;
 import org.apache.commons.rdf.jena.JenaTriple;
 
-class JenaTripleImpl extends AbstractQuadLike<BlankNodeOrIRI, IRI, RDFTerm, RDFTerm>
-		implements JenaTriple {
+class JenaTripleImpl extends AbstractQuadLike<BlankNodeOrIRI, IRI, RDFTerm, RDFTerm> implements JenaTriple {
+
+    JenaTripleImpl(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        super(subject, predicate, object);
+    }
+
+    JenaTripleImpl(org.apache.jena.graph.Triple triple, UUID salt) throws ConversionException {
+        super(triple, salt);
+        // Check the conversion
+        if (!(subject instanceof BlankNodeOrIRI) || !(predicate instanceof IRI) || !(object instanceof RDFTerm)) {
+            throw new ConversionException("Can't adapt generalized triple: " + quad);
+        }
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (other == this)
+            return true;
+        if (other == null)
+            return false;
+        if (!(other instanceof Triple))
+            return false;
+        Triple triple = (Triple) other;
+        return getSubject().equals(triple.getSubject()) && getPredicate().equals(triple.getPredicate())
+                && getObject().equals(triple.getObject());
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(getSubject(), getPredicate(), getObject());
+    }
 
-	JenaTripleImpl(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		super(subject, predicate, object);
-	}
-
-	JenaTripleImpl(org.apache.jena.graph.Triple triple, UUID salt) throws ConversionException {
-		super(triple, salt);
-		// Check the conversion
-		if (! (subject instanceof BlankNodeOrIRI) ||
-			! (predicate instanceof IRI) ||
-			! (object instanceof RDFTerm)) {
-			throw new ConversionException("Can't adapt generalized triple: " + quad);	
-		}
-	}
-
-	@Override
-	public boolean equals(Object other) {
-		if (other == this)
-			return true;
-		if (other == null)
-			return false;
-		if (!(other instanceof Triple))
-			return false;
-		Triple triple = (Triple) other;
-		return getSubject().equals(triple.getSubject()) && getPredicate().equals(triple.getPredicate())
-				&& getObject().equals(triple.getObject());
-	}
-
-	@Override
-	public int hashCode() {
-		return Objects.hash(getSubject(), getPredicate(), getObject());
-	}
-
-	
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/test/java/org/apache/commons/rdf/jena/JenaRDFTest.java
----------------------------------------------------------------------
diff --git a/jena/src/test/java/org/apache/commons/rdf/jena/JenaRDFTest.java b/jena/src/test/java/org/apache/commons/rdf/jena/JenaRDFTest.java
index 87a4618..72986d0 100644
--- a/jena/src/test/java/org/apache/commons/rdf/jena/JenaRDFTest.java
+++ b/jena/src/test/java/org/apache/commons/rdf/jena/JenaRDFTest.java
@@ -22,11 +22,10 @@ import org.apache.commons.rdf.api.AbstractRDFTest;
 import org.apache.commons.rdf.api.RDF;
 
 public class JenaRDFTest extends AbstractRDFTest {
-	
+
     @Override
     public RDF createFactory() {
         return new JenaRDF();
     }
 
 }
-

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/test/java/org/apache/commons/rdf/jena/JenaServiceLoaderTest.java
----------------------------------------------------------------------
diff --git a/jena/src/test/java/org/apache/commons/rdf/jena/JenaServiceLoaderTest.java b/jena/src/test/java/org/apache/commons/rdf/jena/JenaServiceLoaderTest.java
index 836e2ec..dc0c8bd 100644
--- a/jena/src/test/java/org/apache/commons/rdf/jena/JenaServiceLoaderTest.java
+++ b/jena/src/test/java/org/apache/commons/rdf/jena/JenaServiceLoaderTest.java
@@ -31,10 +31,10 @@ public class JenaServiceLoaderTest {
     public void testServiceLoaderLookup() {
         ServiceLoader<RDF> loader = ServiceLoader.load(RDF.class);
         for (RDF impl : loader) {
-        	if (impl instanceof JenaRDF) {
-        		return; // yay
-        	}
+            if (impl instanceof JenaRDF) {
+                return; // yay
+            }
         }
-        fail("JenaRDF not found in ServiceLoader");        
+        fail("JenaRDF not found in ServiceLoader");
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/test/java/org/apache/commons/rdf/jena/TestBlankNodeJena.java
----------------------------------------------------------------------
diff --git a/jena/src/test/java/org/apache/commons/rdf/jena/TestBlankNodeJena.java b/jena/src/test/java/org/apache/commons/rdf/jena/TestBlankNodeJena.java
index abe8080..49470c0 100644
--- a/jena/src/test/java/org/apache/commons/rdf/jena/TestBlankNodeJena.java
+++ b/jena/src/test/java/org/apache/commons/rdf/jena/TestBlankNodeJena.java
@@ -26,21 +26,21 @@ import org.apache.commons.rdf.jena.impl.InternalJenaFactory;
 
 public class TestBlankNodeJena extends AbstractBlankNodeTest {
 
-	InternalJenaFactory internalJenaFactory = new InternalJenaFactory(){};
-	
-	/** 
-	 * Fixed salt for the purpose of this test.
-	 */
+    InternalJenaFactory internalJenaFactory = new InternalJenaFactory() {
+    };
+
+    /**
+     * Fixed salt for the purpose of this test.
+     */
     private static final UUID SALT = UUID.fromString("ccfde817-55b8-4a5f-bc2d-6bfd8eaa41ce");
 
-	@Override
+    @Override
     protected BlankNode getBlankNode() {
         return internalJenaFactory.createBlankNode(SALT);
     }
-    
+
     @Override
     protected BlankNode getBlankNode(String identifier) {
         return internalJenaFactory.createBlankNode(identifier, SALT);
     }
 }
-

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/test/java/org/apache/commons/rdf/jena/TestGraphJena.java
----------------------------------------------------------------------
diff --git a/jena/src/test/java/org/apache/commons/rdf/jena/TestGraphJena.java b/jena/src/test/java/org/apache/commons/rdf/jena/TestGraphJena.java
index 296c42d..1ab01f9 100644
--- a/jena/src/test/java/org/apache/commons/rdf/jena/TestGraphJena.java
+++ b/jena/src/test/java/org/apache/commons/rdf/jena/TestGraphJena.java
@@ -29,4 +29,3 @@ public class TestGraphJena extends AbstractGraphTest {
     }
 
 }
-

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
----------------------------------------------------------------------
diff --git a/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java b/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
index 50bb1ff..632cce9 100644
--- a/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
+++ b/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
@@ -42,93 +42,82 @@ import org.junit.Test;
 /** Adapt a Jena Graph after parsing data into it */
 public class TestJenaGraphToCommonsRDFGraph {
     private static final boolean DEBUG = false;
-	private Path turtleFile;
+    private Path turtleFile;
 
-    
     @Before
-    public void preparePath() throws IOException {    	
-    	turtleFile = Files.createTempFile("commonsrdf", "test.ttl");    	
-    	Files.copy(getClass().getResourceAsStream("/D.ttl"), turtleFile, StandardCopyOption.REPLACE_EXISTING);
+    public void preparePath() throws IOException {
+        turtleFile = Files.createTempFile("commonsrdf", "test.ttl");
+        Files.copy(getClass().getResourceAsStream("/D.ttl"), turtleFile, StandardCopyOption.REPLACE_EXISTING);
     }
-    
+
     @After
     public void deletePath() throws IOException {
-    	if (turtleFile != null) { 
-    		Files.deleteIfExists(turtleFile);
-    	}
+        if (turtleFile != null) {
+            Files.deleteIfExists(turtleFile);
+        }
     }
-    
+
     @Test
-	public void jenaToCommonsRDF() throws Exception {
+    public void jenaToCommonsRDF() throws Exception {
         org.apache.jena.graph.Graph jGraph = GraphFactory.createGraphMem();
         RDFDataMgr.read(jGraph, turtleFile.toUri().toString());
-        
+
         JenaRDF factory = new JenaRDF();
-        
-        // "graph" is a CommonsRDF graph 
+
+        // "graph" is a CommonsRDF graph
         Graph graph = factory.asGraph(jGraph);
-        
-        
-        
+
         // The below check expected statements from D.ttl
-        
+
         JenaIRI p = factory.createIRI("http://example.com/p");
-		JenaIRI s = factory.createIRI("http://example.com/s");
-		JenaLiteral literal123 = factory.createLiteral("123", Types.XSD_INTEGER);
-		assertTrue(graph.contains(s, p, literal123));
-        
+        JenaIRI s = factory.createIRI("http://example.com/s");
+        JenaLiteral literal123 = factory.createLiteral("123", Types.XSD_INTEGER);
+        assertTrue(graph.contains(s, p, literal123));
+
         JenaIRI p1 = factory.createIRI("http://example.com/p1");
         // Let's look up the BlankNode
-		BlankNodeOrIRI bnode1 = graph.stream(null, p1, null)
-        		.findFirst().map(Triple::getSubject).get();
+        BlankNodeOrIRI bnode1 = graph.stream(null, p1, null).findFirst().map(Triple::getSubject).get();
         assertTrue(bnode1 instanceof BlankNode);
-        
+
         // Verify we can use BlankNode in query again
         RDFTerm obj = graph.stream(bnode1, p1, null).findFirst().map(Triple::getObject).get();
-        
+
         // Let's look up also that nested blank node
         assertTrue(obj instanceof BlankNode);
-        BlankNode bnode2 = (BlankNode)obj;
-        
-        
-        
+        BlankNode bnode2 = (BlankNode) obj;
+
         JenaIRI q = factory.createIRI("http://example.com/q");
         JenaLiteral literalR = factory.createLiteral("r", "en");
-		assertTrue(graph.contains(bnode2, q, literalR));
-        
+        assertTrue(graph.contains(bnode2, q, literalR));
+
+        // Can we add the same triple again as s/p/o
+        // without affecting graph size?
+        // Just to be evil we add a blanknode-iri-blanknode statement
+        assertEquals(3, graph.size());
+        graph.add(bnode1, p1, bnode2);
+        assertEquals(3, graph.size());
 
-		// Can we add the same triple again as s/p/o 
-		// without affecting graph size?
-		// Just to be evil we add a blanknode-iri-blanknode statement
+        // Add the same Triple again
+        graph.stream(bnode2, null, null).findFirst().ifPresent(graph::add);
         assertEquals(3, graph.size());
-		graph.add(bnode1, p1, bnode2);
-		assertEquals(3, graph.size());
-        
-		// Add the same Triple again
-		graph.stream(bnode2,null,null).findFirst().ifPresent(graph::add);
-		assertEquals(3, graph.size());
-		
-		
+
         // Add to CommonsRDF Graph
         JenaIRI s2 = factory.createIRI("http://example/s2");
-		JenaIRI p2 = factory.createIRI("http://example/p2");
-		JenaLiteral foo = factory.createLiteral("foo");
-		graph.add(s2,
-        		  p2,
-        		  foo);
-		assertEquals(4, graph.size());
-		assertTrue(graph.contains(s2,p2,foo));
-        
+        JenaIRI p2 = factory.createIRI("http://example/p2");
+        JenaLiteral foo = factory.createLiteral("foo");
+        graph.add(s2, p2, foo);
+        assertEquals(4, graph.size());
+        assertTrue(graph.contains(s2, p2, foo));
+
         // Verify the corresponding Jena Nodes are in Jena graph
         assertTrue(jGraph.contains(s2.asJenaNode(), p2.asJenaNode(), foo.asJenaNode()));
-        
+
         if (DEBUG) {
-	        System.out.println("==== Write CommonsRDF graph\n");
-	        graph.stream().forEach(System.out::println);        
-	        // And its in the Jena graph
-	        System.out.println("\n==== Write Jena graph directly\n");
-	        RDFDataMgr.write(System.out, jGraph, Lang.TTL);
+            System.out.println("==== Write CommonsRDF graph\n");
+            graph.stream().forEach(System.out::println);
+            // And its in the Jena graph
+            System.out.println("\n==== Write Jena graph directly\n");
+            RDFDataMgr.write(System.out, jGraph, Lang.TTL);
         }
     }
 }
-

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFParserBuilder.java
----------------------------------------------------------------------
diff --git a/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFParserBuilder.java b/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFParserBuilder.java
index 7760e1f..da60602 100644
--- a/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFParserBuilder.java
+++ b/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFParserBuilder.java
@@ -36,28 +36,28 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class TestRDFParserBuilder {
-	
-	private Path turtleFile;
-
-	@Before
-	public void preparePath() throws IOException {
-		turtleFile = Files.createTempFile("commonsrdf", "test.ttl");
-		Files.copy(getClass().getResourceAsStream("/D.ttl"), turtleFile, StandardCopyOption.REPLACE_EXISTING);
-	}
-
-	@After
-	public void deletePath() throws IOException {
-		if (turtleFile != null) {
-			Files.deleteIfExists(turtleFile);
-		}
-	}
-
-	@Test
-	public void parseTurtle() throws Exception {
-		Graph g = new JenaRDF().createGraph();
-		Future<ParseResult> gFuture = new JenaRDFParser().contentType(RDFSyntax.TURTLE).source(turtleFile)
-				.target(g).parse();
-		gFuture.get(5, TimeUnit.SECONDS);
-		assertEquals(3, g.size());
-	}
+
+    private Path turtleFile;
+
+    @Before
+    public void preparePath() throws IOException {
+        turtleFile = Files.createTempFile("commonsrdf", "test.ttl");
+        Files.copy(getClass().getResourceAsStream("/D.ttl"), turtleFile, StandardCopyOption.REPLACE_EXISTING);
+    }
+
+    @After
+    public void deletePath() throws IOException {
+        if (turtleFile != null) {
+            Files.deleteIfExists(turtleFile);
+        }
+    }
+
+    @Test
+    public void parseTurtle() throws Exception {
+        Graph g = new JenaRDF().createGraph();
+        Future<ParseResult> gFuture = new JenaRDFParser().contentType(RDFSyntax.TURTLE).source(turtleFile).target(g)
+                .parse();
+        gFuture.get(5, TimeUnit.SECONDS);
+        assertEquals(3, g.size());
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdBlankNode.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdBlankNode.java b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdBlankNode.java
index 0a7d59c..d3ac1f0 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdBlankNode.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdBlankNode.java
@@ -22,42 +22,41 @@ import org.apache.commons.rdf.api.BlankNode;
 import com.github.jsonldjava.core.RDFDataset.Node;
 
 public interface JsonLdBlankNode extends JsonLdTerm, BlankNode {
-}	
-	
-	final class JsonLdBlankNodeImpl extends JsonLdTermImpl implements JsonLdBlankNode {
-		private String blankNodePrefix;
-	
-		JsonLdBlankNodeImpl(Node node, String blankNodePrefix) {
-			super(node);
-			this.blankNodePrefix = blankNodePrefix;
-			if (! node.isBlankNode()) {
-				throw new IllegalArgumentException("Node is not a BlankNode:" + node);
-			}
-		}
-	
-		@Override
-		public String ntriplesString() {
-			// TODO: Escape if this is not valid ntriples string (e.g. contains :)
-			return node.getValue();
-		}
-	
-		@Override
-		public String uniqueReference() {					
-			return blankNodePrefix + node.getValue();
-		}
-	
-		@Override
-		public boolean equals(Object obj) {
-			if (! ( obj instanceof BlankNode)) {
-				return false;
-			}
-			BlankNode other = (BlankNode) obj;
-			return uniqueReference().equals(other.uniqueReference());
-		}
-	
-		@Override
-		public int hashCode() {
-			return uniqueReference().hashCode();
-		}
-	}
+}
 
+final class JsonLdBlankNodeImpl extends JsonLdTermImpl implements JsonLdBlankNode {
+    private String blankNodePrefix;
+
+    JsonLdBlankNodeImpl(Node node, String blankNodePrefix) {
+        super(node);
+        this.blankNodePrefix = blankNodePrefix;
+        if (!node.isBlankNode()) {
+            throw new IllegalArgumentException("Node is not a BlankNode:" + node);
+        }
+    }
+
+    @Override
+    public String ntriplesString() {
+        // TODO: Escape if this is not valid ntriples string (e.g. contains :)
+        return node.getValue();
+    }
+
+    @Override
+    public String uniqueReference() {
+        return blankNodePrefix + node.getValue();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof BlankNode)) {
+            return false;
+        }
+        BlankNode other = (BlankNode) obj;
+        return uniqueReference().equals(other.uniqueReference());
+    }
+
+    @Override
+    public int hashCode() {
+        return uniqueReference().hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/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 8774cdc..72aadc2 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
@@ -37,79 +37,74 @@ public interface JsonLdDataset extends JsonLdGraphLike<org.apache.commons.rdf.ap
 
 class JsonLdDatasetImpl extends AbstractJsonLdGraphLike<org.apache.commons.rdf.api.Quad> implements JsonLdDataset {
 
-	JsonLdDatasetImpl(RDFDataset rdfDataSet) {
-		super(rdfDataSet);
-	}
-
-	JsonLdDatasetImpl(RDFDataset rdfDataset, String bnodePrefix) {
-		super(rdfDataset, bnodePrefix);
-	}
-
-	JsonLdDatasetImpl(String bnodePrefix) {
-		super(bnodePrefix);
-	}
-
-	@Override
-	public void add(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		super.add(graphName, subject, predicate, object);
-	}
-
-	@Override
-	public boolean contains(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		return super.contains(graphName, subject, predicate, object);
-	}
-	
-	@Override
-	public Graph getGraph() {
-		return new JsonLdGraphImpl(rdfDataSet, Optional.empty(), bnodePrefix);
-	}	
-
-	@Override
-	public Optional<Graph> getGraph(BlankNodeOrIRI graphName) {
-		if (graphName == null) {
-			return Optional.of(getGraph());
-		}
-		return getGraphNames()
-				.map(g -> (Graph)new JsonLdGraphImpl(rdfDataSet, Optional.of(g), bnodePrefix))
-				.findAny();
-	}
-
-	@Override
-	public Stream<BlankNodeOrIRI> getGraphNames() {
-		return rdfDataSet.graphNames().parallelStream().filter(Predicate.isEqual("@default").negate())
-				.map(s -> s.startsWith("_:") ? new RDFDataset.BlankNode(s) : new RDFDataset.IRI(s))
-				.map(n -> (BlankNodeOrIRI) factory.asRDFTerm(n));
-	}
-
-	@Override
-	public void remove(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		super.remove(graphName, subject, predicate, object);
-	}
-
-
-	@Override
-	public void remove(Quad q) {
-		remove(q.getGraphName(), q.getSubject(), q.getPredicate(), q.getObject());
-	}
-	
-	@Override
-	public Stream<? extends Quad> stream(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate,
-			RDFTerm object) {		
-		return filteredGraphs(graphName)
-				.flatMap(List::stream)
-				.filter(quadFilter(subject, predicate, object))
-				.map(factory::asQuad);
-	}
-
-	@Override
-	public long size() {		
-		return rdfDataSet.graphNames().parallelStream().map(rdfDataSet::getQuads).collect(Collectors.summingLong(List::size));
-	}
-
-	@Override
-	Quad asTripleOrQuad(com.github.jsonldjava.core.RDFDataset.Quad jsonldQuad) {
-		return factory.asQuad(jsonldQuad);
-	}
-
+    JsonLdDatasetImpl(RDFDataset rdfDataSet) {
+        super(rdfDataSet);
+    }
+
+    JsonLdDatasetImpl(RDFDataset rdfDataset, String bnodePrefix) {
+        super(rdfDataset, bnodePrefix);
+    }
+
+    JsonLdDatasetImpl(String bnodePrefix) {
+        super(bnodePrefix);
+    }
+
+    @Override
+    public void add(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        super.add(graphName, subject, predicate, object);
+    }
+
+    @Override
+    public boolean contains(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        return super.contains(graphName, subject, predicate, object);
+    }
+
+    @Override
+    public Graph getGraph() {
+        return new JsonLdGraphImpl(rdfDataSet, Optional.empty(), bnodePrefix);
+    }
+
+    @Override
+    public Optional<Graph> getGraph(BlankNodeOrIRI graphName) {
+        if (graphName == null) {
+            return Optional.of(getGraph());
+        }
+        return getGraphNames().map(g -> (Graph) new JsonLdGraphImpl(rdfDataSet, Optional.of(g), bnodePrefix)).findAny();
+    }
+
+    @Override
+    public Stream<BlankNodeOrIRI> getGraphNames() {
+        return rdfDataSet.graphNames().parallelStream().filter(Predicate.isEqual("@default").negate())
+                .map(s -> s.startsWith("_:") ? new RDFDataset.BlankNode(s) : new RDFDataset.IRI(s))
+                .map(n -> (BlankNodeOrIRI) factory.asRDFTerm(n));
+    }
+
+    @Override
+    public void remove(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        super.remove(graphName, subject, predicate, object);
+    }
+
+    @Override
+    public void remove(Quad q) {
+        remove(q.getGraphName(), q.getSubject(), q.getPredicate(), q.getObject());
+    }
+
+    @Override
+    public Stream<? extends Quad> stream(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate,
+            RDFTerm object) {
+        return filteredGraphs(graphName).flatMap(List::stream).filter(quadFilter(subject, predicate, object))
+                .map(factory::asQuad);
+    }
+
+    @Override
+    public long size() {
+        return rdfDataSet.graphNames().parallelStream().map(rdfDataSet::getQuads)
+                .collect(Collectors.summingLong(List::size));
+    }
+
+    @Override
+    Quad asTripleOrQuad(com.github.jsonldjava.core.RDFDataset.Quad jsonldQuad) {
+        return factory.asQuad(jsonldQuad);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/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 1acba7d..42061a1 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
@@ -37,82 +37,76 @@ import com.github.jsonldjava.core.RDFDataset;
 public interface JsonLdGraph extends JsonLdGraphLike<Triple>, Graph {
 }
 
-class JsonLdGraphImpl extends AbstractJsonLdGraphLike<Triple> 
-	implements JsonLdGraph {
-
-	private final Optional<BlankNodeOrIRI> graphName;
-
-	JsonLdGraphImpl(RDFDataset rdfDataSet) {
-		super(rdfDataSet);
-		this.graphName = Optional.empty();
-	}
-	
-	JsonLdGraphImpl(RDFDataset rdfDataSet, Optional<BlankNodeOrIRI> graphName, String bnodePrefix) {
-		super(rdfDataSet, bnodePrefix);
-		this.graphName = Objects.requireNonNull(graphName);
-	}
-	
-	JsonLdGraphImpl(String bnodePrefix) {
-		super(bnodePrefix);
-		this.graphName = Optional.empty();
-	}
-
-	@Override
-	public void clear() {
-		filteredGraphs(graphName).forEach(l -> l.clear());
-	}
-
-	@Override
-	public void add(Triple t) {
-		// Ensure it's added in the correct graph
-		super.add(graphName.orElse(null), t.getSubject(), t.getPredicate(), t.getObject());
-	}
-	
-	@Override
-	public void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		super.add(graphName.orElse(null), subject, predicate, object);
-	}
-
-	@Override
-	public boolean contains(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		return super.contains(graphName, subject, predicate, object);
-	}
-	
-	@Override
-	public boolean contains(Triple t) {
-		return contains(graphName, t.getSubject(), t.getPredicate(), t.getObject());
-	}
-	
-	@Override
-	public void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		super.remove(graphName, subject, predicate, object);
-	}
-	
-	@Override
-	public void remove(Triple t) {
-		// Only remove from the particular graph
-		remove(graphName, t.getSubject(), t.getPredicate(), t.getObject());		
-	}
-
-	@Override
-	public long size() {
-		String g = graphName.map(factory::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)
-				.flatMap(List::stream)
-				.filter(quadFilter(subject, predicate, object))
-				.map(factory::asTriple);
-	}
-	
-	@Override
-	JsonLdTriple asTripleOrQuad(com.github.jsonldjava.core.RDFDataset.Quad jsonldQuad) {
-		return factory.asTriple(jsonldQuad);
-	}
-}
+class JsonLdGraphImpl extends AbstractJsonLdGraphLike<Triple> implements JsonLdGraph {
+
+    private final Optional<BlankNodeOrIRI> graphName;
+
+    JsonLdGraphImpl(RDFDataset rdfDataSet) {
+        super(rdfDataSet);
+        this.graphName = Optional.empty();
+    }
+
+    JsonLdGraphImpl(RDFDataset rdfDataSet, Optional<BlankNodeOrIRI> graphName, String bnodePrefix) {
+        super(rdfDataSet, bnodePrefix);
+        this.graphName = Objects.requireNonNull(graphName);
+    }
+
+    JsonLdGraphImpl(String bnodePrefix) {
+        super(bnodePrefix);
+        this.graphName = Optional.empty();
+    }
+
+    @Override
+    public void clear() {
+        filteredGraphs(graphName).forEach(l -> l.clear());
+    }
+
+    @Override
+    public void add(Triple t) {
+        // Ensure it's added in the correct graph
+        super.add(graphName.orElse(null), t.getSubject(), t.getPredicate(), t.getObject());
+    }
+
+    @Override
+    public void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        super.add(graphName.orElse(null), subject, predicate, object);
+    }
 
+    @Override
+    public boolean contains(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        return super.contains(graphName, subject, predicate, object);
+    }
+
+    @Override
+    public boolean contains(Triple t) {
+        return contains(graphName, t.getSubject(), t.getPredicate(), t.getObject());
+    }
+
+    @Override
+    public void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        super.remove(graphName, subject, predicate, object);
+    }
+
+    @Override
+    public void remove(Triple t) {
+        // Only remove from the particular graph
+        remove(graphName, t.getSubject(), t.getPredicate(), t.getObject());
+    }
+
+    @Override
+    public long size() {
+        String g = graphName.map(factory::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).flatMap(List::stream).filter(quadFilter(subject, predicate, object))
+                .map(factory::asTriple);
+    }
+
+    @Override
+    JsonLdTriple asTripleOrQuad(com.github.jsonldjava.core.RDFDataset.Quad jsonldQuad) {
+        return factory.asTriple(jsonldQuad);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/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 d4417ec..7b5b3f5 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
@@ -46,177 +46,176 @@ import com.github.jsonldjava.core.RDFDataset.Node;
  *            specialisation of {@link TripleLike}, e.g. {@link Triple} or
  *            {@link org.apache.commons.rdf.api.Quad}
  */
-public interface JsonLdGraphLike <T extends TripleLike>
-	extends GraphLike<T> {
-	/**
-	 * Return the underlying JSONLD-Java {@link RDFDataset}.
-	 * <p>
-	 * Changes in the JSONLD-Java dataset is reflected in this class and vice
-	 * versa.
-	 * 
-	 * @return The underlying JSONLD-JAva RDFDataset
-	 */
-	public RDFDataset getRdfDataSet();
+public interface JsonLdGraphLike<T extends TripleLike> extends GraphLike<T> {
+    /**
+     * Return the underlying JSONLD-Java {@link RDFDataset}.
+     * <p>
+     * Changes in the JSONLD-Java dataset is reflected in this class and vice
+     * versa.
+     * 
+     * @return The underlying JSONLD-JAva RDFDataset
+     */
+    public RDFDataset getRdfDataSet();
 }
 
-abstract class AbstractJsonLdGraphLike<T extends TripleLike>
-	implements JsonLdGraphLike<T> {
-	
-	/** 
-	 * Used by {@link #bnodePrefix()} to get a unique UUID per JVM run
-	 */
-	private static UUID SALT = UUID.randomUUID();
-	
-	/**
-	 * Prefix to use in blank node identifiers
-	 */
-	final String bnodePrefix;
-
-	final JsonLdRDF 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;
-	
-	AbstractJsonLdGraphLike(RDFDataset rdfDataSet) {
-		this(rdfDataSet, "urn:uuid:" + SALT + "#" +  "g"+ System.identityHashCode(rdfDataSet));
-	}
-
-	AbstractJsonLdGraphLike(RDFDataset rdfDataSet, String bnodePrefix) {
-		this.rdfDataSet = Objects.requireNonNull(rdfDataSet);
-		this.bnodePrefix = Objects.requireNonNull(bnodePrefix);
-		this.factory = new JsonLdRDF(bnodePrefix);
-	}
-	
-	AbstractJsonLdGraphLike(String bnodePrefix) {
-		this(new RDFDataset(), bnodePrefix);
-	}
-	
-	@Override
-	public void add(T t) {
-		// add triples to default graph by default
-		BlankNodeOrIRI graphName = null;
-		if (t instanceof org.apache.commons.rdf.api.Quad) {
-			org.apache.commons.rdf.api.Quad q = (org.apache.commons.rdf.api.Quad)t;
-			graphName = q.getGraphName().orElse(null);
-		}
-		// FIXME: JSON-LD's rdfDataSet.addQuad method does not support 
-		// generalized RDF, so we have to do a naive cast here
-		add(graphName, (BlankNodeOrIRI)t.getSubject(), (IRI)t.getPredicate(), t.getObject());
-	}	
-
-	void add(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		String g = factory.asJsonLdString(graphName);
-		String s = factory.asJsonLdString(subject);
-		String p = factory.asJsonLdString(predicate);		
-		if (object instanceof BlankNodeOrIRI) {
-			String o = factory.asJsonLdString((BlankNodeOrIRI)object);
-			rdfDataSet.addQuad(s,p,o,g);
-		} else if(object instanceof Literal) { 
-			Literal literal = (Literal) object;
-			String language = literal.getLanguageTag().orElse(null);
-			String datatype = literal.getDatatype().getIRIString();
-			rdfDataSet.addQuad(s,p,literal.getLexicalForm(), datatype, language, g);
-		}		
-	}
-		
-	public void close() {
-		// Drop the memory reference, but don't clear it
-		rdfDataSet = null;			
-	}	
-
-	@Override
-	public void clear() {		
-		filteredGraphs(null).forEach(s -> s.clear());
-		//   In theory we could use
-		//rdfDataSet.clear();
-		//   but then we would need to also do
-		//rdfDataSet.put("@default",  new ArrayList());
-		//   .. both of which seems to be touching too much on JsonLd-Java's internal structure
-	}
-
-	@Override
-	public boolean contains(T tripleOrQuad) {		
-		return stream().anyMatch(Predicate.isEqual(tripleOrQuad));
-	}
-
-	public RDFDataset getRdfDataSet() {
-		return rdfDataSet;
-	}
-
-	
-	@Override
-	public Stream<? extends T> stream() {
-		return rdfDataSet.graphNames().parallelStream()
-				.map(rdfDataSet::getQuads)
-				.flatMap(List<RDFDataset.Quad>::parallelStream)
-				.map(this::asTripleOrQuad);
-	}
-	
-	/**
-	 * Convert JsonLd Quad to a Commons RDF {@link Triple} or {@link org.apache.commons.rdf.api.Quad}
-	 * 
-	 * 
-	 * @see JsonLdRDF#asTriple(Quad)
-	 * @see JsonLdRDF#asQuad(Quad)
-	 * @param jsonldQuad jsonld quad to convert
-	 * @return converted {@link TripleLike}
-	 */
-	abstract T asTripleOrQuad(RDFDataset.Quad jsonldQuad);
-
-	// 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));
-	}
-
-	Stream<List<RDFDataset.Quad>> filteredGraphs(Optional<BlankNodeOrIRI> graphName) {
-		return rdfDataSet.graphNames().parallelStream()
-				// if graphName == null (wildcard), select all graphs, 
-	 			// otherwise check its jsonld string
-			    // (including @default for default graph)
-				.filter(g -> graphName == null ||
-						g.equals(graphName.map(factory::asJsonLdString).orElse("@default")))
-				// 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(factory::asJsonLdString).orElse("@default");			
-		}		
-		return "@default";
-	}
-	
-	
-	Predicate<RDFDataset.Quad> quadFilter(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		Optional<Node> subjectNode = Optional.ofNullable(subject).map(factory::asJsonLdNode);
-		Optional<Node> predicateNode = Optional.ofNullable(predicate).map(factory::asJsonLdNode);
-		Optional<Node> objectNode = Optional.ofNullable(object).map(factory::asJsonLdNode);
-		
-		return q -> {
-		    if (subjectNode.isPresent() && subjectNode.get().compareTo(q.getSubject()) != 0) {
-		        return false;
-		    }
-		    if (predicateNode.isPresent() && predicateNode.get().compareTo(q.getPredicate()) != 0) {	          
-		        return false;
-		    }
-		    if (objectNode.isPresent() && objectNode.get().compareTo(q.getObject()) != 0) {
-		        return false;
-		    }
-		    return true;			
-		};
-	}
-	
-	// 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)));
-	}
-	
+abstract class AbstractJsonLdGraphLike<T extends TripleLike> implements JsonLdGraphLike<T> {
+
+    /**
+     * Used by {@link #bnodePrefix()} to get a unique UUID per JVM run
+     */
+    private static UUID SALT = UUID.randomUUID();
+
+    /**
+     * Prefix to use in blank node identifiers
+     */
+    final String bnodePrefix;
+
+    final JsonLdRDF 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;
+
+    AbstractJsonLdGraphLike(RDFDataset rdfDataSet) {
+        this(rdfDataSet, "urn:uuid:" + SALT + "#" + "g" + System.identityHashCode(rdfDataSet));
+    }
+
+    AbstractJsonLdGraphLike(RDFDataset rdfDataSet, String bnodePrefix) {
+        this.rdfDataSet = Objects.requireNonNull(rdfDataSet);
+        this.bnodePrefix = Objects.requireNonNull(bnodePrefix);
+        this.factory = new JsonLdRDF(bnodePrefix);
+    }
+
+    AbstractJsonLdGraphLike(String bnodePrefix) {
+        this(new RDFDataset(), bnodePrefix);
+    }
+
+    @Override
+    public void add(T t) {
+        // add triples to default graph by default
+        BlankNodeOrIRI graphName = null;
+        if (t instanceof org.apache.commons.rdf.api.Quad) {
+            org.apache.commons.rdf.api.Quad q = (org.apache.commons.rdf.api.Quad) t;
+            graphName = q.getGraphName().orElse(null);
+        }
+        // FIXME: JSON-LD's rdfDataSet.addQuad method does not support
+        // generalized RDF, so we have to do a naive cast here
+        add(graphName, (BlankNodeOrIRI) t.getSubject(), (IRI) t.getPredicate(), t.getObject());
+    }
+
+    void add(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        String g = factory.asJsonLdString(graphName);
+        String s = factory.asJsonLdString(subject);
+        String p = factory.asJsonLdString(predicate);
+        if (object instanceof BlankNodeOrIRI) {
+            String o = factory.asJsonLdString((BlankNodeOrIRI) object);
+            rdfDataSet.addQuad(s, p, o, g);
+        } else if (object instanceof Literal) {
+            Literal literal = (Literal) object;
+            String language = literal.getLanguageTag().orElse(null);
+            String datatype = literal.getDatatype().getIRIString();
+            rdfDataSet.addQuad(s, p, literal.getLexicalForm(), datatype, language, g);
+        }
+    }
+
+    public void close() {
+        // Drop the memory reference, but don't clear it
+        rdfDataSet = null;
+    }
+
+    @Override
+    public void clear() {
+        filteredGraphs(null).forEach(s -> s.clear());
+        // In theory we could use
+        // rdfDataSet.clear();
+        // but then we would need to also do
+        // rdfDataSet.put("@default", new ArrayList());
+        // .. both of which seems to be touching too much on JsonLd-Java's
+        // internal structure
+    }
+
+    @Override
+    public boolean contains(T tripleOrQuad) {
+        return stream().anyMatch(Predicate.isEqual(tripleOrQuad));
+    }
+
+    public RDFDataset getRdfDataSet() {
+        return rdfDataSet;
+    }
+
+    @Override
+    public Stream<? extends T> stream() {
+        return rdfDataSet.graphNames().parallelStream().map(rdfDataSet::getQuads)
+                .flatMap(List<RDFDataset.Quad>::parallelStream).map(this::asTripleOrQuad);
+    }
+
+    /**
+     * Convert JsonLd Quad to a Commons RDF {@link Triple} or
+     * {@link org.apache.commons.rdf.api.Quad}
+     * 
+     * 
+     * @see JsonLdRDF#asTriple(Quad)
+     * @see JsonLdRDF#asQuad(Quad)
+     * @param jsonldQuad
+     *            jsonld quad to convert
+     * @return converted {@link TripleLike}
+     */
+    abstract T asTripleOrQuad(RDFDataset.Quad jsonldQuad);
+
+    // 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));
+    }
+
+    Stream<List<RDFDataset.Quad>> filteredGraphs(Optional<BlankNodeOrIRI> graphName) {
+        return rdfDataSet.graphNames().parallelStream()
+                // if graphName == null (wildcard), select all graphs,
+                // otherwise check its jsonld string
+                // (including @default for default graph)
+                .filter(g -> graphName == null || g.equals(graphName.map(factory::asJsonLdString).orElse("@default")))
+                // 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(factory::asJsonLdString).orElse("@default");
+        }
+        return "@default";
+    }
+
+    Predicate<RDFDataset.Quad> quadFilter(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        Optional<Node> subjectNode = Optional.ofNullable(subject).map(factory::asJsonLdNode);
+        Optional<Node> predicateNode = Optional.ofNullable(predicate).map(factory::asJsonLdNode);
+        Optional<Node> objectNode = Optional.ofNullable(object).map(factory::asJsonLdNode);
+
+        return q -> {
+            if (subjectNode.isPresent() && subjectNode.get().compareTo(q.getSubject()) != 0) {
+                return false;
+            }
+            if (predicateNode.isPresent() && predicateNode.get().compareTo(q.getPredicate()) != 0) {
+                return false;
+            }
+            if (objectNode.isPresent() && objectNode.get().compareTo(q.getObject()) != 0) {
+                return false;
+            }
+            return true;
+        };
+    }
+
+    // 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/413dd09a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdIRI.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdIRI.java b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdIRI.java
index dc94401..f7c1707 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdIRI.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdIRI.java
@@ -25,40 +25,40 @@ import com.github.jsonldjava.core.RDFDataset.Node;
 public interface JsonLdIRI extends JsonLdTerm, IRI {
 }
 
-	final class JsonLdIRIImpl extends JsonLdTermImpl implements JsonLdIRI {
-	
-		JsonLdIRIImpl(Node node) {
-			super(node);
-			if (! node.isIRI()) {
-				throw new IllegalArgumentException("Node is not an IRI:" + node);
-			}
-		}
-	
-		JsonLdIRIImpl(String iri) {
-			super(new RDFDataset.IRI(iri));
-		}
-	
-		@Override
-		public String ntriplesString() {
-			return "<" + node.getValue() + ">";
-		}
-	
-		@Override
-		public String getIRIString() {
-			return node.getValue();
-		}
-	
-		@Override
-		public int hashCode() {
-			return node.getValue().hashCode();
-		}
-	
-		@Override
-		public boolean equals(Object obj) {
-			if (! (obj instanceof IRI)) {
-				return false;
-			} 
-			IRI other = (IRI) obj;
-			return node.getValue().equals(other.getIRIString());
-		}
-	}
+final class JsonLdIRIImpl extends JsonLdTermImpl implements JsonLdIRI {
+
+    JsonLdIRIImpl(Node node) {
+        super(node);
+        if (!node.isIRI()) {
+            throw new IllegalArgumentException("Node is not an IRI:" + node);
+        }
+    }
+
+    JsonLdIRIImpl(String iri) {
+        super(new RDFDataset.IRI(iri));
+    }
+
+    @Override
+    public String ntriplesString() {
+        return "<" + node.getValue() + ">";
+    }
+
+    @Override
+    public String getIRIString() {
+        return node.getValue();
+    }
+
+    @Override
+    public int hashCode() {
+        return node.getValue().hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof IRI)) {
+            return false;
+        }
+        IRI other = (IRI) obj;
+        return node.getValue().equals(other.getIRIString());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdLiteral.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdLiteral.java b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdLiteral.java
index 01dff6f..afb7da2 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdLiteral.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdLiteral.java
@@ -27,73 +27,72 @@ import org.apache.commons.rdf.simple.Types;
 import com.github.jsonldjava.core.RDFDataset.Node;
 
 public interface JsonLdLiteral extends JsonLdTerm, Literal {
-}	
-	
-	class JsonLdLiteralImpl extends JsonLdTermImpl implements JsonLdLiteral {
-	
-		JsonLdLiteralImpl(Node node) {
-			super(node);
-			if (! node.isLiteral()) {
-				throw new IllegalArgumentException("Node is not a Literal:" + node);
-			}
-		}
-	
-		@Override
-		public String ntriplesString() {
-	        StringBuilder sb = new StringBuilder();
-	        sb.append('"');
-	        // Escape special characters
-	        sb.append(getLexicalForm().replace("\\", "\\\\"). // escaped to \\
-	                replace("\"", "\\\""). // escaped to \"
-	                replace("\r", "\\r"). // escaped to \r
-	                replace("\n", "\\n")); // escaped to \n
-	        sb.append('"');
-	
-	        if (getLanguageTag().isPresent()) {
-	            sb.append("@");
-	            sb.append(getLanguageTag().get());
-	        } else if (!getDatatype().equals(Types.XSD_STRING)) {
-	            sb.append("^^");
-	            sb.append(getDatatype().ntriplesString());
-	        }
-	        return sb.toString();
-	    }
-	
-		@Override
-		public String getLexicalForm() {
-			return node.getValue();
-		}
-	
-		@Override
-		public IRI getDatatype() {
-			return new JsonLdIRIImpl(node.getDatatype());
-		}
-	
-		@Override
-		public Optional<String> getLanguageTag() {
-			return Optional.ofNullable(node.getLanguage());
-		}
-	
-		@Override
-		public int hashCode() {
-			// Should be the same as 
-			// Objects.hash(getLexicalForm(), getDatatype(), getLanguageTag());
-			return Objects.hash(node.getValue(), node.getDatatype(), node.getLanguage());
-		}
-		
-		@Override
-		public boolean equals(Object obj) {
-			if (obj instanceof JsonLdLiteral) {
-				JsonLdLiteral other = (JsonLdLiteral) obj;
-				return asJsonLdNode().compareTo(other.asJsonLdNode()) == 0;
-			}
-			if (obj instanceof Literal) {
-				Literal other = (Literal) obj;
-				return getLexicalForm().equals(other.getLexicalForm()) &&
-						getDatatype().equals(other.getDatatype()) &&
-						getLanguageTag().equals(other.getLanguageTag());
-			}
-			return false;
-			
-		}	
-	}
+}
+
+class JsonLdLiteralImpl extends JsonLdTermImpl implements JsonLdLiteral {
+
+    JsonLdLiteralImpl(Node node) {
+        super(node);
+        if (!node.isLiteral()) {
+            throw new IllegalArgumentException("Node is not a Literal:" + node);
+        }
+    }
+
+    @Override
+    public String ntriplesString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append('"');
+        // Escape special characters
+        sb.append(getLexicalForm().replace("\\", "\\\\"). // escaped to \\
+                replace("\"", "\\\""). // escaped to \"
+                replace("\r", "\\r"). // escaped to \r
+                replace("\n", "\\n")); // escaped to \n
+        sb.append('"');
+
+        if (getLanguageTag().isPresent()) {
+            sb.append("@");
+            sb.append(getLanguageTag().get());
+        } else if (!getDatatype().equals(Types.XSD_STRING)) {
+            sb.append("^^");
+            sb.append(getDatatype().ntriplesString());
+        }
+        return sb.toString();
+    }
+
+    @Override
+    public String getLexicalForm() {
+        return node.getValue();
+    }
+
+    @Override
+    public IRI getDatatype() {
+        return new JsonLdIRIImpl(node.getDatatype());
+    }
+
+    @Override
+    public Optional<String> getLanguageTag() {
+        return Optional.ofNullable(node.getLanguage());
+    }
+
+    @Override
+    public int hashCode() {
+        // Should be the same as
+        // Objects.hash(getLexicalForm(), getDatatype(), getLanguageTag());
+        return Objects.hash(node.getValue(), node.getDatatype(), node.getLanguage());
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj instanceof JsonLdLiteral) {
+            JsonLdLiteral other = (JsonLdLiteral) obj;
+            return asJsonLdNode().compareTo(other.asJsonLdNode()) == 0;
+        }
+        if (obj instanceof Literal) {
+            Literal other = (Literal) obj;
+            return getLexicalForm().equals(other.getLexicalForm()) && getDatatype().equals(other.getDatatype())
+                    && getLanguageTag().equals(other.getLanguageTag());
+        }
+        return false;
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuad.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuad.java b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuad.java
index fcf71f1..9b39514 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuad.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuad.java
@@ -28,31 +28,28 @@ public interface JsonLdQuad extends org.apache.commons.rdf.api.Quad, JsonLdTripl
 
 }
 
-	final class JsonLdQuadImpl extends JsonLdQuadLikeImpl<BlankNodeOrIRI,IRI,RDFTerm,BlankNodeOrIRI> 
-		implements JsonLdQuad {
-		
-		JsonLdQuadImpl(com.github.jsonldjava.core.RDFDataset.Quad quad, String blankNodePrefix) {
-			super(quad, blankNodePrefix);			
-		}
-	
-		@Override
-		public boolean equals(Object obj) {
-			if (obj == this) {
-				return true;
-			}
-			if (! (obj instanceof org.apache.commons.rdf.api.Quad)) {
-				return false;
-			}
-			org.apache.commons.rdf.api.Quad other = (org.apache.commons.rdf.api.Quad) obj;
-			return getGraphName().equals(other.getGraphName()) &&
-					getSubject().equals(other.getSubject()) && 
-					getPredicate().equals(other.getPredicate()) && 
-					getObject().equals(other.getObject());
-		}
-	
-		@Override
-		public int hashCode() {
-			return Objects.hash(getGraphName(), getSubject(), getPredicate(), getObject());
-		}	
-	}	
-		
+final class JsonLdQuadImpl extends JsonLdQuadLikeImpl<BlankNodeOrIRI, IRI, RDFTerm, BlankNodeOrIRI>
+        implements JsonLdQuad {
+
+    JsonLdQuadImpl(com.github.jsonldjava.core.RDFDataset.Quad quad, String blankNodePrefix) {
+        super(quad, blankNodePrefix);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        }
+        if (!(obj instanceof org.apache.commons.rdf.api.Quad)) {
+            return false;
+        }
+        org.apache.commons.rdf.api.Quad other = (org.apache.commons.rdf.api.Quad) obj;
+        return getGraphName().equals(other.getGraphName()) && getSubject().equals(other.getSubject())
+                && getPredicate().equals(other.getPredicate()) && getObject().equals(other.getObject());
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(getGraphName(), getSubject(), getPredicate(), getObject());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuadLike.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuadLike.java b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuadLike.java
index 1584f9e..9f92cda 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuadLike.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuadLike.java
@@ -25,50 +25,50 @@ import org.apache.commons.rdf.api.RDFTerm;
 import com.github.jsonldjava.core.RDFDataset.Quad;
 
 public interface JsonLdQuadLike<G extends RDFTerm> extends QuadLike<G>, JsonLdTripleLike {
-	
+
 }
-	
-	class JsonLdQuadLikeImpl<S extends RDFTerm, P extends RDFTerm, O extends RDFTerm, G extends RDFTerm> implements JsonLdQuadLike<G> {
-		
-		// Note: We always pass the blankNodePrefix and don't rely on the internal
-		// blankNodePrefix in this static factory
-		private static JsonLdRDF rdfTermFactory = new JsonLdRDF();
-		
-		private final Quad quad;
-		private String blankNodePrefix;
-		
-		JsonLdQuadLikeImpl(Quad jsonldQuad, String blankNodePrefix) {
-			this.quad = jsonldQuad;
-			this.blankNodePrefix = blankNodePrefix;			
-		}
-	
-		@SuppressWarnings("unchecked")	
-		@Override
-		public Optional<G> getGraphName() {
-			G g = (G) rdfTermFactory.asRDFTerm(quad.getGraph(), blankNodePrefix);
-			return Optional.ofNullable(g);
-		}
-		
-		@SuppressWarnings("unchecked")
-		@Override
-		public S getSubject() {
-			return (S) rdfTermFactory.asRDFTerm(quad.getSubject(), blankNodePrefix);
-		}
-	
-		@SuppressWarnings("unchecked")
-		@Override
-		public P getPredicate() {
-			return (P) rdfTermFactory.asRDFTerm(quad.getPredicate(), blankNodePrefix);
-		}
-	
-		@SuppressWarnings("unchecked")
-		@Override
-		public O getObject() {
-			return (O) rdfTermFactory.asRDFTerm(quad.getObject(), blankNodePrefix);
-		}
-	
-		public Quad asJsonLdQuad() {
-			return quad;
-		}
-	}
 
+class JsonLdQuadLikeImpl<S extends RDFTerm, P extends RDFTerm, O extends RDFTerm, G extends RDFTerm>
+        implements JsonLdQuadLike<G> {
+
+    // Note: We always pass the blankNodePrefix and don't rely on the internal
+    // blankNodePrefix in this static factory
+    private static JsonLdRDF rdfTermFactory = new JsonLdRDF();
+
+    private final Quad quad;
+    private String blankNodePrefix;
+
+    JsonLdQuadLikeImpl(Quad jsonldQuad, String blankNodePrefix) {
+        this.quad = jsonldQuad;
+        this.blankNodePrefix = blankNodePrefix;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Optional<G> getGraphName() {
+        G g = (G) rdfTermFactory.asRDFTerm(quad.getGraph(), blankNodePrefix);
+        return Optional.ofNullable(g);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public S getSubject() {
+        return (S) rdfTermFactory.asRDFTerm(quad.getSubject(), blankNodePrefix);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public P getPredicate() {
+        return (P) rdfTermFactory.asRDFTerm(quad.getPredicate(), blankNodePrefix);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public O getObject() {
+        return (O) rdfTermFactory.asRDFTerm(quad.getObject(), blankNodePrefix);
+    }
+
+    public Quad asJsonLdQuad() {
+        return quad;
+    }
+}


Mime
View raw message