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 2014/06/06 11:04:38 UTC
svn commit: r1600830 - in /jena/Experimental/jena3-sketch: ./ src/ src/main/
src/main/java/ src/main/java/jena3/ src/main/java/jena3/graph/
src/main/java/jena3/graph/impl/
Author: andy
Date: Fri Jun 6 09:04:37 2014
New Revision: 1600830
URL: http://svn.apache.org/r1600830
Log:
Ideas for reworked/tidied up Node
Added:
jena/Experimental/jena3-sketch/src/
jena/Experimental/jena3-sketch/src/main/
jena/Experimental/jena3-sketch/src/main/java/
jena/Experimental/jena3-sketch/src/main/java/jena3/
jena/Experimental/jena3-sketch/src/main/java/jena3/NodeTuple.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/JenaException.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Node.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeConst.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeFactory.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeKindException.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeVisitor.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Quad.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Triple.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Var$.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeBlank.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeExt.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeGraph.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeImpl.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeLiteral.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeSymbol.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeURI.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/QuadImpl.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/TripleImpl.java (with props)
jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/Var.java (with props)
Modified:
jena/Experimental/jena3-sketch/ (props changed)
Propchange: jena/Experimental/jena3-sketch/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jun 6 09:04:37 2014
@@ -0,0 +1,4 @@
+.classpath
+.settings
+.project
+classes
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/NodeTuple.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/NodeTuple.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/NodeTuple.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/NodeTuple.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3;
+
+import jena3.graph.Node ;
+
+// Generalise "Triple" and "Quad", downside introduces spurious operations
+// visible on those objects.
+// Need to decide if quads align with triples - is get(0) the subject ?
+// Or subject for triples and graph node for quads?
+
+public interface NodeTuple extends Iterable<Node>
+{
+ public Node get(int i) ;
+
+ public boolean isTriple() ;
+ public boolean isQuad() ;
+
+ public Node getGraph() ;
+ public Node getSubject() ;
+ public Node getPredicate() ;
+ public Node getObject() ;
+
+ public int length() ;
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/NodeTuple.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/JenaException.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/JenaException.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/JenaException.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/JenaException.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph;
+
+/**
+ * This should be a superclass of exceptions arising from Jena code.
+ */
+public class JenaException extends RuntimeException
+{
+ public JenaException() { super(); }
+ public JenaException(String message) { super(message); }
+ public JenaException(Throwable cause) { super(cause) ; }
+ public JenaException(String message, Throwable cause) { super(message, cause) ; }
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/JenaException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Node.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Node.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Node.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Node.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph ;
+
+import jena3.graph.impl.NodeLiteral ;
+import org.apache.jena.riot.system.PrefixMap ;
+
+import com.hp.hpl.jena.datatypes.RDFDatatype ;
+
+/**
+ * An RDF 1.1 Term together
+ * <ul>
+ * <li>NodeURI</li>
+ * <li>NodeLiteral</li>
+ * <li>NodeBlank</li>
+ * <li>NodeVar</li>
+ * <li>NodeSymbol</li>
+ * <li>NodeGraph</li>
+ * </ul>
+ *
+ * @see NodeConst
+ * @see NodeFactory
+ */
+
+public interface Node
+{
+ /**
+ * Visit a Node and dispatch on it to the appropriate method from the
+ * NodeVisitor <code>v</code>.
+ *
+ * @param v the visitor to apply to the node
+ * @return the value returned by the applied method
+ */
+ public abstract Object visit(NodeVisitor v) ;
+
+ /**
+ * Answer true iff this node is concrete, ie not variable, ie URI, blank, or
+ * literal.
+ *
+ * @deprecated Use {@linkplain #isTerm()}
+ */
+ @Deprecated
+ public boolean isConcrete() ;
+
+ /** An RDF Term - a thing that can go ina data graph.
+ * The standard RDF terms are URI, Literal and Blank node. */
+ public boolean isTerm() ;
+
+ /**
+ * Answer true iff this node is a literal node.
+ */
+ public boolean isLiteral() ;
+
+ /**
+ * Answer true iff this node is a blank node.
+ */
+ public boolean isBlank() ;
+
+ /**
+ * Answer true iff this node is a URI node [subclasses override]
+ */
+ public boolean isURI() ;
+
+ /**
+ * Answer true iff this node is a variable node - subclasses override
+ */
+ public boolean isVariable() ;
+
+ /** get the blank node id if the node is blank, otherwise die horribly */
+ public Object getBlankNodeId() ;
+
+ /**
+ * Answer the label of this blank node or throw an
+ * UnsupportedOperationException if it's not blank.
+ */
+ public String getBlankNodeLabel() ;
+
+ public NodeLiteral getLiteral() ;
+
+ // public Object getLiteralValue() ;
+
+ /**
+ * Answer the lexical form of this node's literal value, if it is a literal;
+ * otherwise die horribly.
+ */
+ public String getLiteralLexicalForm() ;
+
+ /**
+ * Answer the language of this node's literal value, if it is a literal;
+ * otherwise die horribly.
+ */
+ public String getLiteralLanguage() ;
+
+ /**
+ * Answer the data-type URI of this node's literal value, if it is a
+ * literal; otherwise die horribly.
+ */
+ public String getLiteralDatatypeURI() ;
+
+ /**
+ * Answer the RDF datatype object of this node's literal value, if it is a
+ * literal; otherwise die horribly.
+ */
+ public RDFDatatype getLiteralDatatype() ;
+
+ public Object getIndexingValue() ;
+
+ /** get the URI of this node if it has one, else die horribly */
+ public String getURI() ;
+
+ /**
+ * get the namespace part of this node if it's a URI node, else die horribly
+ */
+ public String getNameSpace() ;
+
+ /**
+ * get the localname part of this node if it's a URI node, else die horribly
+ */
+ public String getLocalName() ;
+
+ /** get a variable nodes name, otherwise die horribly */
+ public String getName() ;
+
+ /** answer true iff this node is a URI node with the given URI */
+ public boolean hasURI(String uri) ;
+
+ /**
+ * Nodes only equal other Nodes that have equal labels.
+ */
+ @Override
+ public boolean equals(Object o) ;
+
+ /**
+ * Test that two nodes are semantically equivalent. In some cases this may
+ * be the same as equals, in others equals is stricter. For example, two
+ * xsd:int literals with the same value but different language tag are
+ * semantically equivalent but distinguished by the java equality function
+ * in order to support round-tripping.
+ * <p>
+ * Default implementation is to use equals, subclasses should override this.
+ * </p>
+ */
+ public boolean sameValueAs(Node n) ;
+
+ @Override
+ public int hashCode() ;
+
+ /**
+ * Answer a human-readable representation of this Node. It will not compress
+ * URIs, nor quote literals (because at the moment too many places use
+ * toString() for something machine-oriented).
+ */
+ @Override
+ public String toString() ;
+
+
+ /**
+ * Answer a human-readable representation of the Node, quoting literals and
+ * compressing URIs.
+ */
+ public String toString( PrefixMap pm ) ;
+}
\ No newline at end of file
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Node.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeConst.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeConst.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeConst.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeConst.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph;
+
+public class NodeConst
+{
+ /*
+ * ANY
+ * NULL
+ * TERM
+ * NONE
+ */
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeConst.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeFactory.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeFactory.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeFactory.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeFactory.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph;
+
+public class NodeFactory
+{
+
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeKindException.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeKindException.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeKindException.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeKindException.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph;
+
+/** Exception throw when attempting to access an apsect of a node of the wrong kind
+ * e.g. Asking for the URI of a literal or blank node.
+ */
+public class NodeKindException extends JenaException
+{
+ public NodeKindException( Node it , String message)
+ { super( message+": "+it ); }
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeKindException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeVisitor.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeVisitor.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeVisitor.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeVisitor.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph;
+
+public interface NodeVisitor
+{
+ // Which flavour? With or without return.? Two visitor types?
+
+ // public Object visit(Node...)
+
+ // public void visit(Node...)
+
+ // public void visit(Node...)
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/NodeVisitor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Quad.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Quad.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Quad.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Quad.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph;
+
+import jena3.NodeTuple ;
+
+public interface Quad extends NodeTuple
+{ }
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Quad.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Triple.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Triple.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Triple.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Triple.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph;
+
+import jena3.NodeTuple ;
+
+// Or TupleNode
+public interface Triple extends NodeTuple
+{ }
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Triple.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Var$.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Var%24.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Var$.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Var$.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph ;
+
+import java.util.ArrayList ;
+import java.util.Collection ;
+import java.util.List ;
+
+import jena3.graph.impl.Var ;
+
+import com.hp.hpl.jena.sparql.ARQConstants ;
+import com.hp.hpl.jena.sparql.expr.ExprVar ;
+
+/** A SPARQL variable */
+
+public class Var$
+{
+ // XX Unbinding variables.
+
+ public static Var alloc(String varName)
+ {
+ return new Var(varName) ;
+ }
+
+ public static Var$ alloc(Node v)
+ {
+ if ( v instanceof Var )
+ return (Var$)v ;
+ throw new NodeKindException(v, "Not a variable") ;
+ }
+
+ public static Var$ alloc(Var$ v)
+ {
+ return v ;
+ }
+
+ public static Var alloc(ExprVar nv) { return new Var(nv.getVarName()) ; }
+
+ public static String canonical(String x)
+ {
+ if ( x.startsWith("?") )
+ return x.substring(1) ;
+ if ( x.startsWith("$") )
+ return x.substring(1) ;
+ return x ;
+ }
+
+ public static boolean isVar(Node node)
+ {
+ if ( node != null && node.isVariable() )
+ return true ;
+ return false ;
+ }
+
+ public static boolean isRenamedVar(Node node)
+ { return node.isVariable() && isRenamedVar(node.getName()) ; }
+
+ public static boolean isRenamedVar(String x)
+ { return x.startsWith(ARQConstants.allocVarScopeHiding) ; }
+
+ public static boolean isNamedVar(Node node)
+ { return node.isVariable() && isNamedVarName(node.getName()) ; }
+
+ public static boolean isNamedVarName(String x)
+ { return ! isBlankNodeVarName(x) && ! isAllocVarName(x) ; }
+
+ public static boolean isBlankNodeVar(Node node)
+ { return node.isVariable() && isBlankNodeVarName(node.getName()) ; }
+
+ public static boolean isBlankNodeVarName(String x)
+ { return x.startsWith(ARQConstants.allocVarAnonMarker) ; }
+
+ public static boolean isAllocVar(Node node)
+ { return node.isVariable() && isAllocVarName(node.getName()) ; }
+
+ public static boolean isAllocVarName(String x)
+ { return x.startsWith(ARQConstants.allocVarMarker) ; }
+
+ /** Convert a collection of variable names to variables */
+ public static List<Var> varList(Collection<String> varNames) {
+ List<Var> x = new ArrayList<>() ;
+ for (String obj : varNames)
+ x.add(Var$.alloc(obj)) ;
+ return x ;
+ }
+
+ /** Return a list of String names from a collection of variables */
+ public static List<String> varNames(Collection<Var> vars)
+ {
+ List<String> x = new ArrayList<String>() ;
+ for (Var var : vars)
+ x.add(var.getVarName()) ;
+ return x ;
+ }
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/Var$.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeBlank.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeBlank.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeBlank.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeBlank.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,139 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph.impl;
+
+import java.util.UUID ;
+
+import jena3.graph.Node ;
+import jena3.graph.NodeVisitor ;
+
+import com.hp.hpl.jena.shared.uuid.JenaUUID ;
+import com.hp.hpl.jena.shared.uuid.UUIDFactory ;
+import com.hp.hpl.jena.shared.uuid.UUID_V1_Gen ;
+
+public class NodeBlank extends NodeImpl
+{
+ // XXX Switch to: org.apache.commons.id.uuid
+ // Expect it's a snadbox and seemlying inactive project.
+ // Others?
+ // Or just go with large random numbers?
+ private static UUIDFactory factory = new UUID_V1_Gen() ; // new UUID_V4_Gen() ;
+
+ // Save the space of a UUID? Obsessive?
+ private long mostSignificantBits ;
+ private long leastSignificantBits ;
+ private String label = null ;
+
+ private NodeBlank(JenaUUID uuid) {
+ mostSignificantBits = uuid.getMostSignificantBits() ;
+ leastSignificantBits = uuid.getLeastSignificantBits() ;
+ }
+
+ public NodeBlank(UUID uuid) {
+ mostSignificantBits = uuid.getMostSignificantBits() ;
+ leastSignificantBits = uuid.getLeastSignificantBits() ;
+ }
+
+ public NodeBlank() {
+ this(factory.generate()) ;
+ }
+
+ public NodeBlank(String string) {
+ // Is it a UUID? If so, use that and don't store the string.
+ try {
+ // UUID.fromString isn't very strict.
+ JenaUUID uuid = JenaUUID.parse(string) ;
+ mostSignificantBits = uuid.getMostSignificantBits() ;
+ leastSignificantBits = uuid.getLeastSignificantBits() ;
+ return ;
+ } catch (Exception ex) {}
+ label = string ;
+ // a UUID of all zeros is illegal.
+ mostSignificantBits = 0 ;
+ leastSignificantBits = 0 ;
+ }
+
+ @Override
+ public boolean isBlank() { return true ; }
+
+ @Override
+ public UUID getBlankNodeId() {
+ return new UUID(mostSignificantBits, leastSignificantBits) ;
+ }
+
+ @Override
+ public String getBlankNodeLabel() {
+ return getLabel() ;
+ }
+
+ private String getLabel() {
+ if ( label == null )
+ label = genLabel() ;
+ return label ;
+// if ( label != null )
+// return label ;
+// // XXX Cache label?
+// return genLabel() ;
+ }
+
+ private String genLabel() {
+ return JenaUUID.toString(mostSignificantBits, leastSignificantBits) ;
+ }
+
+ @Override
+ public Object visit(NodeVisitor v) {
+ return null ;
+ }
+
+ @Override
+ public boolean sameValueAs(Node n) {
+ return equals(n) ;
+ }
+
+ @Override
+ public String toString() {
+ return getLabel() ;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 57 ;
+ int result = 1 ;
+ result = prime * result + (int)(leastSignificantBits ^ (leastSignificantBits >>> 32)) ;
+ result = prime * result + (int)(mostSignificantBits ^ (mostSignificantBits >>> 32)) ;
+ return result ;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( this == obj )
+ return true ;
+ if ( obj == null )
+ return false ;
+ if ( !(obj instanceof NodeBlank) )
+ return false ;
+ NodeBlank other = (NodeBlank)obj ;
+ if ( leastSignificantBits != other.leastSignificantBits )
+ return false ;
+ if ( mostSignificantBits != other.mostSignificantBits )
+ return false ;
+ return true ;
+ }
+
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeBlank.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeExt.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeExt.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeExt.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeExt.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph.impl;
+
+public class NodeExt
+{
+
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeExt.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeGraph.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeGraph.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeGraph.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeGraph.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph.impl;
+
+public class NodeGraph
+{
+
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeGraph.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeImpl.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeImpl.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeImpl.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeImpl.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,259 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph.impl ;
+
+import jena3.graph.Node ;
+import jena3.graph.NodeKindException ;
+import jena3.graph.NodeVisitor ;
+import org.apache.jena.riot.system.PrefixMap ;
+
+import com.hp.hpl.jena.datatypes.RDFDatatype ;
+
+public abstract class NodeImpl implements Node
+{
+ /**
+ * Visit a Node and dispatch on it to the appropriate method from the
+ * NodeVisitor <code>v</code>.
+ *
+ * @param v the visitor to apply to the node
+ * @return the value returned by the applied method
+ */
+ @Override
+ public abstract Object visit(NodeVisitor v) ;
+
+ /**
+ * Answer true iff this node is concrete, ie not variable, ie URI, blank, or
+ * literal.
+ */
+ @Override
+ public boolean isConcrete() {
+ return isTerm() ;
+ }
+
+ @Override
+ public boolean isTerm() {
+ return false ;
+ }
+
+ /**
+ * Answer true iff this node is a literal node [subclasses override]
+ */
+ @Override
+ public boolean isLiteral() {
+ return false ;
+ }
+
+ /**
+ * Answer true iff this node is a blank node [subclasses override]
+ */
+ @Override
+ public boolean isBlank() {
+ return false ;
+ }
+
+ /**
+ * Answer true iff this node is a URI node [subclasses override]
+ */
+ @Override
+ public boolean isURI() {
+ return false ;
+ }
+
+ /**
+ * Answer true iff this node is a variable node - subclasses override
+ */
+ @Override
+ public boolean isVariable() {
+ return false ;
+ }
+
+ /** get the blank node id if the node is blank, otherwise die horribly */
+ @Override
+ public Object getBlankNodeId() {
+ throw new NodeKindException(this, "Not a blank node") ;
+ }
+
+ /**
+ * Answer the label of this blank node or throw an
+ * UnsupportedOperationException if it's not blank.
+ */
+ @Override
+ public String getBlankNodeLabel() {
+ throw new NodeKindException(this, "Not a blank node") ;
+ }
+
+ /**
+ * Answer the literal value of a literal node, or throw an
+ * UnsupportedOperationException if it's not a literal node
+ */
+ @Override
+ public NodeLiteral getLiteral() {
+ throw new NodeKindException(this, "Not a literal") ;
+ }
+
+ /**
+ * Answer the value of this node's literal value, if it is a literal;
+ * otherwise die horribly.
+ */
+ public Object getLiteralValue() {
+ throw new NodeKindException(this, "Not a literal") ;
+ }
+
+ /**
+ * Answer the lexical form of this node's literal value, if it is a literal;
+ * otherwise die horribly.
+ */
+ @Override
+ public String getLiteralLexicalForm() {
+ throw new NodeKindException(this, "Not a literal") ;
+ }
+
+ /**
+ * Answer the language of this node's literal value, if it is a literal;
+ * otherwise die horribly.
+ */
+ @Override
+ public String getLiteralLanguage() {
+ throw new NodeKindException(this, "Not a literal") ;
+ }
+
+ /**
+ * Answer the data-type URI of this node's literal value, if it is a
+ * literal; otherwise die horribly.
+ */
+ @Override
+ public String getLiteralDatatypeURI() {
+ throw new NodeKindException(this, "Not a literal") ;
+ }
+
+ /**
+ * Answer the RDF datatype object of this node's literal value, if it is a
+ * literal; otherwise die horribly.
+ */
+ @Override
+ public RDFDatatype getLiteralDatatype() {
+ throw new NodeKindException(this, "Not a literal") ;
+ }
+
+ /**
+ * Answer the object which is the index value for this Node. The default is
+ * this Node itself; overridden in Node_Literal for literal indexing
+ * purposes. Only concrete nodes should use this method.
+ */
+ @Override
+ public Object getIndexingValue() {
+ return this ;
+ }
+
+ /** get the URI of this node if it has one, else die horribly */
+ @Override
+ public String getURI() {
+ throw new NodeKindException(this, "Not a URI node") ;
+ }
+
+ /**
+ * get the namespace part of this node if it's a URI node, else die horribly
+ */
+ @Override
+ public String getNameSpace() {
+ throw new NodeKindException(this, "Not a URI node") ;
+ }
+
+ /**
+ * get the localname part of this node if it's a URI node, else die horribly
+ */
+ @Override
+ public String getLocalName() {
+ throw new NodeKindException(this, "Not a URI node") ;
+ }
+
+ /** get a variable nodes name, otherwise die horribly */
+ @Override
+ public String getName() {
+ throw new NodeKindException(this, "Not a variable node") ;
+ }
+
+ /** answer true iff this node is a URI node with the given URI */
+ @Override
+ public boolean hasURI(String uri) {
+ return false ;
+ }
+
+ /**
+ * Nodes only equal other Nodes that have equal labels.
+ */
+ @Override
+ public abstract boolean equals(Object o) ;
+
+ /**
+ * Test that two nodes are semantically equivalent. In some cases this may
+ * be the same as equals, in others equals is stricter. For example, two
+ * xsd:int literals with the same value but different language tag are
+ * semantically equivalent but distinguished by the java equality function
+ * in order to support round-tripping.
+ * <p>
+ * Default implementation is to use equals, subclasses should override this.
+ * </p>
+ */
+ @Override
+ public boolean sameValueAs(Node n) {
+ return equals(n) ;
+ }
+
+
+ @Override
+ public abstract int hashCode() ;
+
+ /**
+ * Answer true iff this node accepts the other one as a match. The default
+ * is an equality test; it is over-ridden in subclasses to provide the
+ * appropriate semantics for literals, ANY, and variables.
+ *
+ * @param other a node to test for matching
+ * @return true iff this node accepts the other as a match
+ */
+ public boolean matches(Node other) {
+ return equals(other) ;
+ }
+
+ /**
+ * Answer a human-readable representation of this Node. It will not compress
+ * URIs, nor quote literals (because at the moment too many places use
+ * toString() for something machine-oriented).
+ */
+ @Override
+ public abstract String toString() ;
+
+ /**
+ * Answer a human-readable representation of the Node, quoting literals and
+ * compressing URIs.
+ */
+ @Override
+ public String toString(PrefixMap pm) {
+ return toString() ;
+ }
+
+ /**
+ * Answer a human readable representation of this Node, quoting literals if
+ * specified, and compressing URIs using the prefix mapping supplied.
+ */
+ public String toString(PrefixMap pm, boolean quoting) {
+ return toString() ;
+ }
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeLiteral.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeLiteral.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeLiteral.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeLiteral.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,196 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph.impl;
+
+import jena3.graph.NodeVisitor ;
+import org.apache.jena.atlas.lib.NotImplemented ;
+
+import com.hp.hpl.jena.datatypes.RDFDatatype ;
+import com.hp.hpl.jena.datatypes.xsd.XSDDatatype ;
+
+public class NodeLiteral extends NodeImpl
+{
+ private static final Object badLexicalForm = new Object() ;
+ private static final Object unsetValue = new Object() ;
+
+ /**
+ * The lexical form of the literal, may be null if the literal was
+ * created programatically and has not yet been serialized
+ */
+ final private String lexicalForm;
+
+ /**
+ * The value form of the literal. It will be null only if the value
+ * has not been parsed or if it is an illegal value.
+ * For plain literals and xsd:string literals
+ * the value is the same as the lexicalForm.
+ */
+ private Object value = unsetValue ; // XXX Delay evaluation.
+
+ /**
+ * The type of the literal. A null type indicates a classic "plain" literal.
+ * The type of a literal is fixed when it is created.
+ */
+ // XXX Needs to define hashCode and equals.
+ final private RDFDatatype dtype;
+
+ /**
+ * The xml:lang tag. For xsd literals this is ignored and not part of
+ * equality. For plain literals it is not ignored. The lang of a
+ * literal is fixed when it is created.
+ */
+ final private String lang;
+
+// /**
+// * Indicates whether this is a legal literal. The working groups requires
+// * ill-formed literals to be treated as syntactically correct so instead
+// * of only storing well-formed literals we hack around it this way.
+// * N.B. This applies to any literal, not just XML well-formed literals.
+// */
+// private boolean wellformed = true;
+//
+// /**
+// * keeps the message provided by the DatatypeFormatException
+// * if parsing failed for delayed exception thrown in getValue()
+// */
+// private String exceptionMsg = null; // Suggested by Andreas Langegger
+
+ public NodeLiteral(String lexicalForm, RDFDatatype datatype, String lang) {
+ this.lexicalForm = lexicalForm ;
+ if ( datatype == null )
+ datatype = XSDDatatype.XSDstring ;
+ if ( lang != null )
+ // XXX Check
+ datatype = null ; //XSDDatatype.XSDlangString ;
+ this.dtype = datatype ;
+ if ( lang == null )
+ lang = "" ;
+ this.lang = lang ;
+ }
+
+ /**
+ * Answer the literal value of a literal node, or throw an
+ * UnsupportedOperationException if it's not a literal node
+ */
+ @Override
+ public NodeLiteral getLiteral() {
+ throw new UnsupportedOperationException(this + " is not a literal node") ;
+ }
+
+ /**
+ * Answer the value of this node's literal value, if it is a literal;
+ * otherwise die horribly.
+ */
+ @Override
+ public Object getLiteralValue() {
+ throw new NotImplemented() ;
+ //return value ;
+ }
+
+ /**
+ * Answer the lexical form of this node's literal value, if it is a literal;
+ * otherwise die horribly.
+ */
+ @Override
+ public String getLiteralLexicalForm() {
+ return lexicalForm ;
+ }
+
+ /**
+ * Answer the language of this node's literal value, if it is a literal;
+ * otherwise die horribly.
+ */
+ @Override
+ public String getLiteralLanguage() {
+ return lang ;
+ }
+
+ /**
+ * Answer the data-type URI of this node's literal value.
+ */
+ @Override
+ public String getLiteralDatatypeURI() {
+ return dtype.getURI() ;
+ }
+
+ /**
+ * Answer the RDF datatype object of this node's literal value.
+ */
+ @Override
+ public RDFDatatype getLiteralDatatype() {
+ return dtype ;
+ }
+
+ @Override
+ public Object visit(NodeVisitor v) {
+ throw new NotImplemented() ;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 97 ;
+ int result = 1 ;
+ result = prime * result + ((dtype == null) ? 0 : dtype.hashCode()) ;
+ result = prime * result + ((lang == null) ? 0 : lang.hashCode()) ;
+ result = prime * result + ((lexicalForm == null) ? 0 : lexicalForm.hashCode()) ;
+ return result ;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( this == obj )
+ return true ;
+ if ( obj == null )
+ return false ;
+ if ( !(obj instanceof NodeLiteral) )
+ return false ;
+ NodeLiteral other = (NodeLiteral)obj ;
+ if ( dtype == null ) {
+ if ( other.dtype != null )
+ return false ;
+ } else if ( !dtype.equals(other.dtype) )
+ return false ;
+ if ( lang == null ) {
+ if ( other.lang != null )
+ return false ;
+ } else if ( !lang.equals(other.lang) )
+ return false ;
+ if ( lexicalForm == null ) {
+ if ( other.lexicalForm != null )
+ return false ;
+ } else if ( !lexicalForm.equals(other.lexicalForm) )
+ return false ;
+ return true ;
+ }
+
+ @Override
+ public String toString() {
+ // XXX
+ String s = "\""+lexicalForm+"\"" ;
+ if ( lang == null ) {
+ if ( ! XSDDatatype.XSDstring.equals(dtype) )
+ s = s+"^^<"+dtype.getURI()+">" ;
+ }
+ else
+ s = s+"@"+lang ;
+ return s ;
+
+ }
+
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeLiteral.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeSymbol.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeSymbol.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeSymbol.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeSymbol.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph.impl;
+
+import jena3.graph.NodeVisitor ;
+import org.apache.jena.riot.system.PrefixMap ;
+
+public class NodeSymbol extends NodeImpl
+{
+ private final String symbol ;
+
+ public NodeSymbol(String string) {
+ if ( string == null )
+ throw new IllegalArgumentException("Null argument to NodeSymbol constructor") ;
+ this.symbol = string ;
+ }
+
+ @Override
+ public String toString() {
+ return "symbol:"+symbol ;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31 ;
+ int result = 1 ;
+ result = prime * result + ((symbol == null) ? 0 : symbol.hashCode()) ;
+ return result ;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( this == obj )
+ return true ;
+ if ( obj == null )
+ return false ;
+ if ( !(obj instanceof NodeSymbol) )
+ return false ;
+ NodeSymbol other = (NodeSymbol)obj ;
+ // Label is irrelevant.
+ if ( symbol == null ) {
+ if ( other.symbol != null )
+ return false ;
+ } else if ( !symbol.equals(other.symbol) )
+ return false ;
+ return true ;
+ }
+
+
+ @Override
+ public String toString(PrefixMap pm) {
+ return null ;
+ }
+
+
+ @Override
+ public Object visit(NodeVisitor v) {
+ return null ;
+ }
+
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeSymbol.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeURI.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeURI.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeURI.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeURI.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph.impl;
+
+import jena3.graph.Node ;
+import jena3.graph.NodeVisitor ;
+import org.apache.jena.atlas.lib.NotImplemented ;
+
+public class NodeURI extends NodeImpl
+{
+
+ private final String uri ;
+
+ /*public*/ NodeURI(String uri) { this.uri = uri ; }
+
+ /** get the URI of this node if it has one, else die horribly */
+ @Override
+ public boolean isURI() { return true ; }
+
+ /** get the URI of this node if it has one, else die horribly */
+ @Override
+ public String getURI() { return uri ; }
+
+ @Override
+ public Object visit(NodeVisitor v) {
+ throw new NotImplemented() ; }
+
+ @Override
+ public String getNameSpace() {
+ throw new NotImplemented() ;
+ }
+
+ @Override
+ public String getLocalName() {
+ throw new NotImplemented() ;
+ }
+
+ @Override
+ public boolean sameValueAs(Node n) {
+ return equals(n) ;
+ }
+
+ @Override
+ public String toString() {
+ return "<"+uri+">" ;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31 ;
+ int result = 1 ;
+ result = prime * result + ((uri == null) ? 0 : uri.hashCode()) ;
+ return result ;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( this == obj )
+ return true ;
+ if ( obj == null )
+ return false ;
+ if ( !(obj instanceof NodeURI) )
+ return false ;
+ NodeURI other = (NodeURI)obj ;
+ if ( uri == null ) {
+ if ( other.uri != null )
+ return false ;
+ } else if ( !uri.equals(other.uri) )
+ return false ;
+ return true ;
+ }
+
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/NodeURI.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/QuadImpl.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/QuadImpl.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/QuadImpl.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/QuadImpl.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph.impl;
+
+import java.util.Iterator ;
+
+import jena3.NodeTuple ;
+import jena3.graph.Node ;
+import jena3.graph.Triple ;
+import org.apache.jena.atlas.iterator.IteratorArray ;
+
+public class QuadImpl implements Triple, NodeTuple
+{
+ private final Node graph, subj, pred, obj;
+
+ public QuadImpl(Node g, Node s, Node p, Node o ) {
+ if (g == null) throw new UnsupportedOperationException( "graph cannot be null" );
+ if (s == null) throw new UnsupportedOperationException( "subject cannot be null" );
+ if (p == null) throw new UnsupportedOperationException( "predicate cannot be null" );
+ if (o == null) throw new UnsupportedOperationException( "object cannot be null" );
+ graph = g ;
+ subj = s;
+ pred = p;
+ obj = o;
+ }
+
+ @Override
+ public Node get(int i) {
+ switch(i) {
+ case 0: return graph ;
+ case 1: return subj ;
+ case 2: return pred ;
+ case 3: return obj ;
+ default:
+ throw new IllegalArgumentException("Index out of range for a quad: "+i) ;
+ }
+ }
+
+ @Override
+ public Node getGraph() {
+ return graph ;
+ }
+
+ @Override
+ public Node getSubject() {
+ return subj ;
+ }
+
+ @Override
+ public Node getPredicate() {
+ return pred ;
+ }
+
+ @Override
+ public Node getObject() {
+ return obj ;
+ }
+
+ @Override
+ public int length() {
+ return 4 ;
+ }
+
+ @Override
+ public Iterator<Node> iterator() {
+ return IteratorArray.create(new Node[]{graph, subj, pred, obj}) ;
+ }
+
+ @Override
+ public boolean isTriple() { return false ; }
+
+ @Override
+ public boolean isQuad() { return true ; }
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/QuadImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/TripleImpl.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/TripleImpl.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/TripleImpl.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/TripleImpl.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph.impl;
+
+import java.util.Iterator ;
+
+import jena3.NodeTuple ;
+import jena3.graph.Node ;
+import jena3.graph.Triple ;
+import org.apache.jena.atlas.iterator.IteratorArray ;
+
+public class TripleImpl implements Triple, NodeTuple
+{
+ private final Node subj, pred, obj;
+
+ public TripleImpl( Node s, Node p, Node o ) {
+ if (s == null) throw new UnsupportedOperationException( "subject cannot be null" );
+ if (p == null) throw new UnsupportedOperationException( "predicate cannot be null" );
+ if (o == null) throw new UnsupportedOperationException( "object cannot be null" );
+ subj = s;
+ pred = p;
+ obj = o;
+ }
+
+ @Override
+ public Node get(int i) {
+ switch(i) {
+ case 0: return subj ;
+ case 1: return pred ;
+ case 2: return obj ;
+ default:
+ throw new IllegalArgumentException("Index out of range for a triple: "+i) ;
+ }
+ }
+
+ @Override
+ public Node getGraph() {
+ return null ;
+ }
+
+ @Override
+ public Node getSubject() {
+ return subj ;
+ }
+
+ @Override
+ public Node getPredicate() {
+ return pred ;
+ }
+
+ @Override
+ public Node getObject() {
+ return obj ;
+ }
+
+ @Override
+ public int length() {
+ return 3 ;
+ }
+
+ @Override
+ public boolean isTriple() { return true ; }
+
+ @Override
+ public boolean isQuad() { return false ; }
+
+ @Override
+ public Iterator<Node> iterator() {
+ return IteratorArray.create(new Node[] {subj, pred, obj}) ;
+ }
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/TripleImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/Var.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/Var.java?rev=1600830&view=auto
==============================================================================
--- jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/Var.java (added)
+++ jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/Var.java Fri Jun 6 09:04:37 2014
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jena3.graph.impl;
+
+import jena3.graph.NodeVisitor ;
+
+public class Var extends NodeImpl
+{
+ private final String varName ;
+
+ public Var(String name) {
+ if ( name == null )
+ throw new IllegalArgumentException("Null for variable name") ;
+ this.varName = name ;
+ }
+
+ @Override
+ public String getName()
+ { return varName ; }
+
+ @Override
+ public Object visit( NodeVisitor v ) { return null ; }
+ //{ return v.visitVariable( this, getName() ); }
+
+ @Override
+ public boolean isVariable()
+ { return true; }
+
+ public String getVarName() { return getName() ; }
+
+// public boolean isNamedVar() { return Var$.isNamedVarName(getName()) ; }
+//
+// public boolean isBlankNodeVar() { return Var$.isBlankNodeVarName(getName()) ; }
+//
+// public boolean isAllocVar() { return Var$.isAllocVarName(getName()) ; }
+//
+// public boolean isAnonVar() { return Var$.isAnonVar(this) ; }
+
+ @Override
+ public String toString() {
+ return "?"+varName ;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 103 ;
+ int result = 1 ;
+ result = prime * result + ((varName == null) ? 0 : varName.hashCode()) ;
+ return result ;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( this == obj )
+ return true ;
+ if ( obj == null )
+ return false ;
+ if ( !(obj instanceof Var) )
+ return false ;
+ Var other = (Var)obj ;
+ if ( varName == null ) {
+ if ( other.varName != null )
+ return false ;
+ } else if ( !varName.equals(other.varName) )
+ return false ;
+ return true ;
+ }
+}
Propchange: jena/Experimental/jena3-sketch/src/main/java/jena3/graph/impl/Var.java
------------------------------------------------------------------------------
svn:mime-type = text/plain