Repository: jena Updated Branches: refs/heads/master b5afdc51e -> 057fc73e2
Add extension point for RDF Terms. Add Node_Triple and Node_Graph. Applicaton beware! Project: http://git-wip-us.apache.org/repos/asf/jena/repo Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/41d2f732 Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/41d2f732 Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/41d2f732 Branch: refs/heads/master Commit: 41d2f7328544679e709b96e8746107ec05a873e5 Parents: a725e96 Author: Andy Seaborne <[email protected]> Authored: Tue Nov 28 18:42:30 2017 +0000 Committer: Andy Seaborne <[email protected]> Committed: Tue Nov 28 18:42:30 2017 +0000 ---------------------------------------------------------------------- .../java/org/apache/jena/graph/Node_Ext.java | 67 ++++++++++++++++++++ .../java/org/apache/jena/graph/Node_Graph.java | 49 ++++++++++++++ .../java/org/apache/jena/graph/Node_Triple.java | 27 ++++++++ 3 files changed, 143 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jena/blob/41d2f732/jena-core/src/main/java/org/apache/jena/graph/Node_Ext.java ---------------------------------------------------------------------- diff --git a/jena-core/src/main/java/org/apache/jena/graph/Node_Ext.java b/jena-core/src/main/java/org/apache/jena/graph/Node_Ext.java new file mode 100644 index 0000000..b012681 --- /dev/null +++ b/jena-core/src/main/java/org/apache/jena/graph/Node_Ext.java @@ -0,0 +1,67 @@ +/* + * 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 org.apache.jena.graph; + +import java.util.Objects; + +/** Extension to the RDF Data model. + * This class and any subclasses exist for experimentation and custom extensions. + * There is no support for them within Apache Jena. + * <p> + * Extension nodes exist so that the machinary of datastructures (graphs, triples) + * can be used. There is no guarantee that processing Nodes (e.g. writing) will handle + * extensions. For the usual RDF syntaxes, {@code NodeExt} are not handled. + */ +public abstract class Node_Ext<X> extends Node { + + Node_Ext(X label) { + super(label); + } + + @Override + public Object visitWith(NodeVisitor v) { + return null; + } + + @Override + public boolean isConcrete() { + return false; + } + + @SuppressWarnings("unchecked") + public X get() { + return (X)label; + } + + // Super is OK : it is based on label. +// @Override +// public int hashCode() { +// } + + @Override + public boolean equals(Object o) { + if ( o == this ) + return true; + if ( !(o instanceof Node_Ext<? >) ) + return false; + @SuppressWarnings("unchecked") + Node_Ext<X> other = (Node_Ext<X>)o; + return Objects.equals(this.get(), other.get()); + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/41d2f732/jena-core/src/main/java/org/apache/jena/graph/Node_Graph.java ---------------------------------------------------------------------- diff --git a/jena-core/src/main/java/org/apache/jena/graph/Node_Graph.java b/jena-core/src/main/java/org/apache/jena/graph/Node_Graph.java new file mode 100644 index 0000000..eb83cc2 --- /dev/null +++ b/jena-core/src/main/java/org/apache/jena/graph/Node_Graph.java @@ -0,0 +1,49 @@ +/* + * 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 org.apache.jena.graph; + +/** RDF Graphs as RDF terms. + * <p> + * Beware that equality and hashCode are defined by + * object identity, not graph same-triples nor isomoprphism. + * <p> + * For experimentation. + * Otherwise, unsupported. + */ +public class Node_Graph extends Node_Ext<Graph>{ + + public Node_Graph(Graph graph) { + super(graph); + } + + @Override + public int hashCode() { + return System.identityHashCode(get())*31; + } + + @Override + public boolean equals(Object o) { + if ( o == this ) + return true; + if ( !(o instanceof Node_Graph) ) + return false; + Node_Graph other = (Node_Graph)o; + return this.get() == other.get(); + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/41d2f732/jena-core/src/main/java/org/apache/jena/graph/Node_Triple.java ---------------------------------------------------------------------- diff --git a/jena-core/src/main/java/org/apache/jena/graph/Node_Triple.java b/jena-core/src/main/java/org/apache/jena/graph/Node_Triple.java new file mode 100644 index 0000000..3524de4 --- /dev/null +++ b/jena-core/src/main/java/org/apache/jena/graph/Node_Triple.java @@ -0,0 +1,27 @@ +/* + * 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 org.apache.jena.graph; + +/** RDF triples as RDF terms. */ +public class Node_Triple extends Node_Ext<Triple>{ + + public Node_Triple(Triple triple) { + super(triple); + } +}
