You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2015/07/14 15:44:28 UTC
[3/8] jena git commit: JENA-986: Replace AnonId with BlankNodeId for
graph-level usage.
JENA-986: Replace AnonId with BlankNodeId for graph-level usage.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/20ab2e2e
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/20ab2e2e
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/20ab2e2e
Branch: refs/heads/master
Commit: 20ab2e2e5926a5c9714a0e294a21042f2f200bbe
Parents: da0ccfe
Author: Andy Seaborne <an...@apache.org>
Authored: Mon Jul 13 11:38:18 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Mon Jul 13 11:38:18 2015 +0100
----------------------------------------------------------------------
.../main/java/org/apache/jena/graph/Node.java | 34 ++++++++------
.../java/org/apache/jena/graph/NodeFactory.java | 49 ++++++++++++++++----
.../java/org/apache/jena/graph/NodeVisitor.java | 5 +-
3 files changed, 62 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/20ab2e2e/jena-core/src/main/java/org/apache/jena/graph/Node.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/graph/Node.java b/jena-core/src/main/java/org/apache/jena/graph/Node.java
index 023e78a..f44a308 100644
--- a/jena-core/src/main/java/org/apache/jena/graph/Node.java
+++ b/jena-core/src/main/java/org/apache/jena/graph/Node.java
@@ -20,7 +20,6 @@ package org.apache.jena.graph;
import org.apache.jena.datatypes.RDFDatatype ;
import org.apache.jena.graph.impl.LiteralLabel ;
-import org.apache.jena.rdf.model.AnonId ;
import org.apache.jena.shared.JenaException ;
import org.apache.jena.shared.PrefixMapping ;
@@ -83,7 +82,7 @@ public abstract class Node {
{ return false; }
/** get the blank node id if the node is blank, otherwise die horribly */
- public AnonId getBlankNodeId()
+ public BlankNodeId getBlankNodeId()
{ throw new UnsupportedOperationException( this + " is not a blank node" ); }
/**
@@ -176,24 +175,29 @@ public abstract class Node {
public boolean hasURI( String uri )
{ return false; }
+ // DEPRECATED
/** an abstraction to allow code sharing */
static abstract class NodeMaker { abstract Node construct( Object x ); }
- static final NodeMaker makeAnon = new NodeMaker()
- { @Override
- Node construct( Object x ) { return new Node_Blank( x ); } };
+ @Deprecated
+ static final NodeMaker makeAnon = new NodeMaker() {
+ @Override Node construct( Object x ) { return new Node_Blank( x ); }
+ };
- static final NodeMaker makeLiteral = new NodeMaker()
- { @Override
- Node construct( Object x ) { return new Node_Literal( x ); } };
+ @Deprecated
+ static final NodeMaker makeLiteral = new NodeMaker() {
+ @Override Node construct( Object x ) { return new Node_Literal( x ); }
+ };
- static final NodeMaker makeURI = new NodeMaker()
- { @Override
- Node construct( Object x ) { return new Node_URI( x ); } };
+ @Deprecated
+ static final NodeMaker makeURI = new NodeMaker() {
+ @Override Node construct( Object x ) { return new Node_URI( x ); }
+ };
- static final NodeMaker makeVariable = new NodeMaker()
- { @Override
- Node construct( Object x ) { return new Node_Variable( x ); } };
+ @Deprecated
+ static final NodeMaker makeVariable = new NodeMaker() {
+ @Override Node construct( Object x ) { return new Node_Variable( x ); }
+ };
/**
The canonical NULL. It appears here so that revised definitions [eg as a bnode]
@@ -208,7 +212,9 @@ public abstract class Node {
/**
We object strongly to null labels: for example, they make .equals flaky.
+ @deprecated Use specific {@link NodeFactory} functions.
*/
+ @Deprecated
public static Node create( NodeMaker maker, Object label )
{
if (label == null) throw new JenaException( "Node.make: null label" );
http://git-wip-us.apache.org/repos/asf/jena/blob/20ab2e2e/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java b/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java
index 3f9951a..d127bb9 100644
--- a/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java
+++ b/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java
@@ -23,7 +23,6 @@ import org.apache.jena.datatypes.RDFDatatype ;
import org.apache.jena.datatypes.TypeMapper ;
import org.apache.jena.graph.impl.LiteralLabel ;
import org.apache.jena.graph.impl.LiteralLabelFactory ;
-import org.apache.jena.rdf.model.AnonId ;
public class NodeFactory {
@@ -31,29 +30,61 @@ public class NodeFactory {
return TypeMapper.getInstance().getSafeTypeByName(s) ;
}
- /** make a blank node with a fresh anon id */
- public static Node createAnon() {
- return createAnon(AnonId.create()) ;
+ /** Make a fresh blank node */
+ public static Node createBlankNode() {
+ return createBlankNode(BlankNodeId.create()) ;
+ }
+
+ /** make a blank node with the specified label
+ */
+ public static Node createBlankNode(BlankNodeId id) {
+ return new Node_Blank(id) ;
}
/** make a blank node with the specified label */
- public static Node createAnon(AnonId id) {
- return Node.create(Node.makeAnon, id) ;
+ public static Node createBlankNode(String string) {
+ BlankNodeId id = BlankNodeId.create(string) ;
+ return new Node_Blank(id) ;
+ }
+
+ /** make a blank node with a fresh anon id
+ * @deprecated Use {@link #createBlankNode()}
+ */
+ @Deprecated
+ public static Node createAnon() {
+ return createAnon(BlankNodeId.create()) ;
+ }
+
+ /** make a blank node with the specified label
+ * @deprecated Use {@link #createBlankNode(BlankNodeId)}
+ */
+ @Deprecated
+ public static Node createAnon(BlankNodeId id) {
+ return new Node_Blank(id) ;
+ }
+
+ /** make a blank node with the specified label
+ * @deprecated Use {@link #createBlankNode(String)}
+ */
+ @Deprecated
+ public static Node createAnon(String string) {
+ BlankNodeId id = BlankNodeId.create(string) ;
+ return new Node_Blank(id) ;
}
/** make a literal node with the specified literal value */
public static Node createLiteral(LiteralLabel lit) {
- return Node.create(Node.makeLiteral, lit) ;
+ return new Node_Literal( lit ) ;
}
/** make a URI node with the specified URIref string */
public static Node createURI(String uri) {
- return Node.create(Node.makeURI, uri) ;
+ return new Node_URI(uri) ;
}
/** make a variable node with a given name */
public static Node createVariable(String name) {
- return Node.create(Node.makeVariable, Node_Variable.variable(name)) ;
+ return new Node_Variable(name) ;
}
public static Node createLiteral(String value) {
http://git-wip-us.apache.org/repos/asf/jena/blob/20ab2e2e/jena-core/src/main/java/org/apache/jena/graph/NodeVisitor.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/graph/NodeVisitor.java b/jena-core/src/main/java/org/apache/jena/graph/NodeVisitor.java
index b733c2c..2ad0a51 100644
--- a/jena-core/src/main/java/org/apache/jena/graph/NodeVisitor.java
+++ b/jena-core/src/main/java/org/apache/jena/graph/NodeVisitor.java
@@ -18,8 +18,7 @@
package org.apache.jena.graph;
-import org.apache.jena.graph.impl.* ;
-import org.apache.jena.rdf.model.* ;
+import org.apache.jena.graph.impl.LiteralLabel ;
/**
The NodeVisitor interface is used by Node::visitWith so that an application
@@ -28,7 +27,7 @@ import org.apache.jena.rdf.model.* ;
public interface NodeVisitor
{
Object visitAny( Node_ANY it );
- Object visitBlank( Node_Blank it, AnonId id );
+ Object visitBlank( Node_Blank it, BlankNodeId id );
Object visitLiteral( Node_Literal it, LiteralLabel lit );
Object visitURI( Node_URI it, String uri );
Object visitVariable( Node_Variable it, String name );