You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by ha...@apache.org on 2019/05/11 19:39:34 UTC
[clerezza] 12/45: CLEREZZA-1026: Clean up rdf.core
This is an automated email from the ASF dual-hosted git repository.
hasan pushed a commit to branch reunited
in repository https://gitbox.apache.org/repos/asf/clerezza.git
commit 1b65ea25c9a96f884425a9f7d2090bb2267e94e8
Author: Hasan <ha...@apache.org>
AuthorDate: Wed Nov 14 04:34:23 2018 +0100
CLEREZZA-1026: Clean up rdf.core
---
.../rdf/core/InvalidLiteralTypeException.java | 40 --
.../apache/clerezza/rdf/core/LiteralFactory.java | 84 ----
.../clerezza/rdf/core/NoConvertorException.java | 41 --
.../clerezza/rdf/core/impl/WriteBlockedGraph.java | 123 -----
.../apache/clerezza/rdf/core/impl/util/Base64.java | 120 -----
.../rdf/core/impl/util/PrivilegedGraphWrapper.java | 261 -----------
.../impl/util/PrivilegedImmuatbleGraphWrapper.java | 36 --
.../rdf/core/impl/util/SimpleLiteralFactory.java | 313 -------------
.../clerezza/rdf/core/impl/util/W3CDateFormat.java | 196 --------
.../rdf/core/sparql/NoQueryEngineException.java | 42 --
.../clerezza/rdf/core/sparql/QueryEngine.java | 64 ---
.../clerezza/rdf/core/sparql/QueryParser.java | 70 ---
.../apache/clerezza/rdf/core/sparql/ResultSet.java | 39 --
.../clerezza/rdf/core/sparql/SolutionMapping.java | 50 --
.../clerezza/rdf/core/sparql/SparqlPreParser.java | 168 -------
.../rdf/core/sparql/StringQuerySerializer.java | 94 ----
.../rdf/core/sparql/query/AbstractOperation.java | 41 --
.../core/sparql/query/AlternativeGraphPattern.java | 38 --
.../clerezza/rdf/core/sparql/query/AskQuery.java | 29 --
.../rdf/core/sparql/query/BasicGraphPattern.java | 38 --
.../rdf/core/sparql/query/BinaryOperation.java | 46 --
.../sparql/query/BinaryPropertyPathOperation.java | 44 --
.../rdf/core/sparql/query/BuiltInCall.java | 47 --
.../rdf/core/sparql/query/ConstructQuery.java | 41 --
.../clerezza/rdf/core/sparql/query/DataSet.java | 46 --
.../rdf/core/sparql/query/DescribeQuery.java | 50 --
.../clerezza/rdf/core/sparql/query/Expression.java | 42 --
.../rdf/core/sparql/query/FunctionCall.java | 48 --
.../rdf/core/sparql/query/GraphGraphPattern.java | 42 --
.../rdf/core/sparql/query/GraphPattern.java | 30 --
.../rdf/core/sparql/query/GroupGraphPattern.java | 69 ---
.../clerezza/rdf/core/sparql/query/InlineData.java | 31 --
.../rdf/core/sparql/query/LiteralExpression.java | 40 --
.../rdf/core/sparql/query/MinusGraphPattern.java | 40 --
.../core/sparql/query/OptionalGraphPattern.java | 45 --
.../rdf/core/sparql/query/OrderCondition.java | 37 --
.../query/PathSupportedBasicGraphPattern.java | 43 --
.../sparql/query/PatternExistenceCondition.java | 66 ---
.../rdf/core/sparql/query/PredicatePath.java | 38 --
.../core/sparql/query/PropertyPathExpression.java | 29 --
.../query/PropertyPathExpressionOrVariable.java | 104 -----
.../rdf/core/sparql/query/PropertyPathPattern.java | 46 --
.../rdf/core/sparql/query/PropertySet.java | 44 --
.../clerezza/rdf/core/sparql/query/Query.java | 59 ---
.../sparql/query/QueryWithSolutionModifier.java | 68 ---
.../rdf/core/sparql/query/ResourceOrVariable.java | 106 -----
.../core/sparql/query/RhsListBinaryOperation.java | 47 --
.../rdf/core/sparql/query/SelectQuery.java | 70 ---
.../rdf/core/sparql/query/ServiceGraphPattern.java | 41 --
.../clerezza/rdf/core/sparql/query/SparqlUnit.java | 51 ---
.../rdf/core/sparql/query/TriplePattern.java | 44 --
.../rdf/core/sparql/query/UnaryOperation.java | 38 --
.../sparql/query/UnaryPropertyPathOperation.java | 37 --
.../rdf/core/sparql/query/UriRefExpression.java | 39 --
.../rdf/core/sparql/query/UriRefOrVariable.java | 43 --
.../clerezza/rdf/core/sparql/query/Variable.java | 86 ----
.../query/impl/SimpleAlternativeGraphPattern.java | 59 ---
.../rdf/core/sparql/query/impl/SimpleAskQuery.java | 33 --
.../sparql/query/impl/SimpleBasicGraphPattern.java | 48 --
.../sparql/query/impl/SimpleConstructQuery.java | 50 --
.../rdf/core/sparql/query/impl/SimpleDataSet.java | 51 ---
.../sparql/query/impl/SimpleDescribeQuery.java | 60 ---
.../sparql/query/impl/SimpleGraphGraphPattern.java | 55 ---
.../sparql/query/impl/SimpleGroupGraphPattern.java | 236 ----------
.../core/sparql/query/impl/SimpleInlineData.java | 53 ---
.../sparql/query/impl/SimpleMinusGraphPattern.java | 67 ---
.../query/impl/SimpleOptionalGraphPattern.java | 68 ---
.../sparql/query/impl/SimpleOrderCondition.java | 47 --
.../impl/SimplePathSupportedBasicGraphPattern.java | 48 --
.../query/impl/SimplePropertyPathPattern.java | 136 ------
.../rdf/core/sparql/query/impl/SimpleQuery.java | 76 ----
.../impl/SimpleQueryWithSolutionModifier.java | 92 ----
.../core/sparql/query/impl/SimpleSelectQuery.java | 79 ----
.../query/impl/SimpleServiceGraphPattern.java | 66 ---
.../core/sparql/query/impl/SimpleSparqlUnit.java | 65 ---
.../query/impl/SimpleStringQuerySerializer.java | 315 -------------
.../sparql/query/impl/SimpleTriplePattern.java | 136 ------
.../clerezza/rdf/core/sparql/update/Update.java | 51 ---
.../rdf/core/sparql/update/UpdateOperation.java | 56 ---
.../rdf/core/sparql/update/impl/AddOperation.java | 29 --
.../sparql/update/impl/BaseUpdateOperation.java | 85 ----
.../core/sparql/update/impl/ClearOperation.java | 26 --
.../sparql/update/impl/ClearOrDropOperation.java | 60 ---
.../rdf/core/sparql/update/impl/CopyOperation.java | 26 --
.../core/sparql/update/impl/CreateOperation.java | 55 ---
.../sparql/update/impl/DeleteDataOperation.java | 26 --
.../sparql/update/impl/DeleteWhereOperation.java | 26 --
.../rdf/core/sparql/update/impl/DropOperation.java | 26 --
.../sparql/update/impl/InsertDataOperation.java | 26 --
.../rdf/core/sparql/update/impl/LoadOperation.java | 41 --
.../core/sparql/update/impl/ModifyOperation.java | 111 -----
.../rdf/core/sparql/update/impl/MoveOperation.java | 26 --
.../clerezza/rdf/core/sparql/update/impl/Quad.java | 42 --
.../rdf/core/sparql/update/impl/SimpleUpdate.java | 51 ---
.../sparql/update/impl/SimpleUpdateOperation.java | 76 ----
.../update/impl/UpdateOperationWithQuads.java | 78 ----
.../QueryParserSerializerCombinationTest.java | 140 ------
.../clerezza/rdf/core/sparql/QueryParserTest.java | 383 ----------------
.../rdf/core/sparql/QuerySerializerTest.java | 318 -------------
.../rdf/core/sparql/SparqlPreParserTest.java | 505 ---------------------
100 files changed, 7787 deletions(-)
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/InvalidLiteralTypeException.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/InvalidLiteralTypeException.java
deleted file mode 100644
index 923ea6b..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/InvalidLiteralTypeException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.clerezza.rdf.core;
-
-import org.apache.clerezza.commons.rdf.IRI;
-
-/**
- * Thrown when a literal is of the wrong type for conversion to a java-type
- *
- * @author reto
- */
-public class InvalidLiteralTypeException extends RuntimeException {
-
- /**
- * Constructs the exception to be thrown when a literal cannot be
- * converted to an instance of the specified class
- *
- * @param javaType the <code>Class</code> to convert to
- * @param literalType the literalType which can't be converted
- */
- public InvalidLiteralTypeException(Class<?> javaType, IRI literalType) {
- super("Cannot create a "+javaType+" from a literal of type "+literalType);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/LiteralFactory.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/LiteralFactory.java
deleted file mode 100644
index 2baa1c1..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/LiteralFactory.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.clerezza.rdf.core;
-
-import org.apache.clerezza.rdf.core.impl.util.SimpleLiteralFactory;
-import org.apache.clerezza.commons.rdf.Literal;
-
-/**
- * This class provides methods to convert java objects to typed literals and
- * vice versa. While the default implementation will provide literal objects
- * storing the data's lexical form in memory, other implementations may
- * create literal optimized for processing within the store.
- *
- * Note: this class uses the notion of "Convertor" (in the Exception naming),
- * but does not currently provide a mechanism to register such
- * <code>Convertor</code>s. An implementation is said to provide
- * <code>Convertor</code>s for the types it supports.
- *
- * @since 0.3
- * @author reto
- */
-public abstract class LiteralFactory {
-
- private static LiteralFactory instance = new SimpleLiteralFactory();
-
- /**
- * Get a <code>LiteralFactory</code>. If this has not been set using
- * setInstance it returns an instance of
- * {@link org.apache.clerezza.model.impl.SimpleLiteralFactory}.
- *
- * @return a concrete <code>LiteralFactory</code>
- */
- public static LiteralFactory getInstance() {
- return instance;
- }
-
- /**
- * Set the instance returned by <code>getInstance</code>.
- *
- * @param instance the new default <code>LiteralFactory</code>
- */
- public static void setInstance(LiteralFactory instance) {
- LiteralFactory.instance = instance;
- }
-
- /**
- * Create a typed literal for the specified object
- *
- * @param value the value of the literal to be created
- * @return a TypedLiteral representing the value
- * @throws NoConvertorException thrown if <code>value</code> is of an invalid type
- */
- public abstract Literal createTypedLiteral(Object value)
- throws NoConvertorException;
-
- /**
- * Converts a literal to an instance of the specified class
- *
- * @param <T>
- * @param type the <code>Class</code> of the returned object
- * @param literal the literal to be converted
- * @return a java object representing the value of the literal
- * @throws NoConvertorException thrown if <code>type</code> is unsupported
- * @throws InvalidLiteralTypeException if the literal type doesn't match the requested java type
- */
- public abstract <T> T createObject(Class<T> type, Literal literal)
- throws NoConvertorException, InvalidLiteralTypeException;
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/NoConvertorException.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/NoConvertorException.java
deleted file mode 100644
index 768ecb2..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/NoConvertorException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.clerezza.rdf.core;
-
-import java.lang.reflect.Type;
-
-/**
- * This exception is thrown when no convertor is available to do a required
- * java-object to literal or literal to java-object conversion.
- *
- * @since 0.3
- * @author reto
- */
-public class NoConvertorException extends RuntimeException {
-
- /**
- * Create an instance of <code>NoConvertorException</code>
- * indicating that no convertor is available for the type.
- *
- * @param type the type for which no convertor is available
- */
- public NoConvertorException(Type type) {
- super("No convertor available for type "+type);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedGraph.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedGraph.java
deleted file mode 100644
index 542215d..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedGraph.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * 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.clerezza.rdf.core.impl;
-
-import java.util.AbstractCollection;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.clerezza.commons.rdf.BlankNodeOrIRI;
-import org.apache.clerezza.commons.rdf.RDFTerm;
-import org.apache.clerezza.commons.rdf.Triple;
-import org.apache.clerezza.commons.rdf.Graph;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.access.ReadOnlyException;
-import org.apache.clerezza.commons.rdf.ImmutableGraph;
-import org.apache.clerezza.commons.rdf.event.FilterTriple;
-import org.apache.clerezza.commons.rdf.event.GraphListener;
-import org.apache.clerezza.commons.rdf.impl.utils.AbstractGraph;
-
-/**
- *
- * This is a wrapper object for <code>Graph</code>. If <code>SecurityManger</code>
- * is not <code>null</code> <code>TcManager</code> checks the <code>TcPermission</code>.
- * If read-only permissions are set this wrapper is used instead of <code>Graph</code>
- * and throws exceptions when add or remove methods are called.
- *
- * @author tsuy
- */
-public class WriteBlockedGraph extends AbstractGraph
- implements Graph {
-
- private Graph triples;
-
- public WriteBlockedGraph(Graph triples) {
- this.triples = triples;
- }
-
- @Override
- protected int performSize() {
- return triples.size();
- }
-
- @Override
- protected Iterator<Triple> performFilter(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
- final Iterator<Triple> baseIter = triples.filter(subject, predicate, object);
- return new Iterator<Triple>() {
-
- @Override
- public boolean hasNext() {
- return baseIter.hasNext();
- }
-
- @Override
- public Triple next() {
- return baseIter.next();
- }
-
- @Override
- public void remove() {
- throw new ReadOnlyException("remove");
- }
-
-
- };
- }
-
- @Override
- public boolean add(Triple e) {
- throw new ReadOnlyException("add");
- }
-
- @Override
- public boolean addAll(Collection<? extends Triple> c) {
- throw new ReadOnlyException("add all");
- }
-
- @Override
- public void clear() {
- throw new ReadOnlyException("clear");
- }
-
- @Override
- public boolean remove(Object o) {
- throw new ReadOnlyException("remove");
- }
-
- @Override
- public boolean removeAll(Collection<?> c) {
- throw new ReadOnlyException("remove all");
- }
-
- @Override
- public boolean retainAll(Collection<?> c) {
- throw new ReadOnlyException("retain all");
- }
-
- @Override
- public Iterator iterator() {
- return filter(null, null, null);
- }
-
- @Override
- public ImmutableGraph getImmutableGraph() {
- return this.triples.getImmutableGraph();
- }
-
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/Base64.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/Base64.java
deleted file mode 100644
index 1c3db17..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/Base64.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Taken from the book:
- * Jonathan Knudsen, "Java Cryptography", O'Reilly Media, Inc., 1998
- */
-package org.apache.clerezza.rdf.core.impl.util;
-/*
- *
- * 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.
- *
-*/
-
-
-public class Base64 {
-
- public static String encode(byte[] raw) {
- StringBuffer encoded = new StringBuffer();
- for (int i = 0; i < raw.length; i += 3) {
- encoded.append(encodeBlock(raw, i));
- }
- return encoded.toString();
- }
-
- protected static char[] encodeBlock(byte[] raw, int offset) {
- int block = 0;
- int slack = raw.length - offset - 1;
- int end = (slack >= 2) ? 2 : slack;
- for (int i = 0; i <= end; i++) {
- byte b = raw[offset + i];
- int neuter = (b < 0) ? b + 256 : b;
- block += neuter << (8 * (2 - i));
- }
- char[] base64 = new char[4];
- for (int i = 0; i < 4; i++) {
- int sixbit = (block >>> (6 * (3 - i))) & 0x3f;
- base64[i] = getChar(sixbit);
- }
- if (slack < 1) {
- base64[2] = '=';
- }
- if (slack < 2) {
- base64[3] = '=';
- }
- return base64;
- }
-
- protected static char getChar(int sixBit) {
- if (sixBit >= 0 && sixBit <= 25) {
- return (char) ('A' + sixBit);
- }
- if (sixBit >= 26 && sixBit <= 51) {
- return (char) ('a' + (sixBit - 26));
- }
- if (sixBit >= 52 && sixBit <= 61) {
- return (char) ('0' + (sixBit - 52));
- }
- if (sixBit == 62) {
- return '+';
- }
- if (sixBit == 63) {
- return '/';
- }
- return '?';
- }
-
- public static byte[] decode(String base64) {
- int pad = 0;
- for (int i = base64.length() - 1; base64.charAt(i) == '='; i--) {
- pad++;
- }
- int length = base64.length() * 6 / 8 - pad;
- byte[] raw = new byte[length];
- int rawIndex = 0;
- for (int i = 0; i < base64.length(); i += 4) {
- int block = (getValue(base64.charAt(i)) << 18) + (getValue(base64.charAt(i + 1)) << 12) + (getValue(base64.charAt(i + 2)) << 6) + (getValue(base64.charAt(i + 3)));
- for (int j = 0; j < 3 && rawIndex + j < raw.length; j++) {
- raw[rawIndex + j] = (byte) ((block >> (8 * (2 - j))) & 0xff);
- }
- rawIndex += 3;
- }
- return raw;
- }
-
- protected static int getValue(char c) {
- if (c >= 'A' && c <= 'Z') {
- return c - 'A';
- }
- if (c >= 'a' && c <= 'z') {
- return c - 'a' + 26;
- }
- if (c >= '0' && c <= '9') {
- return c - '0' + 52;
- }
- if (c == '+') {
- return 62;
- }
- if (c == '/') {
- return 63;
- }
- if (c == '=') {
- return 0;
- }
- return -1;
- }
-
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedGraphWrapper.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedGraphWrapper.java
deleted file mode 100644
index 72e42cd..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedGraphWrapper.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * 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.clerezza.rdf.core.impl.util;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleImmutableGraph;
-import org.apache.clerezza.commons.rdf.BlankNodeOrIRI;
-import org.apache.clerezza.commons.rdf.RDFTerm;
-import org.apache.clerezza.commons.rdf.Triple;
-import org.apache.clerezza.commons.rdf.Graph;
-import org.apache.clerezza.commons.rdf.ImmutableGraph;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.commons.rdf.event.FilterTriple;
-import org.apache.clerezza.commons.rdf.event.GraphListener;
-
-/**
- * Calls the methods of the wrapped <code>Graph</code> as privileged
- * code, because they may need permissions like writing to disk or accessing
- * network.
- *
- * @author mir
- */
-public class PrivilegedGraphWrapper implements Graph {
-
- private Graph graph;
-
- public PrivilegedGraphWrapper(Graph Graph) {
- this.graph = Graph;
- }
-
- @Override
- public Iterator<Triple> filter(final BlankNodeOrIRI subject, final IRI predicate,
- final RDFTerm object) {
- return AccessController.doPrivileged(new PrivilegedAction<Iterator<Triple>>() {
-
- @Override
- public Iterator<Triple> run() {
- return graph.filter(subject, predicate, object);
- }
- });
- }
-
- @Override
- public int size() {
- return AccessController.doPrivileged(new PrivilegedAction<Integer>() {
-
- @Override
- public Integer run() {
- return graph.size();
- }
- });
- }
-
- @Override
- public boolean isEmpty() {
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
- @Override
- public Boolean run() {
- return graph.isEmpty();
- }
- });
- }
-
- @Override
- public boolean contains(final Object o) {
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
- @Override
- public Boolean run() {
- return graph.contains(o);
- }
- });
- }
-
- @Override
- public Iterator<Triple> iterator() {
- return AccessController.doPrivileged(new PrivilegedAction<Iterator<Triple>>() {
-
- @Override
- public Iterator<Triple> run() {
- return graph.iterator();
- }
- });
- }
-
- @Override
- public Object[] toArray() {
- return AccessController.doPrivileged(new PrivilegedAction<Object[]>() {
-
- @Override
- public Object[] run() {
- return graph.toArray();
- }
- });
- }
-
- @Override
- public <T> T[] toArray(final T[] a) {
- return AccessController.doPrivileged(new PrivilegedAction<T[]>() {
-
- @Override
- public T[] run() {
- return graph.toArray(a);
- }
- });
- }
-
- @Override
- public boolean add(final Triple triple) {
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
- @Override
- public Boolean run() {
- return graph.add(triple);
- }
- });
- }
-
- @Override
- public boolean remove(final Object o) {
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
- @Override
- public Boolean run() {
- return graph.remove(o);
- }
- });
- }
-
- @Override
- public boolean containsAll(final Collection<?> c) {
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
- @Override
- public Boolean run() {
- return graph.containsAll(c);
- }
- });
- }
-
- @Override
- public boolean addAll(final Collection<? extends Triple> c) {
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
- @Override
- public Boolean run() {
- return graph.addAll(c);
- }
- });
- }
-
- @Override
- public boolean removeAll(final Collection<?> c) {
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
- @Override
- public Boolean run() {
- return graph.removeAll(c);
- }
- });
- }
-
- @Override
- public boolean retainAll(final Collection<?> c) {
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
- @Override
- public Boolean run() {
- return graph.retainAll(c);
- }
- });
- }
-
- @Override
- public void clear() {
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
-
- @Override
- public Object run() {
- graph.clear();
- return null;
- }
- });
- }
-
- @Override
- public ReadWriteLock getLock() {
- return graph.getLock();
- }
-
- private static class PriviledgedTripleIterator implements Iterator<Triple> {
-
- private final Iterator<Triple> wrappedIterator;
-
- public PriviledgedTripleIterator(Iterator<Triple> wrappedIterator) {
- this.wrappedIterator = wrappedIterator;
- }
-
- @Override
- public boolean hasNext() {
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
- @Override
- public Boolean run() {
- return wrappedIterator.hasNext();
- }
- });
- }
-
- @Override
- public Triple next() {
- return AccessController.doPrivileged(new PrivilegedAction<Triple>() {
-
- @Override
- public Triple run() {
- return wrappedIterator.next();
- }
- });
- }
-
- @Override
- public void remove() {
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
-
- @Override
- public Object run() {
- wrappedIterator.remove();
- return null;
- }
- });
- }
- }
-
-
-
- @Override
- public ImmutableGraph getImmutableGraph() {
- return new SimpleImmutableGraph(this);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedImmuatbleGraphWrapper.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedImmuatbleGraphWrapper.java
deleted file mode 100644
index edc3a14..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedImmuatbleGraphWrapper.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.clerezza.rdf.core.impl.util;
-
-import org.apache.clerezza.commons.rdf.ImmutableGraph;
-
-/**
- * Calls the methods of the wrapped <code>ImmutableGraph</code> as privileged
- * code, because they may need permissions like writing to disk or accessing
- * network.
- *
- * @author mir
- */
-public class PrivilegedImmuatbleGraphWrapper extends PrivilegedGraphWrapper
- implements ImmutableGraph {
-
- public PrivilegedImmuatbleGraphWrapper(ImmutableGraph ImmutableGraph) {
- super(ImmutableGraph);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/SimpleLiteralFactory.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/SimpleLiteralFactory.java
deleted file mode 100644
index c96207a..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/SimpleLiteralFactory.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * 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.clerezza.rdf.core.impl.util;
-
-import org.apache.clerezza.commons.rdf.impl.utils.TypedLiteralImpl;
-import java.math.BigInteger;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.apache.clerezza.rdf.core.InvalidLiteralTypeException;
-import org.apache.clerezza.rdf.core.LiteralFactory;
-import org.apache.clerezza.rdf.core.NoConvertorException;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.impl.util.Base64;
-import org.apache.clerezza.rdf.core.impl.util.W3CDateFormat;
-import org.apache.clerezza.commons.rdf.Literal;
-
-/**
- * An implementation of literal factory currently supporting only
- * byte[]/base64Binary and Java.util.Date/date
- *
- * @author reto
- */
-
-public class SimpleLiteralFactory extends LiteralFactory {
-
- private static final String XSD = "http://www.w3.org/2001/XMLSchema#";
- final private static IRI xsdInteger = xsd("integer");
- final private static IRI xsdInt = xsd("int");
- final private static IRI xsdShort = xsd("short");
- final private static IRI xsdByte = xsd("byte");
- final private static IRI xsdLong = xsd("long");
-
-
- final private static Set<IRI> decimalTypes = new HashSet<IRI>();
-
- final private static Map<Class<?>, TypeConverter<?>> typeConverterMap = new HashMap<Class<?>, TypeConverter<?>>();
- final static Class<? extends byte[]> byteArrayType;
-
- static {
- Collections.addAll(decimalTypes, xsdInteger, xsdInt, xsdByte, xsdShort, xsdLong );
-
- byte[] byteArray = new byte[0];
- byteArrayType = byteArray.getClass();
- typeConverterMap.put(byteArrayType, new ByteArrayConverter());
- typeConverterMap.put(Date.class, new DateConverter());
- typeConverterMap.put(Boolean.class, new BooleanConverter());
- typeConverterMap.put(String.class, new StringConverter());
- typeConverterMap.put(Integer.class, new IntegerConverter());
- typeConverterMap.put(BigInteger.class, new BigIntegerConverter());
- typeConverterMap.put(Long.class, new LongConverter());
- typeConverterMap.put(Double.class, new DoubleConverter());
- typeConverterMap.put(Float.class, new FloatConverter());
- typeConverterMap.put(IRI.class, new UriRefConverter());
- }
-
- final private static IRI xsdDouble =xsd("double");
- final private static IRI xsdFloat =xsd("float");
- final private static IRI xsdAnyURI =xsd("anyURI");
-
- final private static IRI xsd(String name) {
- return new IRI(XSD+name);
- }
-
- private static interface TypeConverter<T> {
- Literal createLiteral(T value);
- T createObject(Literal literal);
- }
-
- private static class ByteArrayConverter implements TypeConverter<byte[]> {
-
- private static final IRI base64Uri =xsd("base64Binary");
-
- @Override
- public Literal createLiteral(byte[] value) {
- return new TypedLiteralImpl(Base64.encode((byte[]) value), base64Uri);
- }
-
- @Override
- public byte[] createObject(Literal literal) {
- if (!literal.getDataType().equals(base64Uri)) {
- throw new InvalidLiteralTypeException(byteArrayType, literal.getDataType());
- }
- return (byte[])Base64.decode(literal.getLexicalForm());
- }
-
-
- }
- private static class DateConverter implements TypeConverter<Date> {
-
- private static final IRI dateTimeUri =xsd("dateTime");
- private static final DateFormat DATE_FORMAT = new W3CDateFormat();
-
- @Override
- public Literal createLiteral(Date value) {
- return new TypedLiteralImpl(DATE_FORMAT.format(value), dateTimeUri);
- }
-
- @Override
- public Date createObject(Literal literal) {
- if (!literal.getDataType().equals(dateTimeUri)) {
- throw new InvalidLiteralTypeException(Date.class, literal.getDataType());
- }
- try {
- return DATE_FORMAT.parse(literal.getLexicalForm());
- } catch (ParseException ex) {
- throw new RuntimeException("Exception parsing literal as date", ex);
- }
- }
-
-
- }
-
- private static class BooleanConverter implements TypeConverter<Boolean> {
-
- private static final IRI booleanUri =xsd("boolean");
- public static final TypedLiteralImpl TRUE = new TypedLiteralImpl("true", booleanUri);
- public static final TypedLiteralImpl FALSE = new TypedLiteralImpl("false", booleanUri);
-
- @Override
- public Literal createLiteral(Boolean value) {
- if (value) return TRUE;
- else return FALSE;
- }
-
- @Override
- public Boolean createObject(Literal literal) {
- if (literal == TRUE) return true;
- else if (literal == FALSE) return false;
- else if (!literal.getDataType().equals(booleanUri)) {
- throw new InvalidLiteralTypeException(Boolean.class, literal.getDataType());
- }
- return Boolean.valueOf(literal.getLexicalForm());
- }
- }
-
- private static class StringConverter implements TypeConverter<String> {
-
- private static final IRI stringUri =xsd("string");
-
- @Override
- public Literal createLiteral(String value) {
- return new TypedLiteralImpl(value, stringUri);
- }
-
- @Override
- public String createObject(Literal literal) {
- if (!literal.getDataType().equals(stringUri)) {
- throw new InvalidLiteralTypeException(String.class, literal.getDataType());
- }
- return literal.getLexicalForm();
- }
- }
-
- private static class IntegerConverter implements TypeConverter<Integer> {
-
-
- @Override
- public Literal createLiteral(Integer value) {
- return new TypedLiteralImpl(value.toString(), xsdInt);
- }
-
- @Override
- public Integer createObject(Literal literal) {
- if (!decimalTypes.contains(literal.getDataType())) {
- throw new InvalidLiteralTypeException(Integer.class, literal.getDataType());
- }
- return new Integer(literal.getLexicalForm());
- }
- }
-
- private static class LongConverter implements TypeConverter<Long> {
-
-
-
- @Override
- public Literal createLiteral(Long value) {
- return new TypedLiteralImpl(value.toString(), xsdLong);
- }
-
- @Override
- public Long createObject(Literal literal) {
- if (!decimalTypes.contains(literal.getDataType())) {
- throw new InvalidLiteralTypeException(Long.class, literal.getDataType());
- }
- return new Long(literal.getLexicalForm());
- }
- }
-
-
- private static class FloatConverter implements TypeConverter<Float> {
-
- @Override
- public Literal createLiteral(Float value) {
- return new TypedLiteralImpl(value.toString(), xsdFloat);
- }
-
- @Override
- public Float createObject(Literal literal) {
- if (!literal.getDataType().equals(xsdFloat)) {
- throw new InvalidLiteralTypeException(Float.class, literal.getDataType());
- }
- return Float.valueOf(literal.getLexicalForm());
- }
- }
-
- private static class DoubleConverter implements TypeConverter<Double> {
-
-
-
- @Override
- public Literal createLiteral(Double value) {
- return new TypedLiteralImpl(value.toString(), xsdDouble);
- }
-
- @Override
- public Double createObject(Literal literal) {
- if (!literal.getDataType().equals(xsdDouble)) {
- throw new InvalidLiteralTypeException(Double.class, literal.getDataType());
- }
- return new Double(literal.getLexicalForm());
- }
- }
-
- private static class BigIntegerConverter implements TypeConverter<BigInteger> {
-
-
-
- @Override
- public Literal createLiteral(BigInteger value) {
- return new TypedLiteralImpl(value.toString(), xsdInteger);
- }
-
- @Override
- public BigInteger createObject(Literal literal) {
- if (!literal.getDataType().equals(xsdInteger)) {
- throw new InvalidLiteralTypeException(Double.class, literal.getDataType());
- }
- return new BigInteger(literal.getLexicalForm());
- }
- }
-
- private static class UriRefConverter implements TypeConverter<IRI> {
-
-
-
- @Override
- public Literal createLiteral(IRI value) {
- return new TypedLiteralImpl(value.getUnicodeString(), xsdAnyURI);
- }
-
- @Override
- public IRI createObject(Literal literal) {
- if (!literal.getDataType().equals(xsdAnyURI)) {
- throw new InvalidLiteralTypeException(IRI.class, literal.getDataType());
- }
- return new IRI(literal.getLexicalForm());
- }
- }
-
-
- @SuppressWarnings("unchecked")
- @Override
- public Literal createTypedLiteral(Object value) throws NoConvertorException {
- TypeConverter converter = getConverterFor(value.getClass());
- return converter.createLiteral(value);
- }
-
-
-
- @Override
- public <T> T createObject(Class<T> type, Literal literal)
- throws NoConvertorException, InvalidLiteralTypeException {
- final TypeConverter<T> converter = getConverterFor(type);
- return converter.createObject(literal);
-
- }
-
- @SuppressWarnings("unchecked")
- private <T> TypeConverter<T> getConverterFor(Class<T> type) throws NoConvertorException {
- TypeConverter<T> convertor = (TypeConverter<T>) typeConverterMap.get(type);
- if (convertor != null) {
- return convertor;
- }
- for (Map.Entry<Class<?>, TypeConverter<?>> converterEntry : typeConverterMap.entrySet()) {
- if (type.isAssignableFrom(converterEntry.getKey())) {
- return (TypeConverter<T>) converterEntry.getValue();
- }
- }
- throw new NoConvertorException(type);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/W3CDateFormat.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/W3CDateFormat.java
deleted file mode 100644
index 6de2906..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/impl/util/W3CDateFormat.java
+++ /dev/null
@@ -1,196 +0,0 @@
-//taken from GVS MillisDateFormat.java, modified to support different precision
-
-/*
- (c) Copyright 2005, 2006, Hewlett-Packard Development Company, LP
- [See end of file]
- $Id: W3CDateFormat.java,v 1.6 2007/05/07 18:45:22 rebach Exp $
- */
-package org.apache.clerezza.rdf.core.impl.util;
-/*
- *
- * 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.
- *
-*/
-
-
-import java.text.DateFormat;
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.SimpleTimeZone;
-import java.util.TimeZone;
-
-/**
- * @author reto implements http://www.w3.org/TR/NOTE-datetime with the
- * limitation that it expects exactly a three digits decimal fraction of
- * seconds. if a time zone designator other than 'Z' is present it must
- * contain a column
- */
-public class W3CDateFormat extends DateFormat {
- /**
- * An instance of this class
- */
- public static final W3CDateFormat instance = new W3CDateFormat();
-
- private static final SimpleDateFormat dateFormatWithMillis = new SimpleDateFormat(
- "yyyy-MM-dd'T'HH:mm:ss.SSSZ");
- private static final SimpleDateFormat dateFormatNoMillis = new SimpleDateFormat(
- "yyyy-MM-dd'T'HH:mm:ssZ");
-
- private static final long serialVersionUID = 3258407344076372025L;
-
- private static final TimeZone utcTZ = new SimpleTimeZone(0, "UTC");
-
- static {
- dateFormatWithMillis.setTimeZone(utcTZ);
- dateFormatNoMillis.setTimeZone(utcTZ);
- }
-
- @Override
- public void setTimeZone(TimeZone zone) {
- super.setTimeZone(zone);
- }
-
-
- /**
- * @see java.text.DateFormat#format(java.util.Date, java.lang.StringBuffer,
- * java.text.FieldPosition)
- */
- @Override
- public StringBuffer format(Date date, StringBuffer toAppendTo,
- FieldPosition fieldPosition) {
-
- final DateFormat dateFormat = (date.getTime() % 1000) == 0 ?
- dateFormatNoMillis : dateFormatWithMillis;
- String string = dateFormat.format(date);
- if (string.endsWith("0000")) {
- StringBuffer result = new StringBuffer(string.substring(0, string.length()-5));
- result.append('Z');
- return result;
- } else {
- StringBuffer result = new StringBuffer(string);
- result.insert(string.length() - 2, ':');
- return result;
- }
- }
-
- /**
- * @see java.text.DateFormat#parse(java.lang.String,
- * java.text.ParsePosition)
- */
- public Date parse(String dateString, ParsePosition parsePos) {
-
- int position = parsePos.getIndex();
-
- int y1 = dateString.charAt(position++) - '0';
- int y2 = dateString.charAt(position++) - '0';
- int y3 = dateString.charAt(position++) - '0';
- int y4 = dateString.charAt(position++) - '0';
- int year = 1000 * y1 + 100 * y2 + 10 * y3 + y4;
- position++; // skip '-'
- int m1 = dateString.charAt(position++) - '0';
- int m2 = dateString.charAt(position++) - '0';
- int month = 10 * m1 + m2;
- position++; // skip '-'
- int d1 = dateString.charAt(position++) - '0';
- int d2 = dateString.charAt(position++) - '0';
- int day = 10 * d1 + d2;
- position++; // skip 'T'
- int h1 = dateString.charAt(position++) - '0';
- int h2 = dateString.charAt(position++) - '0';
- int hour = 10 * h1 + h2;
- position++; // skip ':'
- int min1 = dateString.charAt(position++) - '0';
- int min2 = dateString.charAt(position++) - '0';
- int minutes = 10 * min1 + min2;
- position++; // skip ':'
- int s1 = dateString.charAt(position++) - '0';
- int s2 = dateString.charAt(position++) - '0';
- int secs = 10 * s1 + s2;
- Calendar resultCalendar = new GregorianCalendar(year, month - 1, day,
- hour, minutes, secs);
- resultCalendar.setTimeZone(utcTZ);
- char afterSecChar = dateString.charAt(position++);
- int msecs = 0;
- char tzd1;
- if (afterSecChar == '.') {
- int startPos = position;
- //read decimal part, this is till there is a 'Z', a '+' or a '-'
- char nextChar = dateString.charAt(position++);
- while ((nextChar != 'Z') && (nextChar != '-') && (nextChar != '+')) {
- msecs += (nextChar - '0')*Math.pow(10, 3+startPos-position);
- nextChar = dateString.charAt(position++);
- }
- tzd1 = nextChar;
- } else {
- tzd1 = afterSecChar;
- }
- long timeInMillis = resultCalendar.getTimeInMillis() + msecs;
- if (tzd1 != 'Z') {
- int htz1 = dateString.charAt(position++) - '0';
- int htz2 = dateString.charAt(position++) - '0';
- int hourtz = 10 * htz1 + htz2;
- position++; // skip ':'
- int mintz1 = dateString.charAt(position++) - '0';
- int mintz2 = dateString.charAt(position++) - '0';
- int minutestz = 10 * mintz1 + mintz2;
- int offSetInMillis = (hourtz * 60 + minutestz) * 60000;
- if (tzd1 == '+') {
- timeInMillis -= offSetInMillis;
- } else {
- timeInMillis += offSetInMillis;
- }
- }
- parsePos.setIndex(position);
- return new Date(timeInMillis);
-
- }
-}
-
-/*
- * (c) Copyright 2005, 2006 Hewlett-Packard Development Company, LP All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/NoQueryEngineException.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/NoQueryEngineException.java
deleted file mode 100644
index f75676d..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/NoQueryEngineException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql;
-
-/**
- * Indicates that there is no available query engine for resolving a query.
- *
- * @author rbn
- */
-public class NoQueryEngineException extends RuntimeException {
-
- /**
- * Creates a new instance of <code>NoQueryEngineException</code> without detail message.
- */
- public NoQueryEngineException() {
- }
-
-
- /**
- * Constructs an instance of <code>NoQueryEngineException</code> with the specified detail message.
- * @param msg the detail message.
- */
- public NoQueryEngineException(String msg) {
- super(msg);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryEngine.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryEngine.java
deleted file mode 100644
index 0fb56bf..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryEngine.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql;
-
-import org.apache.clerezza.commons.rdf.Graph;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.sparql.query.Query;
-
-/**
- * A QueryEngine can process SPARQL queries against an arbitrary set of graphs.
- *
- * @author rbn
- */
-public interface QueryEngine {
-
- /**
- * Executes any sparql query. The type of the result object will vary
- * depending on the type of the query.
- *
- * @param tcManager
- * where the query originates.
- * @param defaultGraph
- * the default ImmutableGraph against which to execute the query if no
- * FROM clause is present
- * @param query
- * Query object to be executed
- * @return the resulting ResultSet, ImmutableGraph or Boolean value
- */
- @Deprecated
- public Object execute(TcManager tcManager, Graph defaultGraph,
- Query query);
-
- /**
- * Executes any sparql query. The type of the result object will vary
- * depending on the type of the query.
- *
- * @param tcManager
- * where the query originates.
- * @param defaultGraph
- * the default ImmutableGraph against which to execute the query if no
- * FROM clause is present
- * @param query
- * string to be executed.
- * @return the resulting ResultSet, ImmutableGraph or Boolean value
- */
- public Object execute(TcManager tcManager, Graph defaultGraph,
- String query);
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryParser.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryParser.java
deleted file mode 100644
index 8d76c48..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryParser.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql;
-
-import java.io.StringReader;
-import org.apache.clerezza.rdf.core.sparql.query.Query;
-import org.osgi.service.component.annotations.Component;
-
-/**
- * This class implements an OSGi service to provide a method to parse a
- * SPARQL query and generate a {@link Query} object.
- *
- * @author hasan
- */
-
-@Component(service = QueryParser.class)
-public class QueryParser {
-
- private static volatile QueryParser instance;
- public QueryParser() {
- QueryParser.instance = this;
- }
-
- /**
- * Returns an instance of this class.
- * This method is provided due to backward compatibility.
- */
- public static QueryParser getInstance() {
- if (instance == null) {
- synchronized (QueryParser.class) {
- if (instance == null) {
- new QueryParser();
- }
- }
- }
- return instance;
- }
-
- /**
- * Parses a SPARQL query string into a {@link Query} object.
- *
- * @param queryString
- * SPARQL query string
- * @return
- * {@link Query} object corresponding to the specified query string
- *
- * @throws org.apache.clerezza.rdf.core.sparql.ParseException
- */
- public Query parse(final String queryString) throws ParseException {
- JavaCCGeneratedQueryParser parser = new JavaCCGeneratedQueryParser(
- new StringReader(queryString));
- return parser.parse();
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/ResultSet.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/ResultSet.java
deleted file mode 100644
index 1d2e377..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/ResultSet.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * The reult of a sparql SELECT-query. This corresponds to a Solution Sequence
- * as per section 12.1.6 of http://www.w3.org/TR/rdf-sparql-query/.
- *
- * Note that the scope of blank nodes is the reult set and not the
- * Graph from where they originate.
- *
- * @author rbn
- */
-public interface ResultSet extends Iterator<SolutionMapping> {
-
- /** Iterate over the variable names (strings) in this QuerySolution.
- * @return Iterator of strings
- */
- public List<String> getResultVars() ;
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/SolutionMapping.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/SolutionMapping.java
deleted file mode 100644
index 60d1805..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/SolutionMapping.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql;
-
-import org.apache.clerezza.rdf.core.sparql.query.Variable;
-import java.util.Map;
-import org.apache.clerezza.commons.rdf.RDFTerm;
-
-/**
- * A set of mapping from variable names to solutions.
- *
- * a variable name has the form: ( PN_CHARS_U | [0-9] ) ( PN_CHARS_U | [0-9]
- * | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040] )*
- * where PN_CHARS_U = [A-Z] | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6]
- * | [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | [#x200C-#x200D]
- * | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF]
- * | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] | '_'
- *
- *
- * @author rbn
- */
-public interface SolutionMapping extends Map<Variable, RDFTerm> {
-
- /**
- * Should be the equivalent to this:
- * public Resource get(String name) {
- * return get(new Variable(name));
- * }
- *
- * @param name
- * @return
- */
- public RDFTerm get(String name);
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParser.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParser.java
deleted file mode 100644
index c856ea8..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParser.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql;
-
-import java.io.StringReader;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.access.TcProvider;
-import org.apache.clerezza.rdf.core.sparql.query.AlternativeGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.DataSet;
-import org.apache.clerezza.rdf.core.sparql.query.GraphGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.GraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.MinusGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.OptionalGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.Query;
-import org.apache.clerezza.rdf.core.sparql.query.SparqlUnit;
-import org.apache.clerezza.rdf.core.sparql.update.Update;
-
-/**
- * This class implements an OSGi service to provide a method to obtain referred Graphs in a SPARQL Query or Update.
- *
- * @author hasan
- */
-
-
-public class SparqlPreParser {
-
- TcProvider tcProvider;
-
- public SparqlPreParser() {
- }
-
- public SparqlPreParser(TcProvider tcProvider) {
- this.tcProvider = tcProvider;
- }
-
- /**
- * This returns the graphs targeted by the queryString. These are the
- * triple collections explicitly referred in FROM and FROM NAMED clauses,
- * and if the queryString contains no FROM clause the defaultGraph.
- *
- * For queries that are not limited to a specified set of graphs, null is returned.
- *
- * @param queryString
- * @param defaultGraph
- * @return
- * @throws ParseException
- */
- public Set<IRI> getReferredGraphs(String queryString, IRI defaultGraph) throws ParseException {
- Set<IRI> referredGraphs;
- JavaCCGeneratedSparqlPreParser parser = new JavaCCGeneratedSparqlPreParser(new StringReader(queryString));
- SparqlUnit sparqlUnit;
- sparqlUnit = parser.parse();
- boolean referringVariableNamedGraph = false;
- if (sparqlUnit.isQuery()) {
- Query q = sparqlUnit.getQuery();
- DataSet dataSet = q.getDataSet();
- if (dataSet != null) {
- referredGraphs = dataSet.getDefaultGraphs();
- referredGraphs.addAll(dataSet.getNamedGraphs());
- } else {
- referredGraphs = new HashSet<IRI>();
- }
- GroupGraphPattern queryPattern = q.getQueryPattern();
- if (queryPattern != null) {
- Set<GraphPattern> graphPatterns = queryPattern.getGraphPatterns();
- for (GraphPattern graphPattern : graphPatterns) {
- }
- }
-// referringVariableNamedGraph = q.referringVariableNamedGraph();
- referringVariableNamedGraph = referringVariableNamedGraph(q);
- } else {
- Update u = sparqlUnit.getUpdate();
- referredGraphs = u.getReferredGraphs(defaultGraph, tcProvider);
- }
- if (referredGraphs.isEmpty()) {
- if (referringVariableNamedGraph) {
- return null;
- }
- referredGraphs.add(defaultGraph);
- }
- return referredGraphs;
- }
-
- private boolean referringVariableNamedGraph(Query query) {
- GroupGraphPattern queryPattern = query.getQueryPattern();
- if (queryPattern == null) {
- return false;
- }
- Set<GraphPattern> graphPatterns = queryPattern.getGraphPatterns();
- return referringVariableNamedGraph(graphPatterns);
- }
-
- private boolean referringVariableNamedGraph(Set<GraphPattern> graphPatterns) {
- boolean referringVariableNamedGraph = false;
- for (GraphPattern graphPattern : graphPatterns) {
- if (referringVariableNamedGraph(graphPattern)) {
- referringVariableNamedGraph = true;
- break;
- }
- }
- return referringVariableNamedGraph;
- }
-
- private boolean referringVariableNamedGraph(GraphPattern graphPattern) {
- if (graphPattern instanceof GraphGraphPattern) {
- return ((GraphGraphPattern) graphPattern).getGraph().isVariable();
- }
- if (graphPattern instanceof AlternativeGraphPattern) {
- List<GroupGraphPattern> alternativeGraphPatterns =
- ((AlternativeGraphPattern) graphPattern).getAlternativeGraphPatterns();
- boolean referringVariableNamedGraph = false;
- for (GroupGraphPattern groupGraphPattern : alternativeGraphPatterns) {
- if (referringVariableNamedGraph(groupGraphPattern)) {
- referringVariableNamedGraph = true;
- break;
- }
- }
- return referringVariableNamedGraph;
- }
- if (graphPattern instanceof OptionalGraphPattern) {
- GraphPattern mainGraphPattern = ((OptionalGraphPattern) graphPattern).getMainGraphPattern();
- if (referringVariableNamedGraph(mainGraphPattern)) {
- return true;
- }
- GroupGraphPattern optionalGraphPattern = ((OptionalGraphPattern) graphPattern).getOptionalGraphPattern();
- return referringVariableNamedGraph(optionalGraphPattern);
- }
- if (graphPattern instanceof MinusGraphPattern) {
- GraphPattern minuendGraphPattern = ((MinusGraphPattern) graphPattern).getMinuendGraphPattern();
- if (referringVariableNamedGraph(minuendGraphPattern)) {
- return true;
- }
- GroupGraphPattern subtrahendGraphPattern = ((MinusGraphPattern) graphPattern).getSubtrahendGraphPattern();
- return referringVariableNamedGraph(subtrahendGraphPattern);
- }
- if (graphPattern instanceof GroupGraphPattern) {
- GroupGraphPattern groupGraphPattern = (GroupGraphPattern) graphPattern;
- if (groupGraphPattern.isSubSelect()) {
- Query query = ((GroupGraphPattern) graphPattern).getSubSelect();
- return referringVariableNamedGraph(query);
- } else {
- Set<GraphPattern> graphPatterns = ((GroupGraphPattern) graphPattern).getGraphPatterns();
- return referringVariableNamedGraph(graphPatterns);
- }
- }
- return false;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/StringQuerySerializer.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/StringQuerySerializer.java
deleted file mode 100644
index c48100b..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/StringQuerySerializer.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql;
-
-import org.apache.clerezza.rdf.core.sparql.query.AskQuery;
-import org.apache.clerezza.rdf.core.sparql.query.ConstructQuery;
-import org.apache.clerezza.rdf.core.sparql.query.DescribeQuery;
-import org.apache.clerezza.rdf.core.sparql.query.Query;
-import org.apache.clerezza.rdf.core.sparql.query.SelectQuery;
-
-/**
- * This abstract class provides a method to generate a {@link String}
- * representation of a {@link Query}.
- *
- * @author hasan
- */
-public abstract class StringQuerySerializer {
-
- /**
- * Serializes a {@link Query} object to a {@link String}.
- *
- * @param query
- * the Query object to be serialized
- * @return
- * a String representation of the specified Query object.
- */
- public String serialize(Query query) {
- if (query instanceof SelectQuery) {
- return serialize((SelectQuery) query);
- } else if (query instanceof ConstructQuery) {
- return serialize((ConstructQuery) query);
- } else if (query instanceof DescribeQuery) {
- return serialize((DescribeQuery) query);
- } else {
- return serialize((AskQuery) query);
- }
- }
-
- /**
- * Serializes a {@link SelectQuery} object to a {@link String}.
- *
- * @param selectQuery
- * the SelectQuery object to be serialized
- * @return
- * a String representation of the specified SelectQuery object.
- */
- public abstract String serialize(SelectQuery selectQuery);
-
- /**
- * Serializes a {@link ConstructQuery} object to a {@link String}.
- *
- * @param constructQuery
- * the ConstructQuery object to be serialized
- * @return
- * a String representation of the specified ConstructQuery object.
- */
- public abstract String serialize(ConstructQuery constructQuery);
-
- /**
- * Serializes a {@link DescribeQuery} object to a {@link String}.
- *
- * @param describeQuery
- * the DescribeQuery object to be serialized
- * @return
- * a String representation of the specified DescribeQuery object.
- */
- public abstract String serialize(DescribeQuery describeQuery);
-
- /**
- * Serializes an {@link AskQuery} object to a {@link String}.
- *
- * @param askQuery
- * the AskQuery object to be serialized
- * @return
- * a String representation of the specified AskQuery object.
- */
- public abstract String serialize(AskQuery askQuery);
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java
deleted file mode 100644
index fe90f16..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AbstractOperation.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * Defines an operation in an {@link Expression}. An operation has an operator
- * and one or more operands.
- *
- * @author hasan
- */
-public abstract class AbstractOperation implements Expression {
- private String operator;
-
- public AbstractOperation(String operator) {
- this.operator = operator;
- }
-
- /**
- * A string representation of the operator
- * @return The operator as a string
- */
- public String getOperatorString() {
- return operator;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AlternativeGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AlternativeGraphPattern.java
deleted file mode 100644
index 1e1424d..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AlternativeGraphPattern.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.List;
-
-/**
- * Defines alternative ImmutableGraph patterns.
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#alternatives">
- * SPARQL Query Language: 7 Matching Alternatives</a>
- *
- * @author hasan
- */
-public interface AlternativeGraphPattern extends GraphPattern {
-
- /**
- *
- * @return
- * a list of alternative {@link GroupGraphPattern}s
- */
- public List<GroupGraphPattern> getAlternativeGraphPatterns();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AskQuery.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AskQuery.java
deleted file mode 100644
index 66ce9ce..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/AskQuery.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * <p>This interface represents a SPARQL ASK query.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#ask">
- * SPARQL Query Language: 10.3 ASK</a>
- *
- * @author hasan
- */
-public interface AskQuery extends Query {
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BasicGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BasicGraphPattern.java
deleted file mode 100644
index c3ea802..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BasicGraphPattern.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.Set;
-
-/**
- * Defines a basic ImmutableGraph pattern.
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#BasicGraphPatterns">
- * SPARQL Query Language: 5.1 Basic ImmutableGraph Patterns</a>
- *
- * @author hasan
- */
-public interface BasicGraphPattern extends GraphPattern {
-
- /**
- *
- * @return a set of all triple patterns to match.
- */
- public Set<TriplePattern> getTriplePatterns();
-
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryOperation.java
deleted file mode 100644
index bd6b0df..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryOperation.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * Defines an operation with two operands: a left hand side and a right hand side
- * operand.
- *
- * @author hasan
- */
-public class BinaryOperation extends AbstractOperation {
-
- private Expression lhsOperand;
- private Expression rhsOperand;
-
- public BinaryOperation(String operator,
- Expression lhsOperand, Expression rhsOperand) {
- super(operator);
- this.lhsOperand = lhsOperand;
- this.rhsOperand = rhsOperand;
- }
-
- public Expression getLhsOperand() {
- return lhsOperand;
- }
-
- public Expression getRhsOperand() {
- return rhsOperand;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryPropertyPathOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryPropertyPathOperation.java
deleted file mode 100644
index 966b66c..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BinaryPropertyPathOperation.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- *
- * @author hasan
- */
-public class BinaryPropertyPathOperation implements PropertyPathExpression {
- private String operator;
- private PropertyPathExpression lhsOperand;
- private PropertyPathExpression rhsOperand;
-
- public BinaryPropertyPathOperation(String operator, PropertyPathExpression lhsOperand, PropertyPathExpression rhsOperand) {
- this.operator = operator;
- this.lhsOperand = lhsOperand;
- this.rhsOperand = rhsOperand;
- }
-
- public PropertyPathExpression getLhsOperand() {
- return lhsOperand;
- }
-
- public PropertyPathExpression getRhsOperand() {
- return rhsOperand;
- }
-
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BuiltInCall.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BuiltInCall.java
deleted file mode 100644
index 0a66c0b..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/BuiltInCall.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.List;
-
-/**
- * Defines a built-in call which is one form of {@link Expression}.
- * A built-in call has a name of type String and a list of arguments,
- * where each argument is an {@link Expression}.
- *
- * @author hasan
- */
-public class BuiltInCall implements Expression {
-
- protected String name;
- private final List<Expression> arguments;
-
- public BuiltInCall(String name, List<Expression> arguments) {
- this.name = name;
- this.arguments = arguments;
- }
-
- public String getName() {
- return name;
- };
-
- public List<Expression> getArguements() {
- return arguments;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ConstructQuery.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ConstructQuery.java
deleted file mode 100644
index dcded73..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ConstructQuery.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.Set;
-
-/**
- * <p>This interface represents a SPARQL CONSTRUCT query.</p>
- *
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#construct">
- * SPARQL Query Language: 10.2 CONSTRUCT</a>
- *
- * @author hasan
- */
-public interface ConstructQuery extends QueryWithSolutionModifier {
-
- /**
- * <p>Gets the template for constructing triples in a CONSTRUCT query.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#construct">
- * SPARQL Query Language: 10.2 CONSTRUCT</a>
- * @return a template as a set of triple patterns for constructing
- * new triples.
- */
- public Set<TriplePattern> getConstructTemplate();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/DataSet.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/DataSet.java
deleted file mode 100644
index 649b883..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/DataSet.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-
-/**
- * This interface definition is not yet stable and may change in future.
- *
- * @author hasan
- */
-public interface DataSet {
-
- /**
- *
- * @return
- * an empty set if no default ImmutableGraph is specified,
- * otherwise a set of their UriRefs
- */
- public Set<IRI> getDefaultGraphs();
-
- /**
- *
- * @return
- * an empty set if no named ImmutableGraph is specified,
- * otherwise a set of their UriRefs
- */
- public Set<IRI> getNamedGraphs();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/DescribeQuery.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/DescribeQuery.java
deleted file mode 100644
index a5fbbb2..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/DescribeQuery.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.List;
-
-/**
- * <p>This interface represents a SPARQL SELECT query.</p>
- *
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#describe">
- * SPARQL Query Language: 10.4 DESCRIBE (Informative)</a>
- *
- * @author hasan
- */
-public interface DescribeQuery extends QueryWithSolutionModifier {
-
- /**
- * <p>Tests if all variables in the query should be described.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#describe">
- * SPARQL Query Language: 10.4 DESCRIBE (Informative)</a>
- * @return <code>true</code> if the query should return all variables.
- */
- public boolean isDescribeAll();
-
- /**
- * <p>Gets the list of {@link ResourceOrVariable}s to describe.
- * If {@link #isDescribeAll()} returns <code>true</code> then
- * this list contains all the variables from the query.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#describe">
- * SPARQL Query Language: 10.4 DESCRIBE (Informative)</a>
- * @return A list of {@link ResourceOrVariable}s to describe.
- */
- public List<ResourceOrVariable> getResourcesToDescribe();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Expression.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Expression.java
deleted file mode 100644
index 97510dc..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Expression.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.io.Serializable;
-
-/**
- * This interface models logical, relational, and numeric expression.
- * This includes terms and factors in mathematical formulas which can contain
- * variables, literals, and function calls.
- * In a SPARQL query, expressions can occur in an ORDER BY clause or
- * a FILTER constraint.
- *
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#modOrderBy">
- * SPARQL Query Language: 9.1 ORDER BY</a>
- *
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#termConstraint">
- * SPARQL Query Language: 3 RDF Term Constraints (Informative)</a>
- *
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#evaluation">
- * SPARQL Query Language: 11.2 Filter Evaluation</a>
- *
- * @author hasan
- */
-public interface Expression extends Serializable {
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/FunctionCall.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/FunctionCall.java
deleted file mode 100644
index 39e2161..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/FunctionCall.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.List;
-import org.apache.clerezza.commons.rdf.IRI;
-
-/**
- * Defines a function call which is one form of {@link Expression}.
- * A function call has a name of type {@link IRI} and a list of arguments,
- * where each argument is an {@link Expression}.
- *
- * @author hasan
- */
-public class FunctionCall implements Expression {
-
- private final IRI name;
- private final List<Expression> arguments;
-
- public FunctionCall(IRI name, List<Expression> arguments) {
- this.name = name;
- this.arguments = arguments;
- }
-
- public IRI getName() {
- return name;
- };
-
- public List<Expression> getArguements() {
- return arguments;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphGraphPattern.java
deleted file mode 100644
index 0a4844d..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphGraphPattern.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * Defines a ImmutableGraph ImmutableGraph pattern.
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#queryDataset">
- * SPARQL Query Language: 8.3 Querying the Dataset</a>
- *
- * @author hasan
- */
-public interface GraphGraphPattern extends GraphPattern {
-
- /**
- *
- * @return a {@link UriRefOrVariable} which specifies the ImmutableGraph
- * against which the pattern should match.
- */
- public UriRefOrVariable getGraph();
-
- /**
- *
- * @return the pattern to match.
- */
- public GroupGraphPattern getGroupGraphPattern();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphPattern.java
deleted file mode 100644
index eca02f2..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GraphPattern.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * This is the generic interface for all types of ImmutableGraph patterns:
- * {@link BasicGraphPattern}, {@link PathSupportedBasicGraphPattern}, {@link GroupGraphPattern},
- * {@link GraphGraphPattern}, {@link AlternativeGraphPattern}, and
- * {@link OptionalGraphPattern}
- *
- * @author hasan
- */
-public interface GraphPattern {
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GroupGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GroupGraphPattern.java
deleted file mode 100644
index da13f13..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/GroupGraphPattern.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.List;
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-
-/**
- * Defines a group ImmutableGraph pattern.
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#GroupPatterns">
- * SPARQL Query Language: 5.2 Group ImmutableGraph Patterns</a>
- *
- * @author hasan
- */
-public interface GroupGraphPattern extends GraphPattern {
-
- /**
- *
- * @return
- * true if it wraps a {@link SelectQuery}, false otherwise.
- */
- public boolean isSubSelect();
-
- /**
- *
- * @return
- * the wrapped subselect if it wraps a {@link SelectQuery}, null otherwise.
- */
- public SelectQuery getSubSelect();
-
- /**
- *
- * @return
- * null if it wraps a {@link SelectQuery}, otherwise
- * a set of all patterns, ANDed together.
- */
- public Set<GraphPattern> getGraphPatterns();
-
- /**
- *
- * @return
- * all graphs referred in this ImmutableGraph pattern.
- */
- public Set<IRI> getReferredGraphs();
-
- /**
- * @return
- * null if it wraps a {@link SelectQuery}, otherwise
- * a list of filter expressions for all patterns in the group if any.
- */
- public List<Expression> getFilter();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/InlineData.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/InlineData.java
deleted file mode 100644
index 3040813..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/InlineData.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.List;
-import org.apache.clerezza.commons.rdf.RDFTerm;
-
-/**
- *
- * @author hasan
- */
-public interface InlineData extends GraphPattern {
- public List<Variable> getVariables();
- public List<List<RDFTerm>> getValues();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/LiteralExpression.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/LiteralExpression.java
deleted file mode 100644
index c564b09..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/LiteralExpression.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import org.apache.clerezza.commons.rdf.Literal;
-
-/**
- * Wraps a {@link Literal} in an {@link Expression}.
- *
- * @author hasan
- */
-public class LiteralExpression implements Expression {
-
- private final Literal literal;
-
- public LiteralExpression(Literal literal) {
- this.literal = literal;
- }
-
- public Literal getLiteral() {
- return literal;
- }
-
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/MinusGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/MinusGraphPattern.java
deleted file mode 100644
index 73a27f5..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/MinusGraphPattern.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- *
- * @author hasan
- */
-public interface MinusGraphPattern extends GraphPattern {
-
- /**
- *
- * @return
- * the minuend ImmutableGraph pattern to match
- */
- public GraphPattern getMinuendGraphPattern();
-
- /**
- *
- * @return
- * the subtrahend ImmutableGraph pattern to match
- */
- public GroupGraphPattern getSubtrahendGraphPattern();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/OptionalGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/OptionalGraphPattern.java
deleted file mode 100644
index 0bca8aa..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/OptionalGraphPattern.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * Specifying an optional ImmutableGraph pattern implies the existence of a main ImmutableGraph
- * pattern.
- * The main ImmutableGraph pattern is an empty group pattern if it is not specified.
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#optionals">
- * SPARQL Query Language: 6 Including Optional Values</a>
- *
- * @author hasan
- */
-public interface OptionalGraphPattern extends GraphPattern {
-
- /**
- *
- * @return
- * the main ImmutableGraph pattern to match
- */
- public GraphPattern getMainGraphPattern();
-
- /**
- *
- * @return
- * the optional ImmutableGraph pattern to match
- */
- public GroupGraphPattern getOptionalGraphPattern();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/OrderCondition.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/OrderCondition.java
deleted file mode 100644
index 5fd062f..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/OrderCondition.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * Defines an order condition in an ORDER BY clause.
- *
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#modOrderBy">
- * SPARQL Query Language: 9.1 ORDER BY</a>
- *
- * @author hasan
- */
-public interface OrderCondition {
-
- public Expression getExpression();
-
- /**
- * @return <code>true</code> if ascending, <code>false</code> if descending
- */
- public boolean isAscending();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PathSupportedBasicGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PathSupportedBasicGraphPattern.java
deleted file mode 100644
index f71b10d..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PathSupportedBasicGraphPattern.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.Set;
-
-/**
- * Defines a basic ImmutableGraph pattern that supports property path expressions.
- * A {@link PathSupportedBasicGraphPattern} is a set of {@link PropertyPathPattern}s.
- * A {@link PropertyPathPattern} is a generalization of a {@link TriplePattern} to include
- * a {@link PropertyPathExpression} in the property position.
- * Therefore, a {@link PathSupportedBasicGraphPattern} can be seen as a generalization of a {@link BasicGraphPattern}
- * @see <a href="http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#sparqlBasicGraphPatterns">
- * SPARQL 1.1 Query Language: 18.1.6 Basic ImmutableGraph Patterns</a>
- * and <a href="http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#sparqlPropertyPaths">
- * SPARQL 1.1 Query Language: 18.1.7 Property Path Patterns</a>
- *
- * @author hasan
- */
-public interface PathSupportedBasicGraphPattern extends GraphPattern {
-
- /**
- *
- * @return a set of all property path patterns to match.
- */
- public Set<PropertyPathPattern> getPropertyPathPatterns();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PatternExistenceCondition.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PatternExistenceCondition.java
deleted file mode 100644
index 34e66bd..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PatternExistenceCondition.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This expression is intended to be used as a filter expression to test whether a ImmutableGraph pattern matches
- * the dataset or not, given the values of variables in the group ImmutableGraph pattern in which the filter occurs.
- * It does not generate any additional bindings.
- *
- * @see <a href="http://www.w3.org/TR/sparql11-query/#neg-pattern">SPARQL 1.1 Query Language: 8.1 Filtering Using ImmutableGraph Patterns</a>
- *
- * @author hasan
- */
-public class PatternExistenceCondition extends BuiltInCall {
- private boolean negated = false;
- private GroupGraphPattern pattern;
-
- public PatternExistenceCondition() {
- super("EXISTS", new ArrayList<Expression>());
- }
-
- public PatternExistenceCondition(String name, List<Expression> arguments) {
- super(name, new ArrayList<Expression>());
- if (!(name.equalsIgnoreCase("EXISTS") || name.equalsIgnoreCase("NOT EXISTS"))) {
- throw new RuntimeException("Unsupported name: " + name);
- } else {
- this.negated = name.equalsIgnoreCase("NOT EXISTS");
- }
- }
-
- public boolean isExistenceTest() {
- return !negated;
- }
-
- public GroupGraphPattern getPattern() {
- return pattern;
- }
-
- public void setExistenceTest(boolean existenceTest) {
- this.negated = !existenceTest;
- this.name = existenceTest ? "EXISTS" : "NOT EXISTS";
- }
-
- public void setPattern(GroupGraphPattern pattern) {
- this.pattern = pattern;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PredicatePath.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PredicatePath.java
deleted file mode 100644
index 9b926d1..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PredicatePath.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import org.apache.clerezza.commons.rdf.IRI;
-
-/**
- *
- * @author hasan
- */
-public class PredicatePath implements PropertyPathExpression {
- private IRI predicatePath;
-
- public PredicatePath(IRI predicatePath) {
- this.predicatePath = predicatePath;
- }
-
- public IRI getPredicatePath() {
- return predicatePath;
- }
-
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpression.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpression.java
deleted file mode 100644
index abbf87d..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpression.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * This interface models property path expressions.
- * @see <a href="http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#propertypaths">
- * SPARQL 1.1 Query Language: 9 Property Paths</a>
- *
- * @author hasan
- */
-public interface PropertyPathExpression {
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpressionOrVariable.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpressionOrVariable.java
deleted file mode 100644
index 821450c..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathExpressionOrVariable.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * Wraps either a {@link PropertyPathExpression} or a {@link Variable}
- *
- * @author hasan
- */
-public class PropertyPathExpressionOrVariable {
-
- private final PropertyPathExpression propertyPathExpression;
- private final Variable variable;
-
- public PropertyPathExpressionOrVariable(PropertyPathExpression propertyPathExpression) {
- if (propertyPathExpression == null) {
- throw new IllegalArgumentException("Invalid propertyPathExpression: null");
- }
- this.propertyPathExpression = propertyPathExpression;
- variable = null;
- }
-
- public PropertyPathExpressionOrVariable(Variable variable) {
- if (variable == null) {
- throw new IllegalArgumentException("Invalid variable: null");
- }
- this.variable = variable;
- propertyPathExpression = null;
- }
-
- /**
- *
- * @return
- * true if it is a {@link Variable}, false if it is a {@link PropertyPathExpression}
- */
- public boolean isVariable() {
- return propertyPathExpression == null;
- }
-
- /**
- *
- * @return
- * the wrapped PropertyPathExpression if it is a PropertyPathExpression, null otherwise
- */
- public PropertyPathExpression getPropertyPathExpression() {
- return propertyPathExpression;
- }
-
- /**
- *
- * @return
- * the wrapped Variable if it is a Variable, null otherwise
- */
- public Variable getVariable() {
- return variable;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof PropertyPathExpressionOrVariable)) {
- return false;
- }
- final PropertyPathExpressionOrVariable other = (PropertyPathExpressionOrVariable) obj;
- if (this.isVariable() != other.isVariable()) {
- return false;
- }
- if (this.isVariable()) {
- if (!this.getVariable().equals(other.getVariable())) {
- return false;
- }
- } else {
- if (!this.getPropertyPathExpression().equals(other.getPropertyPathExpression())) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- return (isVariable()
- ? 13 * getVariable().hashCode() + 17
- : 13 * getPropertyPathExpression().hashCode() + 17);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathPattern.java
deleted file mode 100644
index 915a0e2..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertyPathPattern.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * Defines a property path pattern consisting of a subject, a property path expression, and an object.
- * The subject and object are of type {@link ResourceOrVariable}, whereas
- * the predicate is of type {@link PropertyPathExpressionOrVariable}.
- * @see <a href="http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#sparqlPropertyPaths">
- * SPARQL 1.1 Query Language: 18.1.7 Property Path Patterns</a>
- *
- * @author hasan
- */
-public interface PropertyPathPattern {
-
- /**
- * @return the subject
- */
- public ResourceOrVariable getSubject();
-
- /**
- * @return the property path expression
- */
- public PropertyPathExpressionOrVariable getPropertyPathExpression();
-
- /**
- * @return the object
- */
- public ResourceOrVariable getObject();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertySet.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertySet.java
deleted file mode 100644
index fe1ce20..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/PropertySet.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A property set is intended to store only predicate paths and inverse predicate paths.
- *
- * @author hasan
- */
-public class PropertySet implements PropertyPathExpression {
- private Set<PropertyPathExpression> propertySet = new HashSet<PropertyPathExpression>();
-
- /**
- *
- * @param propertyPathExpression expected value is a predicate path or an inverse predicate path
- */
- public void addElement(PropertyPathExpression propertyPathExpression) {
- this.propertySet.add(propertyPathExpression);
- }
-
- public Set<PropertyPathExpression> getPropertySet() {
- return propertySet;
- }
-
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java
deleted file mode 100644
index 6f4909d..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Query.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * <p>This interface represents a SPARQL query.</p>
- * <p>There are four types of SPARQL queries: {@link SelectQuery},
- * {@link ConstructQuery}, {@link DescribeQuery}, and {@link AskQuery}.</p>
- *
- * @author hasan
- */
-public interface Query {
-
- /**
- * <p>Gets {@link DataSet} containing the specification of the default
- * ImmutableGraph and named graphs, if any.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#specifyingDataset">
- * SPARQL Query Language: 8.2 Specifying RDF Datasets</a>
- * @return
- * null if no data set is specified, indicating the use of
- * system default ImmutableGraph. Otherwise a {@link DataSet} object is returned.
- */
- public DataSet getDataSet();
-
- /**
- * <p>Gets the query pattern of the WHERE clause for the query.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#GraphPattern">
- * SPARQL Query Language: 5 ImmutableGraph Patterns</a>
- * @return
- * the {@link GroupGraphPattern} of the WHERE clause for this query.
- * If the WHERE clause is not specified, null is returned.
- */
- public GroupGraphPattern getQueryPattern();
-
- public InlineData getInlineData();
-
- /**
- *
- * @return A valid String representation of the query.
- */
- @Override
- public abstract String toString();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/QueryWithSolutionModifier.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/QueryWithSolutionModifier.java
deleted file mode 100644
index 6a6399b..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/QueryWithSolutionModifier.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.List;
-
-/**
- * <p>This interface represents a SPARQL query which contains a specification
- * of solution modifiers: GROUP BY, HAVING, ORDER BY, OFFSET, and LIMIT.</p>
- *
- * @see <a href="http://www.w3.org/TR/sparql11-query/#aggregates">
- * SPARQL 1.1 Query Language: 11 Aggregates</a>
- * and
- * @see <a href="http://www.w3.org/TR/sparql11-query/#solutionModifiers">
- * SPARQL 1.1 Query Language: 15 Solution Sequences and Modifiers</a>
- *
- * @author hasan
- */
-public interface QueryWithSolutionModifier extends Query {
-
- public List<Expression> getGroupConditions();
-
- public List<Expression> getHavingConditions();
-
- /**
- * <p>Gets the list of required ordering conditions in decreasing ordering
- * priority.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#modOrderBy">
- * SPARQL Query Language: 9.1 ORDER BY</a>
- * @return A list of {@link OrderCondition}s, in order of priority.
- */
- public List<OrderCondition> getOrderConditions();
-
- /**
- * <p>Gets the numeric offset of the first row to be returned by the query.
- * The default offset is 0, meaning to start at the beginning.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#modOffset">
- * SPARQL Query Language: 9.4 OFFSET</a>
- * @return The number of rows to skip in the result.
- */
- public int getOffset();
-
- /**
- * <p>Gets the maximum number of results to be returned by the query.
- * A limit of -1 means no limit (return all results).
- * A limit of 0 means that no results should be returned.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#modResultLimit">
- * SPARQL Query Language: 9.5 LIMIT</a>
- * @return The maximum number of rows to returned by the query.
- */
- public int getLimit();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ResourceOrVariable.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ResourceOrVariable.java
deleted file mode 100644
index 0f00bc9..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ResourceOrVariable.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import org.apache.clerezza.commons.rdf.RDFTerm;
-
-/**
- * Wraps either a {@link RDFTerm} or a {@link Variable}
- *
- * @author hasan
- */
-public class ResourceOrVariable {
-
- private final RDFTerm resource;
- private final Variable variable;
-
- public ResourceOrVariable(RDFTerm resource) {
- if (resource == null) {
- throw new IllegalArgumentException("Invalid resource: null");
- }
- this.resource = resource;
- variable = null;
- }
-
- public ResourceOrVariable(Variable variable) {
- if (variable == null) {
- throw new IllegalArgumentException("Invalid variable: null");
- }
- this.variable = variable;
- resource = null;
- }
-
- /**
- *
- * @return
- * true if it is a {@link Variable}, false if it is a {@link RDFTerm}
- */
- public boolean isVariable() {
- return resource == null;
- }
-
- /**
- *
- * @return
- * the wrapped Resource if it is a Resource, null otherwise
- */
- public RDFTerm getResource() {
- return resource;
- }
-
- /**
- *
- * @return
- * the wrapped Variable if it is a Variable, null otherwise
- */
- public Variable getVariable() {
- return variable;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof ResourceOrVariable)) {
- return false;
- }
- final ResourceOrVariable other = (ResourceOrVariable) obj;
- if (this.isVariable() != other.isVariable()) {
- return false;
- }
- if (this.isVariable()) {
- if (!this.getVariable().equals(other.getVariable())) {
- return false;
- }
- } else {
- if (!this.getResource().equals(other.getResource())) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- return (isVariable()
- ? 13 * getVariable().hashCode() + 7
- : 13 * getResource().hashCode() + 7);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/RhsListBinaryOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/RhsListBinaryOperation.java
deleted file mode 100644
index 2e22ed4..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/RhsListBinaryOperation.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.List;
-
-/**
- * Defines an operation with two operands: a left hand side and a right hand side operand
- * where the right hand side operand is a list.
- *
- * @author hasan
- */
-public class RhsListBinaryOperation extends AbstractOperation {
-
- private Expression lhsOperand;
- private List<Expression> rhsOperand;
-
- public RhsListBinaryOperation(String operator, Expression lhsOperand, List<Expression> rhsOperand) {
- super(operator);
- this.lhsOperand = lhsOperand;
- this.rhsOperand = rhsOperand;
- }
-
- public Expression getLhsOperand() {
- return lhsOperand;
- }
-
- public List<Expression> getRhsOperand() {
- return rhsOperand;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/SelectQuery.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/SelectQuery.java
deleted file mode 100644
index 6985a8b..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/SelectQuery.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.List;
-
-/**
- * <p>This interface represents a SPARQL SELECT query.</p>
- *
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#select">
- * SPARQL Query Language: 10.1 SELECT</a>
- *
- * @author hasan
- */
-public interface SelectQuery extends QueryWithSolutionModifier {
-
- /**
- * <p>Tests if this query should return distinct results.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#modDistinct">
- * SPARQL Query Language: 9.3.1 DISTINCT</a>
- * @return <code>true</code> if the query should return distinct results.
- */
- public boolean isDistinct();
-
- /**
- * <p>Tests if this query should return reduced results.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#modReduced">
- * SPARQL Query Language: 9.3.2 REDUCED</a>
- * @return <code>true</code> if the query should return reduced results.
- */
- public boolean isReduced();
-
- /**
- * <p>Tests if this query returns all its variables, and not a projected subset.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#solutionModifiers">
- * SPARQL Query Language: 9 Solution Sequences and Modifiers</a>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#modProjection">
- * SPARQL Query Language: 9.2 Projection</a>
- * @return <code>true</code> if the query should return all variables.
- */
- public boolean isSelectAll();
-
- /**
- * <p>Gets the list of {@link Variable}s to project the solution to.
- * If {@link #isSelectAll()} returns <code>true</code> then
- * this list contains all the variables from the query.</p>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#select">
- * SPARQL Query Language: 10.1 SELECT</a>
- * @see <a href="http://www.w3.org/TR/rdf-sparql-query/#modProjection">
- * SPARQL Query Language: 9.2 Projection</a>
- * @return A list of {@link Variable}s to return from the query.
- */
- public List<Variable> getSelection();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ServiceGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ServiceGraphPattern.java
deleted file mode 100644
index 9ae6f1a..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/ServiceGraphPattern.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * Defines a service ImmutableGraph pattern.
- * @see <a href="http://www.w3.org/TR/sparql11-federated-query/">
- * SPARQL 1.1 Federated Query</a>
- *
- * @author hasan
- */
-public interface ServiceGraphPattern extends GraphPattern {
-
- /**
- *
- * @return a {@link UriRefOrVariable} which specifies the service endpoint.
- */
- public UriRefOrVariable getService();
-
- /**
- *
- * @return the pattern to match.
- */
- public GroupGraphPattern getGroupGraphPattern();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/SparqlUnit.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/SparqlUnit.java
deleted file mode 100644
index 05234f7..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/SparqlUnit.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import org.apache.clerezza.rdf.core.sparql.update.Update;
-
-/**
- * <p>This interface represents a SPARQL Query or Update.</p>
- *
- * @author hasan
- */
-public interface SparqlUnit {
-
- /**
- *
- * @return
- * true if it is a {@link Query}, false if it is an {@link Update}
- */
- public boolean isQuery();
-
- /**
- *
- * @return
- * the wrapped Query if it is a {@link Query}, null otherwise
- */
- public Query getQuery();
-
- /**
- *
- * @return
- * the wrapped Update if it is an {@link Update}, null otherwise
- */
- public Update getUpdate();
-
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/TriplePattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/TriplePattern.java
deleted file mode 100644
index 6d1bfe0..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/TriplePattern.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * Defines a triple pattern consisting of a subject, a predicate, and an object.
- * The subject and object are of type {@link ResourceOrVariable}, whereas
- * the predicate is of type {@link UriRefOrVariable}.
- *
- * @author hasan
- */
-public interface TriplePattern {
-
- /**
- * @return the subject
- */
- public ResourceOrVariable getSubject();
-
- /**
- * @return the predicate
- */
- public UriRefOrVariable getPredicate();
-
- /**
- * @return the object
- */
- public ResourceOrVariable getObject();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UnaryOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UnaryOperation.java
deleted file mode 100644
index 397729e..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UnaryOperation.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- * Defines an operation with a single operand.
- *
- * @author hasan
- */
-public class UnaryOperation extends AbstractOperation {
-
- private Expression operand;
-
- public UnaryOperation(String operator, Expression operand) {
- super(operator);
- this.operand = operand;
- }
-
- public Expression getOperand() {
- return operand;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UnaryPropertyPathOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UnaryPropertyPathOperation.java
deleted file mode 100644
index 9912c03..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UnaryPropertyPathOperation.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-/**
- *
- * @author hasan
- */
-public class UnaryPropertyPathOperation implements PropertyPathExpression {
- private String operator;
- private PropertyPathExpression operand;
-
- public UnaryPropertyPathOperation(String operator, PropertyPathExpression operand) {
- this.operator = operator;
- this.operand = operand;
- }
-
- public PropertyPathExpression getOperand() {
- return operand;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UriRefExpression.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UriRefExpression.java
deleted file mode 100644
index 5910ac2..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UriRefExpression.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import org.apache.clerezza.commons.rdf.IRI;
-
-/**
- * Wraps a {@link IRI} in an {@link Expression}.
- *
- * @author hasan
- */
-public class UriRefExpression implements Expression {
-
- private final IRI uriRef;
-
- public UriRefExpression(IRI uriRef) {
- this.uriRef = uriRef;
- }
-
- public IRI getUriRef() {
- return uriRef;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UriRefOrVariable.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UriRefOrVariable.java
deleted file mode 100644
index 803c1bc..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/UriRefOrVariable.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import org.apache.clerezza.commons.rdf.IRI;
-
-/**
- * Wraps either a {@link IRI} or a {@link Variable}.
- *
- * @author rbn
- */
-public class UriRefOrVariable extends ResourceOrVariable {
-
- public UriRefOrVariable(Variable variable) {
- super(variable);
- }
-
- public UriRefOrVariable(IRI resource) {
- super(resource);
- }
-
- @Override
- public IRI getResource() {
- return (IRI)super.getResource();
- }
-
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Variable.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Variable.java
deleted file mode 100644
index fd4b63f..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/Variable.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query;
-
-import java.util.UUID;
-
-/**
- * Defines a Variable. A Variable can occur in an {@link Expression} and is
- * itself an {@link Expression}.
- *
- * @author hasan
- */
-public class Variable implements Expression {
-
- private String name;
- private Expression boundExpression;
-
- public Variable() {
- this.name = UUID.randomUUID().toString();
- }
-
- /**
- * Creates a variable with the specified name
- *
- * @param name
- */
- public Variable(String name) {
- if (name == null) {
- throw new IllegalArgumentException("name may not be null");
- }
- this.name = name;
- }
-
- public Variable(String name, Expression boundExpression) {
- this.name = name;
- this.boundExpression = boundExpression;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- public Expression getBoundExpression() {
- return boundExpression;
- }
-
- public void setBoundExpression(Expression boundExpression) {
- this.boundExpression = boundExpression;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Variable other = (Variable) obj;
- return name.equals(other.name);
- }
-
- @Override
- public int hashCode() {
- return name.hashCode();
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleAlternativeGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleAlternativeGraphPattern.java
deleted file mode 100644
index e8ad4ed..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleAlternativeGraphPattern.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.clerezza.rdf.core.sparql.query.AlternativeGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-
-/**
- *
- * @author hasan
- */
-public class SimpleAlternativeGraphPattern implements AlternativeGraphPattern {
-
- private List<GroupGraphPattern> alternativeGraphPatterns;
-
- public SimpleAlternativeGraphPattern(
- List<GroupGraphPattern> alternativeGraphPatterns) {
- this.alternativeGraphPatterns = (alternativeGraphPatterns == null)
- ? new ArrayList<GroupGraphPattern>()
- : alternativeGraphPatterns;
-
- this.alternativeGraphPatterns = alternativeGraphPatterns;
- }
-
- public SimpleAlternativeGraphPattern(GroupGraphPattern... groupGraphPatterns) {
- alternativeGraphPatterns = new ArrayList<GroupGraphPattern>();
- GroupGraphPattern[] g = groupGraphPatterns;
- for (int i = 0; i < g.length; i++) {
- alternativeGraphPatterns.add(g[i]);
- }
- }
-
- @Override
- public List<GroupGraphPattern> getAlternativeGraphPatterns() {
- return alternativeGraphPatterns;
- }
-
- public void addAlternativeGraphPattern(GroupGraphPattern groupGraphPattern) {
- alternativeGraphPatterns.add(groupGraphPattern);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleAskQuery.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleAskQuery.java
deleted file mode 100644
index b99fdae..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleAskQuery.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import org.apache.clerezza.rdf.core.sparql.query.AskQuery;
-
-/**
- *
- * @author hasan
- */
-public class SimpleAskQuery extends SimpleQueryWithSolutionModifier implements AskQuery {
-
- @Override
- public String toString() {
- return (new SimpleStringQuerySerializer()).serialize(this);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleBasicGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleBasicGraphPattern.java
deleted file mode 100644
index 6b8916b..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleBasicGraphPattern.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-import org.apache.clerezza.rdf.core.sparql.query.BasicGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.TriplePattern;
-
-/**
- *
- * @author hasan
- */
-public class SimpleBasicGraphPattern implements BasicGraphPattern {
-
- private Set<TriplePattern> triplePatterns;
-
- public SimpleBasicGraphPattern(Set<TriplePattern> triplePatterns) {
- this.triplePatterns = (triplePatterns == null)
- ? new LinkedHashSet<TriplePattern>()
- : triplePatterns;
- }
-
- @Override
- public Set<TriplePattern> getTriplePatterns() {
- return triplePatterns;
- }
-
- public void addTriplePatterns(Set<TriplePattern> triplePatterns) {
- this.triplePatterns.addAll(triplePatterns);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleConstructQuery.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleConstructQuery.java
deleted file mode 100644
index 19ef5aa..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleConstructQuery.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-import org.apache.clerezza.rdf.core.sparql.query.ConstructQuery;
-import org.apache.clerezza.rdf.core.sparql.query.TriplePattern;
-
-/**
- *
- * @author hasan
- */
-public class SimpleConstructQuery extends SimpleQueryWithSolutionModifier
- implements ConstructQuery {
-
- private Set<TriplePattern> triplePatterns;
-
- public SimpleConstructQuery(Set<TriplePattern> triplePatterns) {
- this.triplePatterns = (triplePatterns == null)
- ? new LinkedHashSet<TriplePattern>()
- : triplePatterns;
- }
-
- @Override
- public Set<TriplePattern> getConstructTemplate() {
- return triplePatterns;
- }
-
- @Override
- public String toString() {
- return (new SimpleStringQuerySerializer()).serialize(this);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDataSet.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDataSet.java
deleted file mode 100644
index 354f5b0..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDataSet.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.sparql.query.DataSet;
-
-/**
- *
- * @author hasan
- */
-public class SimpleDataSet implements DataSet {
- private Set<IRI> defaultGraphs = new HashSet<IRI>();
- private Set<IRI> namedGraphs = new HashSet<IRI>();
-
- @Override
- public Set<IRI> getDefaultGraphs() {
- return defaultGraphs;
- }
-
- @Override
- public Set<IRI> getNamedGraphs() {
- return namedGraphs;
- }
-
- public void addDefaultGraph(IRI defaultGraph) {
- defaultGraphs.add(defaultGraph);
- }
-
- public void addNamedGraph(IRI namedGraph) {
- namedGraphs.add(namedGraph);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDescribeQuery.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDescribeQuery.java
deleted file mode 100644
index 9faba61..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleDescribeQuery.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.clerezza.rdf.core.sparql.query.DescribeQuery;
-import org.apache.clerezza.rdf.core.sparql.query.ResourceOrVariable;
-
-/**
- *
- * @author hasan
- */
-public class SimpleDescribeQuery extends SimpleQueryWithSolutionModifier
- implements DescribeQuery {
-
- private boolean describeAll;
- private List<ResourceOrVariable> resourcesToDescribe =
- new ArrayList<ResourceOrVariable>();
-
- @Override
- public boolean isDescribeAll() {
- return describeAll;
- }
-
- @Override
- public List<ResourceOrVariable> getResourcesToDescribe() {
- return resourcesToDescribe;
- }
-
- public void setDescribeAll() {
- assert resourcesToDescribe.isEmpty();
- describeAll = true;
- }
-
- public void addResourceToDescribe(ResourceOrVariable node) {
- resourcesToDescribe.add(node);
- }
-
- @Override
- public String toString() {
- return (new SimpleStringQuerySerializer()).serialize(this);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGraphGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGraphGraphPattern.java
deleted file mode 100644
index 45badaa..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGraphGraphPattern.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import org.apache.clerezza.rdf.core.sparql.query.GraphGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.UriRefOrVariable;
-
-/**
- *
- * @author hasan
- */
-public class SimpleGraphGraphPattern implements GraphGraphPattern {
-
- private UriRefOrVariable ImmutableGraph;
- private GroupGraphPattern groupGraphPattern;
-
- public SimpleGraphGraphPattern(UriRefOrVariable ImmutableGraph,
- GroupGraphPattern groupGraphPattern) {
- if (ImmutableGraph == null) {
- throw new IllegalArgumentException("ImmutableGraph may not be null");
- }
- if (groupGraphPattern == null) {
- throw new IllegalArgumentException("Group ImmutableGraph Pattern may not be null");
- }
- this.ImmutableGraph = ImmutableGraph;
- this.groupGraphPattern = groupGraphPattern;
- }
-
- @Override
- public UriRefOrVariable getGraph() {
- return ImmutableGraph;
- }
-
- @Override
- public GroupGraphPattern getGroupGraphPattern() {
- return groupGraphPattern;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGroupGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGroupGraphPattern.java
deleted file mode 100644
index cd893d2..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleGroupGraphPattern.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.sparql.query.AlternativeGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.BasicGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.Expression;
-import org.apache.clerezza.rdf.core.sparql.query.GraphGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.GraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.MinusGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.OptionalGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.PathSupportedBasicGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.PropertyPathPattern;
-import org.apache.clerezza.rdf.core.sparql.query.SelectQuery;
-import org.apache.clerezza.rdf.core.sparql.query.TriplePattern;
-import org.apache.clerezza.rdf.core.sparql.query.UriRefOrVariable;
-
-/**
- * This class implements {@link GroupGraphPattern}.
- *
- * @author hasan
- */
-public class SimpleGroupGraphPattern implements GroupGraphPattern {
-
- private List<Expression> constraints = new ArrayList<Expression>();
- private List<GraphPattern> graphPatterns = new ArrayList<GraphPattern>();
- private SelectQuery subSelect = null;
- private boolean lastBasicGraphPatternIsComplete = true;
-
- @Override
- public boolean isSubSelect() {
- return subSelect != null;
- }
-
- @Override
- public SelectQuery getSubSelect() {
- return subSelect;
- }
-
- @Override
- public Set<GraphPattern> getGraphPatterns() {
- return subSelect == null ? new LinkedHashSet(graphPatterns) : null;
- }
-
- @Override
- public List<Expression> getFilter() {
- return subSelect == null ? constraints : null;
- }
-
- public void setSubSelect(SelectQuery subSelect) {
- this.subSelect = subSelect;
- }
-
- /**
- * Adds a {@link GraphPattern} to the group.
- *
- * @param graphPattern
- * the GraphPattern to be added.
- */
- public void addGraphPattern(GraphPattern graphPattern) {
- subSelect = null;
- graphPatterns.add(graphPattern);
- lastBasicGraphPatternIsComplete =
- !(graphPattern instanceof BasicGraphPattern || graphPattern instanceof PathSupportedBasicGraphPattern);
- }
-
- /**
- * Adds a constraint to the {@link GroupGraphPattern}.
- *
- * @param constraint
- * an {@link Expression} as the constraint to be added.
- */
- public void addConstraint(Expression constraint) {
- subSelect = null;
- constraints.add(constraint);
- }
-
- public void endLastBasicGraphPattern() {
- lastBasicGraphPatternIsComplete = true;
- }
-
- /**
- * If the last {@link GraphPattern} added to the group is not a
- * {@link SimplePathSupportedBasicGraphPattern}, then creates one containing the
- * specified {@link PropertyPathPattern}s and adds it to the group.
- * Otherwise, adds the specified {@link PropertyPathPattern}s to the last
- * added {@link SimplePathSupportedBasicGraphPattern} in the group.
- *
- * @param propertyPathPatterns
- * a set of {@link PropertyPathPattern}s to be added into a
- * {@link SimplePathSupportedBasicGraphPattern} of the group.
- */
- public void addPropertyPathPatterns(Set<PropertyPathPattern> propertyPathPatterns) {
- subSelect = null;
- if (lastBasicGraphPatternIsComplete) {
- graphPatterns.add(new SimplePathSupportedBasicGraphPattern(propertyPathPatterns));
- lastBasicGraphPatternIsComplete = false;
- } else {
- GraphPattern prevGraphPattern;
- int size = graphPatterns.size();
- prevGraphPattern = graphPatterns.get(size-1);
- if (prevGraphPattern instanceof SimplePathSupportedBasicGraphPattern) {
- ((SimplePathSupportedBasicGraphPattern) prevGraphPattern).addPropertyPathPatterns(propertyPathPatterns);
- }
- }
- }
-
- /**
- * If the last {@link GraphPattern} added to the group is not a
- * {@link SimpleBasicGraphPattern}, then creates one containing the
- * specified {@link TriplePattern}s and adds it to the group.
- * Otherwise, adds the specified {@link TriplePattern}s to the last
- * added {@link SimpleBasicGraphPattern} in the group.
- *
- * @param triplePatterns
- * a set of {@link TriplePattern}s to be added into a
- * {@link SimpleBasicGraphPattern} of the group.
- */
- public void addTriplePatterns(Set<TriplePattern> triplePatterns) {
- subSelect = null;
- GraphPattern prevGraphPattern;
- int size = graphPatterns.size();
- if (!lastBasicGraphPatternIsComplete && (size > 0)) {
- prevGraphPattern = graphPatterns.get(size-1);
- if (prevGraphPattern instanceof SimpleBasicGraphPattern) {
- ((SimpleBasicGraphPattern) prevGraphPattern)
- .addTriplePatterns(triplePatterns);
- return;
- }
- }
- graphPatterns.add(new SimpleBasicGraphPattern(triplePatterns));
- lastBasicGraphPatternIsComplete = false;
- }
-
- /**
- * Adds an {@link OptionalGraphPattern} to the group consisting of
- * a main ImmutableGraph pattern and the specified {@link GroupGraphPattern} as
- * the optional pattern.
- * The main ImmutableGraph pattern is taken from the last added {@link GraphPattern}
- * in the group, if it exists. Otherwise, the main ImmutableGraph pattern is null.
- *
- * @param optional
- * a {@link GroupGraphPattern} as the optional pattern of
- * an {@link OptionalGraphPattern}.
- */
- public void addOptionalGraphPattern(GroupGraphPattern optional) {
- subSelect = null;
- GraphPattern prevGraphPattern = null;
- int size = graphPatterns.size();
- if (size > 0) {
- prevGraphPattern = graphPatterns.remove(size-1);
- }
- graphPatterns.add(new SimpleOptionalGraphPattern(prevGraphPattern, optional));
- lastBasicGraphPatternIsComplete = true;
- }
-
- public void addMinusGraphPattern(GroupGraphPattern subtrahend) {
- subSelect = null;
- GraphPattern prevGraphPattern = null;
- int size = graphPatterns.size();
- if (size > 0) {
- prevGraphPattern = graphPatterns.remove(size-1);
- }
- graphPatterns.add(new SimpleMinusGraphPattern(prevGraphPattern, subtrahend));
- lastBasicGraphPatternIsComplete = true;
- }
-
- @Override
- public Set<IRI> getReferredGraphs() {
- Set<IRI> referredGraphs = new HashSet<IRI>();
- if (subSelect != null) {
- GroupGraphPattern queryPattern = subSelect.getQueryPattern();
- referredGraphs.addAll(queryPattern.getReferredGraphs());
- } else {
- for (GraphPattern graphPattern : graphPatterns) {
- referredGraphs.addAll(getReferredGraphs(graphPattern));
- }
- }
- return referredGraphs;
- }
-
- private Set<IRI> getReferredGraphs(GraphPattern graphPattern) {
- Set<IRI> referredGraphs = new HashSet<IRI>();
- if (graphPattern instanceof GraphGraphPattern) {
- GraphGraphPattern graphGraphPattern = (GraphGraphPattern) graphPattern;
- UriRefOrVariable ImmutableGraph = graphGraphPattern.getGraph();
- if (!ImmutableGraph.isVariable()) {
- referredGraphs.add(ImmutableGraph.getResource());
- }
- referredGraphs.addAll(graphGraphPattern.getGroupGraphPattern().getReferredGraphs());
- } else if (graphPattern instanceof AlternativeGraphPattern) {
- List<GroupGraphPattern> alternativeGraphPatterns =
- ((AlternativeGraphPattern) graphPattern).getAlternativeGraphPatterns();
- for (GroupGraphPattern groupGraphPattern : alternativeGraphPatterns) {
- referredGraphs.addAll(groupGraphPattern.getReferredGraphs());
- }
- } else if (graphPattern instanceof OptionalGraphPattern) {
- GraphPattern mainGraphPattern = ((OptionalGraphPattern) graphPattern).getMainGraphPattern();
- referredGraphs.addAll(getReferredGraphs(mainGraphPattern));
- GroupGraphPattern optionalGraphPattern = ((OptionalGraphPattern) graphPattern).getOptionalGraphPattern();
- referredGraphs.addAll(optionalGraphPattern.getReferredGraphs());
- } else if (graphPattern instanceof MinusGraphPattern) {
- GraphPattern minuendGraphPattern = ((MinusGraphPattern) graphPattern).getMinuendGraphPattern();
- referredGraphs.addAll(getReferredGraphs(minuendGraphPattern));
- GroupGraphPattern subtrahendGraphPattern = ((MinusGraphPattern) graphPattern).getSubtrahendGraphPattern();
- referredGraphs.addAll(subtrahendGraphPattern.getReferredGraphs());
- } else if (graphPattern instanceof GroupGraphPattern) {
- GroupGraphPattern groupGraphPattern = (GroupGraphPattern) graphPattern;
- referredGraphs.addAll(groupGraphPattern.getReferredGraphs());
- }
- return referredGraphs;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleInlineData.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleInlineData.java
deleted file mode 100644
index 3b49f02..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleInlineData.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.clerezza.commons.rdf.RDFTerm;
-import org.apache.clerezza.rdf.core.sparql.query.InlineData;
-import org.apache.clerezza.rdf.core.sparql.query.Variable;
-
-/**
- *
- * @author hasan
- */
-public class SimpleInlineData implements InlineData {
-
- private List<Variable> variables = new ArrayList<Variable>();
- private List<List<RDFTerm>> values = new ArrayList<List<RDFTerm>>();
-
- @Override
- public List<Variable> getVariables() {
- return variables;
- }
-
- @Override
- public List<List<RDFTerm>> getValues() {
- return values;
- }
-
- public void addVariable(Variable variable) {
- variables.add(variable);
- }
-
- public void addValues(List<RDFTerm> values) {
- this.values.add(values);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleMinusGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleMinusGraphPattern.java
deleted file mode 100644
index 951b9ec..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleMinusGraphPattern.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import org.apache.clerezza.rdf.core.sparql.query.GraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.MinusGraphPattern;
-
-/**
- * This class implements {@link MinusGraphPattern}.
- *
- * @author hasan
- */
-public class SimpleMinusGraphPattern implements MinusGraphPattern {
-
- private GraphPattern minuendGraphPattern;
- private GroupGraphPattern subtrahendGraphPattern;
-
- /**
- * Constructs a {@link MinusGraphPattern} out of a {@link GraphPattern}
- * as the minuend ImmutableGraph pattern and a {@link GroupGraphPattern} as the
- * subtrahend pattern.
- *
- * @param minuendGraphPattern
- * a {@link GraphPattern} specifying the minuend pattern.
- * @param subtrahendGraphPattern
- * a {@link GroupGraphPattern} specifying the subtrahend pattern.
- */
- public SimpleMinusGraphPattern(GraphPattern minuendGraphPattern, GroupGraphPattern subtrahendGraphPattern) {
- if (subtrahendGraphPattern == null) {
- throw new IllegalArgumentException("Subtrahend ImmutableGraph pattern may not be null");
- }
- if (minuendGraphPattern == null) {
- this.minuendGraphPattern = new SimpleGroupGraphPattern();
- } else {
- this.minuendGraphPattern = minuendGraphPattern;
- }
- this.subtrahendGraphPattern = subtrahendGraphPattern;
- }
-
- @Override
- public GraphPattern getMinuendGraphPattern() {
- return minuendGraphPattern;
- }
-
- @Override
- public GroupGraphPattern getSubtrahendGraphPattern() {
- return subtrahendGraphPattern;
- }
-
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOptionalGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOptionalGraphPattern.java
deleted file mode 100644
index 64abd73..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOptionalGraphPattern.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import org.apache.clerezza.rdf.core.sparql.query.GraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.OptionalGraphPattern;
-
-/**
- * This class implements {@link OptionalGraphPattern}.
- *
- * @author hasan
- */
-public class SimpleOptionalGraphPattern implements OptionalGraphPattern {
-
- private GraphPattern mainGraphPattern;
- private GroupGraphPattern optionalGraphPattern;
-
- /**
- * Constructs an {@link OptionalGraphPattern} out of a {@link GraphPattern}
- * as the main ImmutableGraph pattern and a {@link GroupGraphPattern} as the
- * optional pattern.
- *
- * @param mainGraphPattern
- * a {@link GraphPattern} specifying the main pattern.
- * @param optionalGraphPattern
- * a {@link GroupGraphPattern} specifying the optional pattern.
- */
- public SimpleOptionalGraphPattern(GraphPattern mainGraphPattern,
- GroupGraphPattern optionalGraphPattern) {
- if (optionalGraphPattern == null) {
- throw new IllegalArgumentException("Optional ImmutableGraph pattern may not be null");
- }
- if (mainGraphPattern == null) {
- this.mainGraphPattern = new SimpleGroupGraphPattern();
- } else {
- this.mainGraphPattern = mainGraphPattern;
- }
- this.optionalGraphPattern = optionalGraphPattern;
- }
-
- @Override
- public GraphPattern getMainGraphPattern() {
- return mainGraphPattern;
- }
-
- @Override
- public GroupGraphPattern getOptionalGraphPattern() {
- return optionalGraphPattern;
- }
-
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOrderCondition.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOrderCondition.java
deleted file mode 100644
index c6b5fba..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleOrderCondition.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import org.apache.clerezza.rdf.core.sparql.query.Expression;
-import org.apache.clerezza.rdf.core.sparql.query.OrderCondition;
-
-/**
- *
- * @author hasan
- */
-public class SimpleOrderCondition implements OrderCondition {
- private Expression expression;
- private boolean ascending;
-
- public SimpleOrderCondition(Expression expression, boolean ascending) {
- this.expression = expression;
- this.ascending = ascending;
- }
-
- @Override
- public Expression getExpression() {
- return expression;
- }
-
- @Override
- public boolean isAscending() {
- return ascending;
- }
-
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePathSupportedBasicGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePathSupportedBasicGraphPattern.java
deleted file mode 100644
index 37711d6..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePathSupportedBasicGraphPattern.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-import org.apache.clerezza.rdf.core.sparql.query.PathSupportedBasicGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.PropertyPathPattern;
-
-/**
- *
- * @author hasan
- */
-public class SimplePathSupportedBasicGraphPattern implements PathSupportedBasicGraphPattern {
-
- private Set<PropertyPathPattern> propertyPathPatterns;
-
- public SimplePathSupportedBasicGraphPattern(Set<PropertyPathPattern> propertyPathPatterns) {
- this.propertyPathPatterns = (propertyPathPatterns == null)
- ? new LinkedHashSet<PropertyPathPattern>()
- : propertyPathPatterns;
- }
-
- @Override
- public Set<PropertyPathPattern> getPropertyPathPatterns() {
- return propertyPathPatterns;
- }
-
- public void addPropertyPathPatterns(Set<PropertyPathPattern> propertyPathPatterns) {
- this.propertyPathPatterns.addAll(propertyPathPatterns);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePropertyPathPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePropertyPathPattern.java
deleted file mode 100644
index 36ed721..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimplePropertyPathPattern.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import org.apache.clerezza.commons.rdf.BlankNodeOrIRI;
-import org.apache.clerezza.commons.rdf.RDFTerm;
-import org.apache.clerezza.rdf.core.sparql.query.PropertyPathExpression;
-import org.apache.clerezza.rdf.core.sparql.query.PropertyPathExpressionOrVariable;
-import org.apache.clerezza.rdf.core.sparql.query.PropertyPathPattern;
-import org.apache.clerezza.rdf.core.sparql.query.ResourceOrVariable;
-import org.apache.clerezza.rdf.core.sparql.query.Variable;
-
-/**
- *
- * @author hasan
- */
-public class SimplePropertyPathPattern implements PropertyPathPattern {
-
- private ResourceOrVariable subject;
- private PropertyPathExpressionOrVariable propertyPathExpression;
- private ResourceOrVariable object;
-
- public SimplePropertyPathPattern(ResourceOrVariable subject,
- PropertyPathExpressionOrVariable propertyPathExpression,
- ResourceOrVariable object) {
- if (subject == null) {
- throw new IllegalArgumentException("Invalid subject: null");
- }
- if (propertyPathExpression == null) {
- throw new IllegalArgumentException("Invalid property path expression: null");
- }
- if (object == null) {
- throw new IllegalArgumentException("Invalid object: null");
- }
- this.subject = subject;
- this.propertyPathExpression = propertyPathExpression;
- this.object = object;
- }
-
- public SimplePropertyPathPattern(Variable subject, Variable propertyPathExpression, Variable object) {
- this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
- new ResourceOrVariable(object));
- }
-
- public SimplePropertyPathPattern(BlankNodeOrIRI subject, Variable propertyPathExpression, Variable object) {
- this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
- new ResourceOrVariable(object));
- }
-
- public SimplePropertyPathPattern(Variable subject, Variable propertyPathExpression, RDFTerm object) {
- this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
- new ResourceOrVariable(object));
- }
-
- public SimplePropertyPathPattern(BlankNodeOrIRI subject, Variable propertyPathExpression, RDFTerm object) {
- this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
- new ResourceOrVariable(object));
- }
-
- public SimplePropertyPathPattern(Variable subject, PropertyPathExpression propertyPathExpression, Variable object) {
- this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
- new ResourceOrVariable(object));
- }
-
- public SimplePropertyPathPattern(BlankNodeOrIRI subject, PropertyPathExpression propertyPathExpression, Variable object) {
- this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
- new ResourceOrVariable(object));
- }
-
- public SimplePropertyPathPattern(Variable subject, PropertyPathExpression propertyPathExpression, RDFTerm object) {
- this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
- new ResourceOrVariable(object));
- }
-
- public SimplePropertyPathPattern(BlankNodeOrIRI subject, PropertyPathExpression propertyPathExpression, RDFTerm object) {
- this(new ResourceOrVariable(subject), new PropertyPathExpressionOrVariable(propertyPathExpression),
- new ResourceOrVariable(object));
- }
-
- @Override
- public ResourceOrVariable getSubject() {
- return subject;
- }
-
- @Override
- public PropertyPathExpressionOrVariable getPropertyPathExpression() {
- return propertyPathExpression;
- }
-
- @Override
- public ResourceOrVariable getObject() {
- return object;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof PropertyPathPattern)) {
- return false;
- }
- final PropertyPathPattern other = (PropertyPathPattern) obj;
- if (!this.subject.equals(other.getSubject())) {
- return false;
- }
- if (!this.propertyPathExpression.equals(other.getPropertyPathExpression())) {
- return false;
- }
- if (!this.object.equals(other.getObject())) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- return (subject.hashCode() >> 1) ^ propertyPathExpression.hashCode() ^ (object.hashCode() << 1);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java
deleted file mode 100644
index 7f8407b..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQuery.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.sparql.query.DataSet;
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.InlineData;
-import org.apache.clerezza.rdf.core.sparql.query.Query;
-
-/**
- *
- * @author hasan
- */
-public abstract class SimpleQuery implements Query {
-
- private SimpleDataSet dataSet = null;
- private GroupGraphPattern queryPattern = null;
- private InlineData inlineData = null;
-
- @Override
- public DataSet getDataSet() {
- return dataSet;
- }
-
- @Override
- public GroupGraphPattern getQueryPattern() {
- return queryPattern;
- }
-
- @Override
- public InlineData getInlineData() {
- return inlineData;
- }
-
- public void addDefaultGraph(IRI defaultGraph) {
- if (dataSet == null) {
- dataSet = new SimpleDataSet();
- }
- dataSet.addDefaultGraph(defaultGraph);
- }
-
- public void addNamedGraph(IRI namedGraph) {
- if (dataSet == null) {
- dataSet = new SimpleDataSet();
- }
- dataSet.addNamedGraph(namedGraph);
- }
-
- public void setQueryPattern(GroupGraphPattern queryPattern) {
- this.queryPattern = queryPattern;
- }
-
- public void setInlineData(InlineData inlineData) {
- this.inlineData = inlineData;
- }
-
- @Override
- public abstract String toString();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQueryWithSolutionModifier.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQueryWithSolutionModifier.java
deleted file mode 100644
index eeb758f..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleQueryWithSolutionModifier.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.clerezza.rdf.core.sparql.query.Expression;
-import org.apache.clerezza.rdf.core.sparql.query.OrderCondition;
-import org.apache.clerezza.rdf.core.sparql.query.QueryWithSolutionModifier;
-
-/**
- *
- * @author hasan
- */
-public abstract class SimpleQueryWithSolutionModifier extends SimpleQuery
- implements QueryWithSolutionModifier {
-
- private List<Expression> groupConditions = new ArrayList<Expression>();
- private List<Expression> havingConditions = new ArrayList<Expression>();
- private List<OrderCondition> orderConditions = new ArrayList<OrderCondition>();
-
- /**
- * Result offset. 0 means no offset.
- */
- private int offset = 0;
-
- /**
- * Result limit. -1 means no limit.
- */
- private int limit = -1;
-
- @Override
- public List<Expression> getGroupConditions() {
- return groupConditions;
- }
-
- @Override
- public List<Expression> getHavingConditions() {
- return havingConditions;
- }
-
- @Override
- public List<OrderCondition> getOrderConditions() {
- return orderConditions;
- }
-
- @Override
- public int getOffset() {
- return offset;
- }
-
- @Override
- public int getLimit() {
- return limit;
- }
-
- public void addGroupCondition(Expression groupCondition) {
- groupConditions.add(groupCondition);
- }
-
- public void addHavingCondition(Expression havingCondition) {
- havingConditions.add(havingCondition);
- }
-
- public void addOrderCondition(OrderCondition orderCondition) {
- orderConditions.add(orderCondition);
- }
-
- public void setOffset(int offset) {
- this.offset = offset;
- }
-
- public void setLimit(int limit) {
- this.limit = limit;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSelectQuery.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSelectQuery.java
deleted file mode 100644
index f71e1a8..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSelectQuery.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.clerezza.rdf.core.sparql.query.SelectQuery;
-import org.apache.clerezza.rdf.core.sparql.query.Variable;
-
-/**
- *
- * @author hasan
- */
-public class SimpleSelectQuery extends SimpleQueryWithSolutionModifier
- implements SelectQuery {
-
- private boolean distinct;
- private boolean reduced;
- private boolean selectAll;
- private List<Variable> variables = new ArrayList<Variable>();
-
- @Override
- public boolean isDistinct() {
- return distinct;
- }
-
- @Override
- public boolean isReduced() {
- return reduced;
- }
-
- @Override
- public boolean isSelectAll() {
- return selectAll;
- }
-
- @Override
- public List<Variable> getSelection() {
- return variables;
- }
-
- public void setDistinct() {
- distinct = true;
- }
-
- public void setReduced() {
- reduced = true;
- }
-
- public void setSelectAll() {
- assert variables.isEmpty();
- selectAll = true;
- }
-
- public void addSelection(Variable var) {
- variables.add(var);
- }
-
- @Override
- public String toString() {
- return (new SimpleStringQuerySerializer()).serialize(this);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleServiceGraphPattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleServiceGraphPattern.java
deleted file mode 100644
index 24d6797..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleServiceGraphPattern.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.ServiceGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.UriRefOrVariable;
-
-/**
- *
- * @author hasan
- */
-public class SimpleServiceGraphPattern implements ServiceGraphPattern {
-
- private UriRefOrVariable service;
- private GroupGraphPattern groupGraphPattern;
- private boolean silent;
-
- public SimpleServiceGraphPattern(UriRefOrVariable service,
- GroupGraphPattern groupGraphPattern) {
- if (service == null) {
- throw new IllegalArgumentException("Service endpoint may not be null");
- }
- if (groupGraphPattern == null) {
- throw new IllegalArgumentException("Group ImmutableGraph Pattern may not be null");
- }
- this.service = service;
- this.groupGraphPattern = groupGraphPattern;
- this.silent = false;
- }
-
- @Override
- public UriRefOrVariable getService() {
- return service;
- }
-
- @Override
- public GroupGraphPattern getGroupGraphPattern() {
- return groupGraphPattern;
- }
-
- public void setSilent(boolean silent) {
- this.silent = silent;
- }
-
- public boolean isSilent() {
- return silent;
- }
-
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSparqlUnit.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSparqlUnit.java
deleted file mode 100644
index 60e88c4..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleSparqlUnit.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import org.apache.clerezza.rdf.core.sparql.query.Query;
-import org.apache.clerezza.rdf.core.sparql.query.SparqlUnit;
-import org.apache.clerezza.rdf.core.sparql.update.Update;
-
-/**
- *
- * @author hasan
- */
-public class SimpleSparqlUnit implements SparqlUnit {
-
- private final Query query;
- private final Update update;
-
- public SimpleSparqlUnit(Query query) {
- if (query == null) {
- throw new IllegalArgumentException("Invalid query: null");
- }
- this.query = query;
- update = null;
- }
-
- public SimpleSparqlUnit(Update update) {
- if (update == null) {
- throw new IllegalArgumentException("Invalid update: null");
- }
- this.update = update;
- query = null;
- }
-
-
- @Override
- public boolean isQuery() {
- return update == null;
- }
-
- @Override
- public Query getQuery() {
- return query;
- }
-
- @Override
- public Update getUpdate() {
- return update;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleStringQuerySerializer.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleStringQuerySerializer.java
deleted file mode 100644
index 18266f6..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleStringQuerySerializer.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import java.util.List;
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.BlankNode;
-import org.apache.clerezza.commons.rdf.RDFTerm;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.sparql.StringQuerySerializer;
-import org.apache.clerezza.rdf.core.sparql.query.AlternativeGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.AskQuery;
-import org.apache.clerezza.rdf.core.sparql.query.BasicGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.BinaryOperation;
-import org.apache.clerezza.rdf.core.sparql.query.BuiltInCall;
-import org.apache.clerezza.rdf.core.sparql.query.ConstructQuery;
-import org.apache.clerezza.rdf.core.sparql.query.DataSet;
-import org.apache.clerezza.rdf.core.sparql.query.DescribeQuery;
-import org.apache.clerezza.rdf.core.sparql.query.Expression;
-import org.apache.clerezza.rdf.core.sparql.query.FunctionCall;
-import org.apache.clerezza.rdf.core.sparql.query.GraphGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.GraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.LiteralExpression;
-import org.apache.clerezza.rdf.core.sparql.query.OptionalGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.OrderCondition;
-import org.apache.clerezza.rdf.core.sparql.query.ResourceOrVariable;
-import org.apache.clerezza.rdf.core.sparql.query.SelectQuery;
-import org.apache.clerezza.rdf.core.sparql.query.TriplePattern;
-import org.apache.clerezza.rdf.core.sparql.query.UnaryOperation;
-import org.apache.clerezza.rdf.core.sparql.query.UriRefExpression;
-import org.apache.clerezza.rdf.core.sparql.query.Variable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class implements abstract methods of {@link StringQuerySerializer}
- * to serialize specific {@link Query} types.
- *
- * @author hasan
- */
-public class SimpleStringQuerySerializer extends StringQuerySerializer {
-
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- @Override
- public String serialize(SelectQuery selectQuery) {
- StringBuffer s = new StringBuffer("SELECT ");
- if (selectQuery.isDistinct()) {
- s.append("DISTINCT\n");
- }
- if (selectQuery.isReduced()) {
- s.append("REDUCED\n");
- }
- if (selectQuery.isSelectAll()) {
- s.append("*");
- } else {
- for (Variable v : selectQuery.getSelection()) {
- appendVariable(s, v);
- s.append(" ");
- }
- }
- s.append("\n");
-
- appendDataSet(s, (SimpleQuery) selectQuery);
- appendWhere(s, (SimpleQuery) selectQuery);
- appendModifier(s, (SimpleQueryWithSolutionModifier) selectQuery);
-
- return s.toString();
- }
-
- private void appendVariable(StringBuffer s, Variable v) {
- s.append("?").append(v.getName());
- }
-
- private void appendDataSet(StringBuffer s, SimpleQuery q) {
- DataSet dataSet = q.getDataSet();
- if (dataSet != null) {
- for (IRI dg : dataSet.getDefaultGraphs()) {
- s.append("FROM ").append(dg.toString()).append("\n");
- }
- for (IRI ng : dataSet.getNamedGraphs()) {
- s.append("FROM NAMED ").append(ng.toString()).append("\n");
- }
- }
- }
-
- private void appendWhere(StringBuffer s, SimpleQuery q) {
- GroupGraphPattern queryPattern = q.getQueryPattern();
- if (queryPattern == null) {
- return;
- }
- s.append("WHERE\n");
- appendGroupGraphPattern(s, q.getQueryPattern());
- }
-
- private void appendGroupGraphPattern(StringBuffer s,
- GroupGraphPattern groupGraphPattern) {
-
- s.append("{ ");
- for (GraphPattern graphPattern : groupGraphPattern.getGraphPatterns()) {
- appendGraphPattern(s, graphPattern);
- }
- for (Expression e : groupGraphPattern.getFilter()) {
- boolean brackettedExpr = !((e instanceof BuiltInCall)
- || (e instanceof FunctionCall));
- s.append("FILTER ");
- if (brackettedExpr) {
- s.append("(");
- }
- appendExpression(s, e);
- if (brackettedExpr) {
- s.append(")");
- }
- s.append("\n");
- }
- s.append("} ");
- }
-
- private void appendGraphPattern(StringBuffer s, GraphPattern graphPattern) {
- if (graphPattern instanceof BasicGraphPattern) {
- appendTriplePatterns(s,
- ((BasicGraphPattern) graphPattern).getTriplePatterns());
- } else if (graphPattern instanceof GroupGraphPattern) {
- appendGroupGraphPattern(s, (GroupGraphPattern) graphPattern);
- } else if (graphPattern instanceof OptionalGraphPattern) {
- appendGraphPattern(s,
- ((OptionalGraphPattern) graphPattern).getMainGraphPattern());
- s.append(" OPTIONAL ");
- appendGroupGraphPattern(s,
- ((OptionalGraphPattern) graphPattern).getOptionalGraphPattern());
- } else if (graphPattern instanceof AlternativeGraphPattern) {
- List<GroupGraphPattern> alternativeGraphPatterns =
- ((AlternativeGraphPattern) graphPattern).getAlternativeGraphPatterns();
- if ((alternativeGraphPatterns != null) &&
- (!alternativeGraphPatterns.isEmpty())) {
- appendGroupGraphPattern(s, alternativeGraphPatterns.get(0));
- int size = alternativeGraphPatterns.size();
- int i = 1;
- while (i < size) {
- s.append(" UNION ");
- appendGroupGraphPattern(s, alternativeGraphPatterns.get(i));
- i++;
- }
- }
- } else if (graphPattern instanceof GraphGraphPattern) {
- s.append("ImmutableGraph ");
- appendResourceOrVariable(s, ((GraphGraphPattern) graphPattern).getGraph());
- s.append(" ");
- appendGroupGraphPattern(s, ((GraphGraphPattern) graphPattern).getGroupGraphPattern());
- } else {
- logger.warn("Unsupported GraphPattern {}", graphPattern.getClass());
- }
- }
-
- private void appendTriplePatterns(StringBuffer s,
- Set<TriplePattern> triplePatterns) {
-
- for (TriplePattern p : triplePatterns) {
- appendResourceOrVariable(s, p.getSubject());
- s.append(" ");
- appendResourceOrVariable(s, p.getPredicate());
- s.append(" ");
- appendResourceOrVariable(s, p.getObject());
- s.append(" .\n");
- }
- }
-
- private void appendResourceOrVariable(StringBuffer s, ResourceOrVariable n) {
- if (n.isVariable()) {
- appendVariable(s, n.getVariable());
- } else {
- RDFTerm r = n.getResource();
- if (r instanceof BlankNode) {
- s.append("_:").append(r.toString().replace("@", "."));
- } else {
- s.append(r.toString());
- }
- }
- }
-
- private void appendExpression(StringBuffer s, Expression e) {
- if (e instanceof Variable) {
- appendVariable(s, (Variable) e);
- } else if (e instanceof BinaryOperation) {
- BinaryOperation bo = (BinaryOperation) e;
- s.append("(");
- appendExpression(s, bo.getLhsOperand());
- s.append(") ").append(bo.getOperatorString()).append(" (");
- appendExpression(s, bo.getRhsOperand());
- s.append(")");
- } else if (e instanceof UnaryOperation) {
- UnaryOperation uo = (UnaryOperation) e;
- s.append(uo.getOperatorString()).append(" (");
- appendExpression(s, uo.getOperand());
- s.append(")");
- } else if (e instanceof BuiltInCall) {
- BuiltInCall b = (BuiltInCall) e;
- appendCall(s, b.getName(), b.getArguements());
- } else if (e instanceof FunctionCall) {
- FunctionCall f = (FunctionCall) e;
- appendCall(s, f.getName().getUnicodeString(), f.getArguements());
- } else if (e instanceof LiteralExpression) {
- appendLiteralExpression(s, (LiteralExpression) e);
- } else if (e instanceof UriRefExpression) {
- s.append(((UriRefExpression) e).getUriRef().toString());
- }
- }
-
- private void appendCall(StringBuffer s, String name, List<Expression> expr) {
- s.append(name).append("(");
- for (Expression e : expr) {
- appendExpression(s, e);
- s.append(",");
- }
- if (expr.isEmpty()) {
- s.append(")");
- } else {
- s.setCharAt(s.length()-1, ')');
- }
- }
-
- private void appendLiteralExpression(StringBuffer s, LiteralExpression le) {
- s.append(le.getLiteral().toString());
- }
-
- private void appendModifier(StringBuffer s, SimpleQueryWithSolutionModifier q) {
- List<OrderCondition> orderConditions = q.getOrderConditions();
- if ((orderConditions != null) && (!orderConditions.isEmpty())) {
- s.append("ORDER BY ");
- for (OrderCondition oc : orderConditions) {
- appendOrderCondition(s, oc);
- s.append("\n");
- }
- }
- if (q.getOffset() > 0) {
- s.append("OFFSET ").append(q.getOffset()).append("\n");
- }
- if (q.getLimit() >= 0) {
- s.append("LIMIT ").append(q.getLimit()).append("\n");
- }
- }
-
- private void appendOrderCondition(StringBuffer s, OrderCondition oc) {
- if (!oc.isAscending()) {
- s.append("DESC(");
- }
- appendExpression(s, oc.getExpression());
- if (!oc.isAscending()) {
- s.append(")");
- }
- s.append(" ");
- }
-
- @Override
- public String serialize(ConstructQuery constructQuery) {
- StringBuffer s = new StringBuffer("CONSTRUCT\n");
- Set<TriplePattern> triplePatterns = constructQuery.getConstructTemplate();
- s.append("{ ");
- if (triplePatterns != null && !triplePatterns.isEmpty()) {
- appendTriplePatterns(s, triplePatterns);
- }
- s.append("}\n");
-
- appendDataSet(s, (SimpleQuery) constructQuery);
- appendWhere(s, (SimpleQuery) constructQuery);
- appendModifier(s, (SimpleQueryWithSolutionModifier) constructQuery);
-
- return s.toString();
- }
-
- @Override
- public String serialize(DescribeQuery describeQuery) {
- StringBuffer s = new StringBuffer("DESCRIBE\n");
-
- if (describeQuery.isDescribeAll()) {
- s.append("*");
- } else {
- for (ResourceOrVariable n : describeQuery.getResourcesToDescribe()) {
- appendResourceOrVariable(s, n);
- s.append(" ");
- }
- }
- appendDataSet(s, (SimpleQuery) describeQuery);
- appendWhere(s, (SimpleQuery) describeQuery);
- appendModifier(s, (SimpleQueryWithSolutionModifier) describeQuery);
-
- return s.toString();
- }
-
- @Override
- public String serialize(AskQuery askQuery) {
- StringBuffer s = new StringBuffer("ASK\n");
- appendDataSet(s, (SimpleQuery) askQuery);
- appendWhere(s, (SimpleQuery) askQuery);
-
- return s.toString();
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleTriplePattern.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleTriplePattern.java
deleted file mode 100644
index adad648..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/query/impl/SimpleTriplePattern.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.query.impl;
-
-import org.apache.clerezza.commons.rdf.BlankNodeOrIRI;
-import org.apache.clerezza.commons.rdf.RDFTerm;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.sparql.query.ResourceOrVariable;
-import org.apache.clerezza.rdf.core.sparql.query.TriplePattern;
-import org.apache.clerezza.rdf.core.sparql.query.UriRefOrVariable;
-import org.apache.clerezza.rdf.core.sparql.query.Variable;
-
-/**
- *
- * @author hasan
- */
-public class SimpleTriplePattern implements TriplePattern {
-
- private ResourceOrVariable subject;
- private UriRefOrVariable predicate;
- private ResourceOrVariable object;
-
- public SimpleTriplePattern(ResourceOrVariable subject,
- UriRefOrVariable predicate,
- ResourceOrVariable object) {
- if (subject == null) {
- throw new IllegalArgumentException("Invalid subject: null");
- }
- if (predicate == null) {
- throw new IllegalArgumentException("Invalid predicate: null");
- }
- if (object == null) {
- throw new IllegalArgumentException("Invalid object: null");
- }
- this.subject = subject;
- this.predicate = predicate;
- this.object = object;
- }
-
- public SimpleTriplePattern(Variable subject, Variable predicate, Variable object) {
- this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
- new ResourceOrVariable(object));
- }
-
- public SimpleTriplePattern(BlankNodeOrIRI subject, Variable predicate, Variable object) {
- this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
- new ResourceOrVariable(object));
- }
-
- public SimpleTriplePattern(Variable subject, IRI predicate, Variable object) {
- this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
- new ResourceOrVariable(object));
- }
-
- public SimpleTriplePattern(BlankNodeOrIRI subject, IRI predicate, Variable object) {
- this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
- new ResourceOrVariable(object));
- }
-
- public SimpleTriplePattern(Variable subject, Variable predicate, RDFTerm object) {
- this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
- new ResourceOrVariable(object));
- }
-
- public SimpleTriplePattern(BlankNodeOrIRI subject, Variable predicate, RDFTerm object) {
- this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
- new ResourceOrVariable(object));
- }
-
- public SimpleTriplePattern(Variable subject, IRI predicate, RDFTerm object) {
- this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
- new ResourceOrVariable(object));
- }
-
- public SimpleTriplePattern(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
- this(new ResourceOrVariable(subject), new UriRefOrVariable(predicate),
- new ResourceOrVariable(object));
- }
-
- @Override
- public ResourceOrVariable getSubject() {
- return subject;
- }
-
- @Override
- public UriRefOrVariable getPredicate() {
- return predicate;
- }
-
- @Override
- public ResourceOrVariable getObject() {
- return object;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof TriplePattern)) {
- return false;
- }
- final TriplePattern other = (TriplePattern) obj;
- if (!this.subject.equals(other.getSubject())) {
- return false;
- }
- if (!this.predicate.equals(other.getPredicate())) {
- return false;
- }
- if (!this.object.equals(other.getObject())) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- return (subject.hashCode() >> 1) ^ subject.hashCode() ^ (subject.hashCode() << 1);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/Update.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/Update.java
deleted file mode 100644
index 944f3b9..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/Update.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update;
-
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.access.TcProvider;
-
-/**
- * <p>This interface represents a SPARQL Update.</p>
- *
- * @author hasan
- */
-public interface Update {
-
- /**
- *
- * @param defaultGraph
- * if default graph is referred either implicitly or explicitly in a SPARQL {@link Update}
- * the specified defaultGraph should be returned in the resulting set.
- * @param tcProvider
- * the specified tcProvider is used to get the named graphs referred in the SPARQL {@link Update}.
- * @return a set of graphs referred in the {@link Update}.
- */
- public Set<IRI> getReferredGraphs(IRI defaultGraph, TcProvider tcProvider);
-
- public void addOperation(UpdateOperation updateOperation);
-
- /**
- *
- * @return A valid String representation of the {@link Update}.
- */
- @Override
- public abstract String toString();
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/UpdateOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/UpdateOperation.java
deleted file mode 100644
index b09d305..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/UpdateOperation.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update;
-
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.access.TcProvider;
-
-/**
- * SPARQL Update Operation
- *
- * @author hasan
- */
-public interface UpdateOperation {
- public enum GraphSpec {
- GRAPH, DEFAULT, NAMED, ALL
- }
-
- /**
- *
- * @param defaultGraph
- * if default graph is referred either implicitly or explicitly as an input graph in this operation
- * the specified defaultGraph should be returned in the resulting set.
- * @param tcProvider
- * the specified tcProvider is used to get the named graphs referred as input graphs in this operation.
- * @return a set of graphs referred as input graphs in this operation.
- */
- public Set<IRI> getInputGraphs(IRI defaultGraph, TcProvider tcProvider);
-
- /**
- *
- * @param defaultGraph
- * if default graph is referred either implicitly or explicitly as a destination graph in this operation
- * the specified defaultGraph should be returned in the resulting set.
- * @param tcProvider
- * the specified tcProvider is used to get the named graphs referred as destination graphs in this operation.
- * @return a set of graphs referred as destination graphs in this operation.
- */
- public Set<IRI> getDestinationGraphs(IRI defaultGraph, TcProvider tcProvider);
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/AddOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/AddOperation.java
deleted file mode 100644
index 36344b6..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/AddOperation.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-/**
- * The ADD operation is a shortcut for inserting all data from an input ImmutableGraph into a destination ImmutableGraph.
- * Data from the input ImmutableGraph is not affected, and initial data from the destination ImmutableGraph, if any, is kept intact.
- * @see <a href="http://www.w3.org/TR/2013/REC-sparql11-update-20130321/#add">SPARQL 1.1 Update: 3.2.5 ADD</a>
- *
- * @author hasan
- */
-public class AddOperation extends SimpleUpdateOperation {
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/BaseUpdateOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/BaseUpdateOperation.java
deleted file mode 100644
index bc12710..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/BaseUpdateOperation.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.access.TcProvider;
-import org.apache.clerezza.rdf.core.sparql.update.UpdateOperation;
-
-/**
- *
- * @author hasan
- */
-public abstract class BaseUpdateOperation implements UpdateOperation {
-
- protected Set<IRI> inputGraphs = new HashSet<IRI>();
- protected Set<IRI> destinationGraphs = new HashSet<IRI>();
- protected GraphSpec inputGraphSpec = GraphSpec.GRAPH;
- protected GraphSpec destinationGraphSpec = GraphSpec.GRAPH;
-
- public void setInputGraphSpec(GraphSpec inputGraphSpec) {
- this.inputGraphSpec = inputGraphSpec;
- }
-
- public GraphSpec getInputGraphSpec() {
- return inputGraphSpec;
- }
-
- public void setDestinationGraphSpec(GraphSpec destinationGraphSpec) {
- this.destinationGraphSpec = destinationGraphSpec;
- }
-
- public GraphSpec getDestinationGraphSpec() {
- return destinationGraphSpec;
- }
-
- @Override
- public Set<IRI> getInputGraphs(IRI defaultGraph, TcProvider tcProvider) {
- return getGraphs(defaultGraph, tcProvider, inputGraphSpec, inputGraphs);
- }
-
- private Set<IRI> getGraphs(IRI defaultGraph, TcProvider tcProvider, GraphSpec graphSpec, Set<IRI> graphs) {
- switch (graphSpec) {
- case DEFAULT:
- Set<IRI> result = new HashSet<IRI>();
- result.add(defaultGraph);
- return result;
- case NAMED:
- case ALL:
- return tcProvider.listGraphs();
- default:
- return graphs;
- }
- }
-
- @Override
- public Set<IRI> getDestinationGraphs(IRI defaultGraph, TcProvider tcProvider) {
- return getGraphs(defaultGraph, tcProvider, destinationGraphSpec, destinationGraphs);
- }
-
- public void addInputGraph(IRI ImmutableGraph) {
- inputGraphs.add(ImmutableGraph);
- }
-
- public void addDestinationGraph(IRI ImmutableGraph) {
- destinationGraphs.add(ImmutableGraph);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOperation.java
deleted file mode 100644
index 9fdfe95..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOperation.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-/**
- *
- * @author hasan
- */
-public class ClearOperation extends ClearOrDropOperation {
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOrDropOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOrDropOperation.java
deleted file mode 100644
index 2b356af..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ClearOrDropOperation.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.access.TcProvider;
-import org.apache.clerezza.rdf.core.sparql.update.UpdateOperation;
-
-/**
- *
- * @author hasan
- */
-public class ClearOrDropOperation extends BaseUpdateOperation {
- private boolean silent;
-
- public ClearOrDropOperation() {
- this.silent = false;
- destinationGraphSpec = UpdateOperation.GraphSpec.DEFAULT;
- }
-
- public void setSilent(boolean silent) {
- this.silent = silent;
- }
-
- public boolean isSilent() {
- return silent;
- }
-
- public void setDestinationGraph(IRI destination) {
- destinationGraphSpec = UpdateOperation.GraphSpec.GRAPH;
- destinationGraphs.clear();
- destinationGraphs.add(destination);
- }
-
- public IRI getDestinationGraph(IRI defaultGraph, TcProvider tcProvider) {
- Set<IRI> result = getDestinationGraphs(defaultGraph, tcProvider);
- if (result.isEmpty()) {
- return null;
- } else {
- return result.iterator().next();
- }
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CopyOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CopyOperation.java
deleted file mode 100644
index 6e9aa40..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CopyOperation.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-/**
- *
- * @author hasan
- */
-public class CopyOperation extends SimpleUpdateOperation {
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CreateOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CreateOperation.java
deleted file mode 100644
index 090f423..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/CreateOperation.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-import org.apache.clerezza.commons.rdf.IRI;
-
-/**
- *
- * @author hasan
- */
-public class CreateOperation extends BaseUpdateOperation {
-
- private boolean silent;
-
- public CreateOperation() {
- this.silent = false;
- }
-
- public void setSilent(boolean silent) {
- this.silent = silent;
- }
-
- public boolean isSilent() {
- return silent;
- }
-
- public void setDestinationGraph(IRI destination) {
- destinationGraphs.clear();
- destinationGraphs.add(destination);
- }
-
- public IRI getDestinationGraph() {
- if (destinationGraphs.isEmpty()) {
- return null;
- } else {
- return destinationGraphs.iterator().next();
- }
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/DeleteDataOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/DeleteDataOperation.java
deleted file mode 100644
index c2318c6..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/DeleteDataOperation.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-/**
- *
- * @author hasan
- */
-public class DeleteDataOperation extends UpdateOperationWithQuads {
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/DeleteWhereOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/DeleteWhereOperation.java
deleted file mode 100644
index 6704775..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/DeleteWhereOperation.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-/**
- *
- * @author hasan
- */
-public class DeleteWhereOperation extends UpdateOperationWithQuads {
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/DropOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/DropOperation.java
deleted file mode 100644
index e70a93f..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/DropOperation.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-/**
- *
- * @author hasan
- */
-public class DropOperation extends ClearOrDropOperation {
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/InsertDataOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/InsertDataOperation.java
deleted file mode 100644
index 2c985d9..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/InsertDataOperation.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-/**
- *
- * @author hasan
- */
-public class InsertDataOperation extends UpdateOperationWithQuads {
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/LoadOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/LoadOperation.java
deleted file mode 100644
index 8dfc69f..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/LoadOperation.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.sparql.update.UpdateOperation;
-
-/**
- * The LOAD operation reads an RDF document from a IRI and inserts its triples into the specified ImmutableGraph in the ImmutableGraph Store.
- * If the destination ImmutableGraph already exists, then no data in that ImmutableGraph will be removed.
- * If no destination ImmutableGraph IRI is provided to load the triples into, then the data will be loaded into the default ImmutableGraph.
- * @see <a href="http://www.w3.org/TR/2013/REC-sparql11-update-20130321/#load">SPARQL 1.1 Update: 3.1.4 LOAD</a>
- * @author hasan
- */
-public class LoadOperation extends SimpleUpdateOperation {
-
- public void setSource(IRI source) {
- setInputGraph(source);
- }
-
- public IRI getSource() {
- return getInputGraph(null);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ModifyOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ModifyOperation.java
deleted file mode 100644
index 97ce39b..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/ModifyOperation.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.access.TcProvider;
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleDataSet;
-import org.apache.clerezza.rdf.core.sparql.update.UpdateOperation;
-
-/**
- * This ModifyOperation is a DELETE/INSERT operation.
- * @see <a href="http://www.w3.org/TR/2013/REC-sparql11-update-20130321/#deleteInsert">SPARQL 1.1 Update: 3.1.3 DELETE/INSERT</a>
- *
- * The DELETE/INSERT operation can be used to remove or add triples from/to the ImmutableGraph Store based on bindings
- * for a query pattern specified in a WHERE clause.
- *
- * @author hasan
- */
-public class ModifyOperation implements UpdateOperation {
- private IRI fallbackGraph = null;
- private UpdateOperationWithQuads deleteOperation = null;
- private UpdateOperationWithQuads insertOperation = null;
- private SimpleDataSet dataSet = null;
- private GroupGraphPattern queryPattern = null;
-
- public void setFallbackGraph(IRI fallbackGraph) {
- this.fallbackGraph = fallbackGraph;
- }
-
- public void setDeleteOperation(UpdateOperationWithQuads deleteOperation) {
- this.deleteOperation = deleteOperation;
- }
-
- public void setInsertOperation(UpdateOperationWithQuads insertOperation) {
- this.insertOperation = insertOperation;
- }
-
- public void setDataSet(SimpleDataSet dataSet) {
- this.dataSet = dataSet;
- }
-
- public void addGraphToDataSet(IRI ImmutableGraph) {
- if (dataSet == null) {
- dataSet = new SimpleDataSet();
- }
- dataSet.addDefaultGraph(ImmutableGraph);
- }
-
- public void addNamedGraphToDataSet(IRI namedGraph) {
- if (dataSet == null) {
- dataSet = new SimpleDataSet();
- }
- dataSet.addNamedGraph(namedGraph);
- }
-
- public void setQueryPattern(GroupGraphPattern queryPattern) {
- this.queryPattern = queryPattern;
- }
-
- @Override
- public Set<IRI> getInputGraphs(IRI defaultGraph, TcProvider tcProvider) {
- Set<IRI> graphs = new HashSet<IRI>();
- if (dataSet != null) {
- graphs.addAll(dataSet.getDefaultGraphs());
- graphs.addAll(dataSet.getNamedGraphs());
- } else {
- if (fallbackGraph != null) {
- graphs.add(fallbackGraph);
- }
- }
- if (graphs.isEmpty()) {
- graphs.add(defaultGraph);
- }
- if (queryPattern != null) {
- graphs.addAll(queryPattern.getReferredGraphs());
- }
- return graphs;
- }
-
- @Override
- public Set<IRI> getDestinationGraphs(IRI defaultGraph, TcProvider tcProvider) {
- Set<IRI> graphs = new HashSet<IRI>();
- IRI dfltGraph = (fallbackGraph != null) ? fallbackGraph : defaultGraph;
- if (deleteOperation != null) {
- graphs.addAll(deleteOperation.getDestinationGraphs(dfltGraph, tcProvider));
- }
- if (insertOperation != null) {
- graphs.addAll(insertOperation.getDestinationGraphs(dfltGraph, tcProvider));
- }
- return graphs;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/MoveOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/MoveOperation.java
deleted file mode 100644
index 84bc569..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/MoveOperation.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-/**
- *
- * @author hasan
- */
-public class MoveOperation extends SimpleUpdateOperation {
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/Quad.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/Quad.java
deleted file mode 100644
index ff26de0..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/Quad.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-import java.util.Set;
-import org.apache.clerezza.rdf.core.sparql.query.TriplePattern;
-import org.apache.clerezza.rdf.core.sparql.query.UriRefOrVariable;
-import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleBasicGraphPattern;
-
-/**
- *
- * @author hasan
- */
-public class Quad extends SimpleBasicGraphPattern {
-
- private UriRefOrVariable ImmutableGraph = null;
-
- public Quad(UriRefOrVariable ImmutableGraph, Set<TriplePattern> triplePatterns) {
- super(triplePatterns);
- this.ImmutableGraph = ImmutableGraph;
- }
-
- public UriRefOrVariable getGraph() {
- return this.ImmutableGraph;
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleUpdate.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleUpdate.java
deleted file mode 100644
index c91ee95..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleUpdate.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.access.TcProvider;
-import org.apache.clerezza.rdf.core.sparql.update.Update;
-import org.apache.clerezza.rdf.core.sparql.update.UpdateOperation;
-
-/**
- *
- * @author hasan
- */
-public class SimpleUpdate implements Update {
- protected List<UpdateOperation> operations = new ArrayList<UpdateOperation>();
-
- @Override
- public Set<IRI> getReferredGraphs(IRI defaultGraph, TcProvider tcProvider) {
- Set<IRI> referredGraphs = new HashSet<IRI>();
- for (UpdateOperation operation : operations) {
- referredGraphs.addAll(operation.getInputGraphs(defaultGraph, tcProvider));
- referredGraphs.addAll(operation.getDestinationGraphs(defaultGraph, tcProvider));
- }
- return referredGraphs;
- }
-
- @Override
- public void addOperation(UpdateOperation updateOperation) {
- operations.add(updateOperation);
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleUpdateOperation.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleUpdateOperation.java
deleted file mode 100644
index 6042536..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/SimpleUpdateOperation.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.sparql.update.UpdateOperation;
-
-/**
- *
- * @author hasan
- */
-public class SimpleUpdateOperation extends BaseUpdateOperation {
-
- private boolean silent;
-
- public SimpleUpdateOperation() {
- this.silent = false;
- inputGraphSpec = UpdateOperation.GraphSpec.DEFAULT;
- destinationGraphSpec = UpdateOperation.GraphSpec.DEFAULT;
- }
-
- public void setSilent(boolean silent) {
- this.silent = silent;
- }
-
- public boolean isSilent() {
- return silent;
- }
-
- public void setInputGraph(IRI source) {
- inputGraphSpec = UpdateOperation.GraphSpec.GRAPH;
- inputGraphs.clear();
- inputGraphs.add(source);
- }
-
- public IRI getInputGraph(IRI defaultGraph) {
- Set<IRI> result = getInputGraphs(defaultGraph, null);
- if (result.isEmpty()) {
- return null;
- } else {
- return result.iterator().next();
- }
- }
-
- public void setDestinationGraph(IRI destination) {
- destinationGraphSpec = UpdateOperation.GraphSpec.GRAPH;
- destinationGraphs.clear();
- destinationGraphs.add(destination);
- }
-
- public IRI getDestinationGraph(IRI defaultGraph) {
- Set<IRI> result = getDestinationGraphs(defaultGraph, null);
- if (result.isEmpty()) {
- return null;
- } else {
- return result.iterator().next();
- }
- }
-}
diff --git a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/UpdateOperationWithQuads.java b/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/UpdateOperationWithQuads.java
deleted file mode 100644
index 5b2ea57..0000000
--- a/rdf/core/src/main/java/org/apache/clerezza/rdf/core/sparql/update/impl/UpdateOperationWithQuads.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql.update.impl;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.access.TcProvider;
-import org.apache.clerezza.rdf.core.sparql.query.TriplePattern;
-import org.apache.clerezza.rdf.core.sparql.query.UriRefOrVariable;
-import org.apache.clerezza.rdf.core.sparql.update.UpdateOperation;
-
-/**
- *
- * @author hasan
- */
-public class UpdateOperationWithQuads implements UpdateOperation {
-
- private Quad defaultQuad = null;
- private List<Quad> quads = new ArrayList<Quad>();
-
- public UpdateOperationWithQuads() {
- }
-
- public void addQuad(Set<TriplePattern> triplePatterns) {
- if (defaultQuad == null) {
- defaultQuad = new Quad(null, triplePatterns);
- } else {
- defaultQuad.addTriplePatterns(triplePatterns);
- }
- }
-
- public void addQuad(UriRefOrVariable ImmutableGraph, Set<TriplePattern> triplePatterns) {
- if (ImmutableGraph == null) {
- addQuad(triplePatterns);
- } else {
- quads.add(new Quad(ImmutableGraph, triplePatterns));
- }
- }
-
- @Override
- public Set<IRI> getInputGraphs(IRI defaultGraph, TcProvider tcProvider) {
- return new HashSet<IRI>();
- }
-
- @Override
- public Set<IRI> getDestinationGraphs(IRI defaultGraph, TcProvider tcProvider) {
- Set<IRI> graphs = new HashSet<IRI>();
- if (defaultQuad != null) {
- graphs.add(defaultGraph);
- }
- for (Quad quad : quads) {
- UriRefOrVariable ImmutableGraph = quad.getGraph();
- if (!ImmutableGraph.isVariable()) {
- graphs.add(ImmutableGraph.getResource());
- }
- }
- return graphs;
- }
-}
diff --git a/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/QueryParserSerializerCombinationTest.java b/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/QueryParserSerializerCombinationTest.java
deleted file mode 100644
index 50eeee5..0000000
--- a/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/QueryParserSerializerCombinationTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql;
-
-import org.apache.clerezza.rdf.core.sparql.query.Query;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- * @author hasan
- */
-public class QueryParserSerializerCombinationTest {
-
- public QueryParserSerializerCombinationTest() {
- }
-
- @BeforeClass
- public static void setUpClass() {
- }
-
- @AfterClass
- public static void tearDownClass() {
- }
-
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() {
- }
-
- @Test
- public void testPatternOrderPreservation() throws Exception {
- String queryString =
- "SELECT ?property ?range ?property_description ?subproperty ?subproperty_description \n"
- + "WHERE\n"
- + "{ ?property <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#ObjectProperty> .\n"
- + "{ { ?property <http://www.w3.org/2000/01/rdf-schema#domain> ?superclass .\n"
- + "<http://example.org/ontologies/market_ontology.owl#Company> <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?superclass .\n"
- + "} UNION { ?property <http://www.w3.org/2000/01/rdf-schema#domain> ?dunion .\n"
- + "?dunion <http://www.w3.org/2002/07/owl#unionOf> ?dlist .\n"
- + "?dlist <http://jena.hpl.hp.com/ARQ/list#member> ?superclass .\n"
- + "<http://example.org/ontologies/market_ontology.owl#Company> <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?superclass .\n"
- + "} } { { ?property <http://www.w3.org/2000/01/rdf-schema#range> ?superrange .\n"
- + "?range <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?superrange .\n"
- + "FILTER (! (isBLANK(?range)))\n"
- + "} UNION { ?property <http://www.w3.org/2000/01/rdf-schema#range> ?range .\n"
- + "FILTER (! (isBLANK(?range)))\n"
- + "} } OPTIONAL { ?somesub <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?range .\n"
- + "FILTER (((?somesub) != (<http://www.w3.org/2002/07/owl#Nothing>)) && ((?somesub) != (?range)))\n"
- + "} OPTIONAL { ?subproperty <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?property .\n"
- + " OPTIONAL { ?subproperty <http://purl.org/dc/elements/1.1/description> ?subproperty_description .\n"
- + "} FILTER (((?subproperty) != (<http://www.w3.org/2002/07/owl#bottomObjectProperty>)) && ((?subproperty) != (?property)))\n"
- + "} OPTIONAL { ?property <http://purl.org/dc/elements/1.1/description> ?property_description .\n"
- + "} FILTER ((?property) != (<http://www.w3.org/2002/07/owl#bottomObjectProperty>))\n"
- + "FILTER ((?range) != (<http://www.w3.org/2002/07/owl#Nothing>))\n"
- + "FILTER (! (BOUND(?somesub)))\n"
- + "} \n";
-
- Query query = QueryParser.getInstance().parse(queryString);
- Assert.assertEquals(queryString.replaceAll("\\s", "").trim(), query.toString().replaceAll("\\s", "").trim());
- }
-
- @Test
- public void testParsingAndSerializationStability() throws Exception {
- String queryString =
- "PREFIX mo: <http://example.org/ontologies/market_ontology.owl#>\n"
- + "PREFIX list: <http://jena.hpl.hp.com/ARQ/list#>\n"
- + "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n"
- + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
- + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
- + "PREFIX dc: <http://purl.org/dc/elements/1.1/>\n"
- + "SELECT ?property ?range ?property_description ?subproperty ?subproperty_description\n"
- + "WHERE {\n"
- + " ?property a owl:ObjectProperty .\n"
- + " FILTER (?property != owl:bottomObjectProperty) .\n"
- + " {\n"
- + " {\n"
- + " ?property rdfs:domain ?superclass .\n"
- + " mo:Company rdfs:subClassOf ?superclass .\n"
- + " }\n"
- + " UNION\n"
- + " {\n"
- + " ?property rdfs:domain ?dunion .\n"
- + " ?dunion owl:unionOf ?dlist .\n"
- + " ?dlist list:member ?superclass .\n"
- + " mo:Company rdfs:subClassOf ?superclass .\n"
- + " }\n"
- + " }\n"
- + " {\n"
- + " {\n"
- + " ?property rdfs:range ?superrange .\n"
- + " ?range rdfs:subClassOf ?superrange .\n"
- + " FILTER (!isBlank(?range)) .\n"
- + " }\n"
- + " UNION\n"
- + " {\n"
- + " ?property rdfs:range ?range .\n"
- + " FILTER (!isBlank(?range)) .\n"
- + " }\n"
- + " } .\n"
- + " FILTER (?range != owl:Nothing) .\n"
- + " OPTIONAL { ?somesub rdfs:subClassOf ?range . FILTER(?somesub != owl:Nothing && ?somesub != ?range)}\n"
- + " FILTER (!bound(?somesub)) .\n"
- + " OPTIONAL {\n"
- + " ?subproperty rdfs:subPropertyOf ?property .\n"
- + " FILTER(?subproperty != owl:bottomObjectProperty && ?subproperty != ?property)\n"
- + " OPTIONAL { ?subproperty dc:description ?subproperty_description . }\n"
- + " }\n"
- + " OPTIONAL { ?property dc:description ?property_description . }\n"
- + "} ";
-
- Query query1 = QueryParser.getInstance().parse(queryString);
- Thread.sleep(5000l);
- Query query2 = QueryParser.getInstance().parse(queryString);
- Assert.assertEquals(query1.toString(), query2.toString());
- }
-}
diff --git a/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/QueryParserTest.java b/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/QueryParserTest.java
deleted file mode 100644
index f39e338..0000000
--- a/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/QueryParserTest.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.clerezza.commons.rdf.Language;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl;
-import org.apache.clerezza.rdf.core.sparql.query.AskQuery;
-import org.apache.clerezza.rdf.core.sparql.query.BasicGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.BuiltInCall;
-import org.apache.clerezza.rdf.core.sparql.query.ConstructQuery;
-import org.apache.clerezza.rdf.core.sparql.query.DescribeQuery;
-import org.apache.clerezza.rdf.core.sparql.query.Expression;
-import org.apache.clerezza.rdf.core.sparql.query.GraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.OptionalGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.OrderCondition;
-import org.apache.clerezza.rdf.core.sparql.query.Query;
-import org.apache.clerezza.rdf.core.sparql.query.QueryWithSolutionModifier;
-import org.apache.clerezza.rdf.core.sparql.query.ResourceOrVariable;
-import org.apache.clerezza.rdf.core.sparql.query.SelectQuery;
-import org.apache.clerezza.rdf.core.sparql.query.TriplePattern;
-import org.apache.clerezza.rdf.core.sparql.query.UnaryOperation;
-import org.apache.clerezza.rdf.core.sparql.query.UriRefOrVariable;
-import org.apache.clerezza.rdf.core.sparql.query.Variable;
-import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleTriplePattern;
-
-/**
- *
- * @author hasan
- */
-public class QueryParserTest {
-
- @Test
- public void testSelectQuery() throws ParseException {
-
-// SELECT ?title FROM <http://example.org/library>
-// WHERE { <http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> ?title . }
-
- final String variable = "title";
- final String defaultGraph = "http://example.org/library";
- final String subject = "http://example.org/book/book1";
- final String predicate = "http://purl.org/dc/elements/1.1/title";
-
- StringBuffer queryStrBuf = new StringBuffer();
- queryStrBuf.append("SELECT ?").append(variable)
- .append(" FROM <").append(defaultGraph)
- .append("> WHERE { <").append(subject).append("> <")
- .append(predicate).append("> ?").append(variable).append(" . }");
-
- Query q = QueryParser.getInstance().parse(queryStrBuf.toString());
- Assert.assertTrue(SelectQuery.class.isAssignableFrom(q.getClass()));
- SelectQuery selectQuery = (SelectQuery) q;
- Assert.assertTrue(selectQuery.getSelection().get(0)
- .equals(new Variable(variable)));
- Assert.assertTrue(selectQuery.getDataSet().getDefaultGraphs().toArray()[0]
- .equals(new IRI(defaultGraph)));
-
- GraphPattern gp = (GraphPattern) selectQuery.getQueryPattern()
- .getGraphPatterns().toArray()[0];
- Assert.assertTrue(BasicGraphPattern.class.isAssignableFrom(gp.getClass()));
- BasicGraphPattern bgp = (BasicGraphPattern) gp;
-
- Set<TriplePattern> triplePatterns = bgp.getTriplePatterns();
- Assert.assertTrue(triplePatterns.size()==1);
-
- ResourceOrVariable s = new ResourceOrVariable(new IRI(subject));
- UriRefOrVariable p = new UriRefOrVariable(new IRI(predicate));
- ResourceOrVariable o = new ResourceOrVariable(new Variable(variable));
-
- Assert.assertTrue(triplePatterns.contains(
- new SimpleTriplePattern(s, p, o)));
- }
-
- @Test(expected=ParseException.class)
- public void testInvalidQuery() throws ParseException {
- Query q = QueryParser.getInstance().parse("Hello");
- }
-
- @Test
- public void testSelectQuerySelection() throws ParseException {
- SelectQuery q = (SelectQuery) QueryParser.getInstance().parse(
- "SELECT ?a ?b WHERE {?a ?x ?b}");
- Set<Variable> selectionSet = new HashSet<Variable>(
- q.getSelection());
- Set<Variable> expected = new HashSet<Variable>();
- expected.add(new Variable("a"));
- expected.add(new Variable("b"));
- Assert.assertEquals(expected, selectionSet);
- Assert.assertFalse(q.isSelectAll());
-
- }
-
- @Test
- public void testSelectAll() throws ParseException {
- SelectQuery q = (SelectQuery) QueryParser.getInstance().parse(
- "SELECT * WHERE {?a ?x ?b}");
- Set<Variable> selectionSet = new HashSet<Variable>(
- q.getSelection());
- Set<Variable> expected = new HashSet<Variable>();
- expected.add(new Variable("a"));
- expected.add(new Variable("b"));
- expected.add(new Variable("x"));
- Assert.assertEquals(expected, selectionSet);
- Assert.assertTrue(q.isSelectAll());
-
- }
-
- @Test
- public void testPlainLiteral() throws ParseException {
- SelectQuery q = (SelectQuery) QueryParser.getInstance().parse(
- "SELECT * WHERE {?a ?x 'tiger' . ?a ?x 'lion'@en . }");
-
- GraphPattern gp = (GraphPattern) q.getQueryPattern()
- .getGraphPatterns().toArray()[0];
- Assert.assertTrue(BasicGraphPattern.class.isAssignableFrom(gp.getClass()));
- BasicGraphPattern bgp = (BasicGraphPattern) gp;
-
- Set<TriplePattern> triplePatterns = bgp.getTriplePatterns();
- Assert.assertTrue(triplePatterns.size()==2);
-
- Assert.assertTrue(triplePatterns.contains(new SimpleTriplePattern(
- new Variable("a"), new Variable("x"),
- new PlainLiteralImpl("tiger"))));
-
- Assert.assertTrue(triplePatterns.contains(new SimpleTriplePattern(
- new Variable("a"), new Variable("x"),
- new PlainLiteralImpl("lion", new Language("en")))));
- }
-
- @Test
- public void testOrderBy() throws ParseException {
- SelectQuery q = (SelectQuery) QueryParser.getInstance().parse(
- "SELECT * WHERE {?a ?x ?b} ORDER BY DESC(?b)");
-
- List<OrderCondition> oc = ((QueryWithSolutionModifier) q).getOrderConditions();
- Assert.assertTrue(oc.size()==1);
- Assert.assertFalse(oc.get(0).isAscending());
- Variable b = new Variable("b");
- Assert.assertEquals(b, oc.get(0).getExpression());
- }
-
- @Test
- public void testConstructQuery() throws ParseException {
-
-// CONSTRUCT { <http://example.org/person#Alice> <http://www.w3.org/2001/vcard-rdf/3.0#FN> ?name}
-// WHERE { ?x <http://xmlns.com/foaf/0.1/name> ?name}
-
-
- final String variable1 = "name";
- final String variable2 = "x";
- final String subject1 = "http://example.org/person#Alice";
- final String predicate1 = "http://www.w3.org/2001/vcard-rdf/3.0#FN";
- final String predicate2 = "http://xmlns.com/foaf/0.1/name";
-
- StringBuffer queryStrBuf = new StringBuffer();
- queryStrBuf.append("CONSTRUCT { <").append(subject1).append("> <")
- .append(predicate1).append("> ?").append(variable1)
- .append("} WHERE { ?").append(variable2).append(" <")
- .append(predicate2).append("> ?").append(variable1).append("}");
-
- Query q = QueryParser.getInstance().parse(queryStrBuf.toString());
- Assert.assertTrue(ConstructQuery.class.isAssignableFrom(q.getClass()));
- ConstructQuery constructQuery = (ConstructQuery) q;
- Set<TriplePattern> triplePatterns = constructQuery
- .getConstructTemplate();
- Assert.assertTrue(triplePatterns.size()==1);
-
- ResourceOrVariable s = new ResourceOrVariable(new IRI(subject1));
- UriRefOrVariable p = new UriRefOrVariable(new IRI(predicate1));
- ResourceOrVariable o = new ResourceOrVariable(new Variable(variable1));
-
- Assert.assertTrue(triplePatterns.contains(
- new SimpleTriplePattern(s, p, o)));
-
- GraphPattern gp = (GraphPattern) constructQuery.getQueryPattern()
- .getGraphPatterns().toArray()[0];
- Assert.assertTrue(BasicGraphPattern.class.isAssignableFrom(gp.getClass()));
- BasicGraphPattern bgp = (BasicGraphPattern) gp;
- triplePatterns = bgp.getTriplePatterns();
- Assert.assertTrue(triplePatterns.size()==1);
-
- s = new ResourceOrVariable(new Variable(variable2));
- p = new UriRefOrVariable(new IRI(predicate2));
-
- Assert.assertTrue(triplePatterns.contains(
- new SimpleTriplePattern(s, p, o)));
- }
-
- @Test
- public void testDescribeQuery() throws ParseException {
-
-// DESCRIBE <http://example.org/book/book1>
-
- final String resource = "http://example.org/book/book1";
-
- StringBuffer queryStrBuf = new StringBuffer();
- queryStrBuf.append("DESCRIBE <").append(resource).append(">");
-
- Query q = QueryParser.getInstance().parse(queryStrBuf.toString());
- Assert.assertTrue(DescribeQuery.class.isAssignableFrom(q.getClass()));
- DescribeQuery describeQuery = (DescribeQuery) q;
- Assert.assertTrue(describeQuery.getResourcesToDescribe().get(0)
- .getResource().equals(new IRI(resource)));
- }
-
- @Test
- public void testAskQuery() throws ParseException {
-
-// ASK { ?x <http://xmlns.com/foaf/0.1/name> "Alice" }
-
- final String variable = "x";
- final String predicate = "http://xmlns.com/foaf/0.1/name";
- final String object = "Alice";
-
- StringBuffer queryStrBuf = new StringBuffer();
- queryStrBuf.append("ASK { ?").append(variable).append(" <")
- .append(predicate).append("> \"").append(object).append("\" }");
-
- Query q = QueryParser.getInstance().parse(queryStrBuf.toString());
- Assert.assertTrue(AskQuery.class.isAssignableFrom(q.getClass()));
- AskQuery askQuery = (AskQuery) q;
-
- GraphPattern gp = (GraphPattern) askQuery.getQueryPattern()
- .getGraphPatterns().toArray()[0];
- Assert.assertTrue(BasicGraphPattern.class.isAssignableFrom(gp.getClass()));
- BasicGraphPattern bgp = (BasicGraphPattern) gp;
-
- Set<TriplePattern> triplePatterns = bgp.getTriplePatterns();
- Assert.assertTrue(triplePatterns.size()==1);
-
- Assert.assertTrue(triplePatterns.contains(new SimpleTriplePattern(new Variable(variable),
- new IRI(predicate), new PlainLiteralImpl(object))));
- }
-
- @Test
- public void testBaseAndPrefix() throws ParseException {
-
-// BASE <http://example.org/book/>
-// PREFIX dc: <http://purl.org/dc/elements/1.1/>
-//
-// SELECT $title
-// WHERE { <book1> dc:title ?title }
-
- final String base = "http://example.org/book/";
- final String prefix = "dc";
- final String prefixUri = "http://purl.org/dc/elements/1.1/";
- final String variable = "title";
- final String subject = "book1";
- final String predicate = "title";
-
- StringBuffer queryStrBuf = new StringBuffer();
- queryStrBuf.append("BASE <").append(base).append(">")
- .append(" PREFIX ").append(prefix).append(": <")
- .append(prefixUri).append("> SELECT $").append(variable)
- .append(" WHERE { <").append(subject).append("> ")
- .append(prefix).append(":").append(predicate).append(" ?")
- .append(variable).append(" }");
-
- Query q = QueryParser.getInstance().parse(queryStrBuf.toString());
- Assert.assertTrue(SelectQuery.class.isAssignableFrom(q.getClass()));
- SelectQuery selectQuery = (SelectQuery) q;
- Assert.assertTrue(selectQuery.getSelection().get(0)
- .equals(new Variable(variable)));
-
- GraphPattern gp = (GraphPattern) selectQuery.getQueryPattern()
- .getGraphPatterns().toArray()[0];
- Assert.assertTrue(BasicGraphPattern.class.isAssignableFrom(gp.getClass()));
- BasicGraphPattern bgp = (BasicGraphPattern) gp;
-
- Set<TriplePattern> triplePatterns = bgp.getTriplePatterns();
- Assert.assertTrue(triplePatterns.size()==1);
-
- ResourceOrVariable s = new ResourceOrVariable(new IRI(base+subject));
- UriRefOrVariable p = new UriRefOrVariable(new IRI(prefixUri+predicate));
- ResourceOrVariable o = new ResourceOrVariable(new Variable(variable));
-
- Assert.assertTrue(triplePatterns.contains(
- new SimpleTriplePattern(s, p, o)));
- }
-
- @Test
- public void testOptionalAndFilter() throws ParseException {
-
-// PREFIX dc: <http://purl.org/dc/elements/1.1/>
-// PREFIX books: <http://example.org/book/>
-//
-// SELECT ?book ?title
-// WHERE
-// { ?book dc:title ?title .
-// OPTIONAL
-// { ?book books:author ?author .}
-// FILTER ( ! bound(?author) )
-// }
- final String prefix1 = "dc";
- final String prefix1Uri = "http://purl.org/dc/elements/1.1/";
- final String prefix2 = "books";
- final String prefix2Uri = "http://example.org/book/";
- final String variable1 = "book";
- final String variable2 = "title";
- final String variable3 = "author";
- final String predicate1 = "title";
- final String predicate2 = "author";
-
- StringBuffer queryStrBuf = new StringBuffer();
- queryStrBuf.append("PREFIX ").append(prefix1).append(": <").append(prefix1Uri)
- .append("> PREFIX ").append(prefix2).append(": <").append(prefix2Uri)
- .append("> SELECT ?").append(variable1).append(" ?").append(variable2)
- .append(" WHERE { ?").append(variable1).append(" ")
- .append(prefix1).append(":").append(predicate1)
- .append(" ?").append(variable2).append(" . OPTIONAL { ?")
- .append(variable1).append(" ").append(prefix2).append(":")
- .append(predicate2).append(" ?").append(variable3)
- .append(" .} FILTER ( ! bound(?").append(variable3).append(") ) }");
-
- Query q = QueryParser.getInstance().parse(queryStrBuf.toString());
- Assert.assertTrue(SelectQuery.class.isAssignableFrom(q.getClass()));
- SelectQuery selectQuery = (SelectQuery) q;
- Assert.assertTrue(selectQuery.getSelection().size() == 2);
- Set<Variable> vars = new HashSet<Variable>(2);
- Variable var1 = new Variable(variable1);
- Variable var2 = new Variable(variable2);
- vars.add(var1);
- vars.add(var2);
- Assert.assertTrue(selectQuery.getSelection().containsAll(vars));
-
- GroupGraphPattern ggp = selectQuery.getQueryPattern();
- List<Expression> constraints = ggp.getFilter();
- Assert.assertTrue(UnaryOperation.class.isAssignableFrom(constraints
- .get(0).getClass()));
- UnaryOperation uop = (UnaryOperation) constraints.get(0);
- Assert.assertTrue(uop.getOperatorString().equals("!"));
- Assert.assertTrue(BuiltInCall.class.isAssignableFrom(uop.getOperand()
- .getClass()));
- BuiltInCall bic = (BuiltInCall) uop.getOperand();
- Assert.assertTrue(bic.getName().equals("BOUND"));
- Variable var3 = new Variable(variable3);
- Assert.assertTrue(bic.getArguements().get(0).equals(var3));
-
- GraphPattern gp = (GraphPattern) ggp.getGraphPatterns().toArray()[0];
- Assert.assertTrue(OptionalGraphPattern.class.isAssignableFrom(gp.getClass()));
- OptionalGraphPattern ogp = (OptionalGraphPattern) gp;
- Assert.assertTrue(BasicGraphPattern.class.isAssignableFrom(
- ogp.getMainGraphPattern().getClass()));
- BasicGraphPattern bgp = (BasicGraphPattern) ogp.getMainGraphPattern();
-
- Set<TriplePattern> triplePatterns = bgp.getTriplePatterns();
- Assert.assertTrue(triplePatterns.size() == 1);
- Assert.assertTrue(triplePatterns.contains(new SimpleTriplePattern(var1, new IRI(prefix1Uri + predicate1),
- var2)));
-
- GraphPattern gp2 = (GraphPattern) ogp.getOptionalGraphPattern()
- .getGraphPatterns().toArray()[0];
- Assert.assertTrue(BasicGraphPattern.class.isAssignableFrom(gp2.getClass()));
- bgp = (BasicGraphPattern) gp2;
-
- triplePatterns = bgp.getTriplePatterns();
- Assert.assertTrue(triplePatterns.size() == 1);
- Assert.assertTrue(triplePatterns.contains(new SimpleTriplePattern(var1, new IRI(prefix2Uri + predicate2),
- var3)));
- }
-}
diff --git a/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/QuerySerializerTest.java b/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/QuerySerializerTest.java
deleted file mode 100644
index eccf13f..0000000
--- a/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/QuerySerializerTest.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.clerezza.rdf.core.LiteralFactory;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.sparql.query.BinaryOperation;
-import org.apache.clerezza.rdf.core.sparql.query.BuiltInCall;
-import org.apache.clerezza.rdf.core.sparql.query.Expression;
-import org.apache.clerezza.rdf.core.sparql.query.LiteralExpression;
-import org.apache.clerezza.rdf.core.sparql.query.ResourceOrVariable;
-import org.apache.clerezza.rdf.core.sparql.query.TriplePattern;
-import org.apache.clerezza.rdf.core.sparql.query.UriRefExpression;
-import org.apache.clerezza.rdf.core.sparql.query.UriRefOrVariable;
-import org.apache.clerezza.rdf.core.sparql.query.Variable;
-import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleAskQuery;
-import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleBasicGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleConstructQuery;
-import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleDescribeQuery;
-import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleGroupGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleOptionalGraphPattern;
-import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleOrderCondition;
-import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleSelectQuery;
-import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleTriplePattern;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- *
- * @author hasan
- */
-public class QuerySerializerTest {
-
- @Test
- public void testSelectQuery() {
-
- final String queryString = "SELECT ?title FROM <http://example.org/library>" +
- " WHERE { <http://example.org/book/book1>" +
- " <http://purl.org/dc/elements/1.1/title> ?title . }";
-
- SimpleSelectQuery selectQuery = new SimpleSelectQuery();
- Variable variable = new Variable("title");
- selectQuery.addSelection(variable);
- IRI defaultGraph = new IRI("http://example.org/library");
- selectQuery.addDefaultGraph(defaultGraph);
- ResourceOrVariable subject = new ResourceOrVariable(
- new IRI("http://example.org/book/book1"));
- UriRefOrVariable predicate = new UriRefOrVariable(
- new IRI("http://purl.org/dc/elements/1.1/title"));
- ResourceOrVariable object = new ResourceOrVariable(variable);
- TriplePattern triplePattern = new SimpleTriplePattern(subject, predicate, object);
- Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
- triplePatterns.add(triplePattern);
-
- SimpleBasicGraphPattern bgp = new SimpleBasicGraphPattern(triplePatterns);
- SimpleGroupGraphPattern queryPattern = new SimpleGroupGraphPattern();
- queryPattern.addGraphPattern(bgp);
- selectQuery.setQueryPattern(queryPattern);
-
- Assert.assertTrue(selectQuery.toString()
- .replaceAll("( |\n)+", " ").trim().equals(queryString));
- }
-
- @Test
- public void testConstructQuery() {
-
- final String queryString = "CONSTRUCT { <http://example.org/person#Alice> " +
- "<http://www.w3.org/2001/vcard-rdf/3.0#FN> ?name . } " +
- "WHERE { ?x <http://xmlns.com/foaf/0.1/name> ?name . }";
-
- ResourceOrVariable s = new ResourceOrVariable(
- new IRI("http://example.org/person#Alice"));
- UriRefOrVariable p = new UriRefOrVariable(
- new IRI("http://www.w3.org/2001/vcard-rdf/3.0#FN"));
- ResourceOrVariable o = new ResourceOrVariable(new Variable("name"));
- Set<TriplePattern> constructTriplePatterns = new HashSet<TriplePattern>();
- constructTriplePatterns.add(new SimpleTriplePattern(s, p, o));
- SimpleConstructQuery constructQuery = new SimpleConstructQuery(constructTriplePatterns);
-
- s = new ResourceOrVariable(new Variable("x"));
- p = new UriRefOrVariable(new IRI("http://xmlns.com/foaf/0.1/name"));
- Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
- triplePatterns.add(new SimpleTriplePattern(s, p, o));
-
- SimpleBasicGraphPattern bgp = new SimpleBasicGraphPattern(triplePatterns);
- SimpleGroupGraphPattern queryPattern = new SimpleGroupGraphPattern();
- queryPattern.addGraphPattern(bgp);
- constructQuery.setQueryPattern(queryPattern);
-
- Assert.assertTrue(constructQuery.toString()
- .replaceAll("( |\n)+", " ").trim().equals(queryString));
- }
-
- @Test
- public void testDescribeQuery() {
-
- final String queryString = "DESCRIBE <http://example.org/book/book1>";
-
- SimpleDescribeQuery describeQuery = new SimpleDescribeQuery();
- describeQuery.addResourceToDescribe(new ResourceOrVariable(
- new IRI("http://example.org/book/book1")));
-
- Assert.assertTrue(describeQuery.toString()
- .replaceAll("( |\n)+", " ").trim().equals(queryString));
- }
-
- @Test
- public void testAskQuery() {
-
- final String queryString = "ASK WHERE { ?x <http://xmlns.com/foaf/0.1/name> " +
- "\"Alice\"^^<http://www.w3.org/2001/XMLSchema#string> . }";
-
- ResourceOrVariable s = new ResourceOrVariable(new Variable("x"));
- UriRefOrVariable p = new UriRefOrVariable(
- new IRI("http://xmlns.com/foaf/0.1/name"));
- ResourceOrVariable o = new ResourceOrVariable(
- LiteralFactory.getInstance().createTypedLiteral("Alice"));
-
- Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
- triplePatterns.add(new SimpleTriplePattern(s, p, o));
- SimpleAskQuery askQuery = new SimpleAskQuery();
-
- SimpleBasicGraphPattern bgp = new SimpleBasicGraphPattern(triplePatterns);
- SimpleGroupGraphPattern queryPattern = new SimpleGroupGraphPattern();
- queryPattern.addGraphPattern(bgp);
- askQuery.setQueryPattern(queryPattern);
-
- Assert.assertTrue(askQuery.toString()
- .replaceAll("( |\n)+", " ").trim().equals(queryString));
- }
-
- /**
- * Ignoring: given that triplePatterns is a Set I don't see what is supposed
- * to guarantee the expected ordering.
- */
- @Ignore
- @Test
- public void testFilter() {
-
- final String queryString = "SELECT ?title ?price WHERE { " +
- "?x <http://purl.org/dc/elements/1.1/title> ?title . " +
- "?x <http://example.org/ns#price> ?price . " +
- "FILTER ((?price) < (\"30.5\"^^<http://www.w3.org/2001/XMLSchema#double>)) " +
- "}";
-
- Variable price = new Variable("price");
- Variable title = new Variable("title");
- SimpleSelectQuery selectQuery = new SimpleSelectQuery();
- selectQuery.addSelection(title);
- selectQuery.addSelection(price);
-
- Variable x = new Variable("x");
- Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
- triplePatterns.add(new SimpleTriplePattern(x,
- new IRI("http://example.org/ns#price"), price));
- triplePatterns.add(new SimpleTriplePattern(x,
- new IRI("http://purl.org/dc/elements/1.1/title"), title));
-
- SimpleBasicGraphPattern bgp = new SimpleBasicGraphPattern(triplePatterns);
- SimpleGroupGraphPattern queryPattern = new SimpleGroupGraphPattern();
- queryPattern.addGraphPattern(bgp);
- BinaryOperation constraint = new BinaryOperation("<",
- price, new LiteralExpression(LiteralFactory.getInstance().createTypedLiteral(30.5)));
- queryPattern.addConstraint(constraint);
- selectQuery.setQueryPattern(queryPattern);
-
- Assert.assertTrue(selectQuery.toString()
- .replaceAll("( |\n)+", " ").trim().equals(queryString));
- }
-
- @Test
- public void testUriRefExpression() {
-
- final String queryString = "SELECT ?resource WHERE { " +
- "?resource <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?myType . " +
- "FILTER ((?resource) = (<http://example.org/ontology#special>)) " +
- "}";
-
- Variable resource = new Variable("resource");
- SimpleSelectQuery selectQuery = new SimpleSelectQuery();
- selectQuery.addSelection(resource);
-
- Variable myType = new Variable("myType");
- Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
- triplePatterns.add(new SimpleTriplePattern(resource,
- new IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), myType));
-
- SimpleBasicGraphPattern bgp = new SimpleBasicGraphPattern(triplePatterns);
- SimpleGroupGraphPattern queryPattern = new SimpleGroupGraphPattern();
- queryPattern.addGraphPattern(bgp);
- BinaryOperation constraint = new BinaryOperation("=",
- resource, new UriRefExpression(new IRI("http://example.org/ontology#special")));
- queryPattern.addConstraint(constraint);
- selectQuery.setQueryPattern(queryPattern);
-
- Assert.assertTrue(selectQuery.toString()
- .replaceAll("( |\n)+", " ").trim().equals(queryString));
- }
-
- @Test
- public void testOrderBy() {
-
- final String queryString = "SELECT * WHERE { ?a ?b ?c . } ORDER BY DESC(?c)";
-
- Variable a = new Variable("a");
- Variable b = new Variable("b");
- Variable c = new Variable("c");
- SimpleSelectQuery selectQuery = new SimpleSelectQuery();
- selectQuery.setSelectAll();
- selectQuery.addSelection(a);
- selectQuery.addSelection(b);
- selectQuery.addSelection(c);
-
- Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
- triplePatterns.add(new SimpleTriplePattern(a, b, c));
- SimpleBasicGraphPattern bgp = new SimpleBasicGraphPattern(triplePatterns);
- SimpleGroupGraphPattern queryPattern = new SimpleGroupGraphPattern();
- queryPattern.addGraphPattern(bgp);
- selectQuery.setQueryPattern(queryPattern);
- selectQuery.addOrderCondition(new SimpleOrderCondition(c, false));
-
- Assert.assertTrue(selectQuery.toString()
- .replaceAll("( |\n)+", " ").trim().equals(queryString));
- }
-
- @Test
- public void testOptional() {
-
- final String queryString = "SELECT ?title ?price WHERE { " +
- "?x <http://purl.org/dc/elements/1.1/title> ?title . " +
- "OPTIONAL { ?x <http://example.org/ns#price> ?price . } " +
- "}";
-
- Variable title = new Variable("title");
- Variable price = new Variable("price");
- SimpleSelectQuery selectQuery = new SimpleSelectQuery();
- selectQuery.addSelection(title);
- selectQuery.addSelection(price);
-
- Variable x = new Variable("x");
- Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
- triplePatterns.add(new SimpleTriplePattern(x,
- new IRI("http://purl.org/dc/elements/1.1/title"), title));
-
- SimpleBasicGraphPattern bgp = new SimpleBasicGraphPattern(triplePatterns);
-
- Set<TriplePattern> triplePatternsOpt = new HashSet<TriplePattern>();
- triplePatternsOpt.add(new SimpleTriplePattern(x,
- new IRI("http://example.org/ns#price"), price));
-
- SimpleBasicGraphPattern bgpOpt =
- new SimpleBasicGraphPattern(triplePatternsOpt);
-
- SimpleGroupGraphPattern ggpOpt = new SimpleGroupGraphPattern();
- ggpOpt.addGraphPattern(bgpOpt);
-
- SimpleOptionalGraphPattern ogp = new SimpleOptionalGraphPattern(bgp, ggpOpt);
-
- SimpleGroupGraphPattern queryPattern = new SimpleGroupGraphPattern();
- queryPattern.addGraphPattern(ogp);
- selectQuery.setQueryPattern(queryPattern);
-
- Assert.assertTrue(selectQuery.toString()
- .replaceAll("( |\n)+", " ").trim().equals(queryString));
- }
-
- @Test
- public void testRegex() {
-
- final String queryString = "SELECT ?p WHERE { " +
- "<http://localhost/testitem> ?p ?x . " +
- "FILTER REGEX(?x,\".*uni.*\"^^<http://www.w3.org/2001/XMLSchema#string>) }";
-
- Variable p = new Variable("p");
- SimpleSelectQuery selectQuery = new SimpleSelectQuery();
- selectQuery.addSelection(p);
-
- Variable x = new Variable("x");
- Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
- triplePatterns.add(new SimpleTriplePattern(
- new IRI("http://localhost/testitem"), p, x));
-
- SimpleBasicGraphPattern bgp = new SimpleBasicGraphPattern(triplePatterns);
- SimpleGroupGraphPattern queryPattern = new SimpleGroupGraphPattern();
- queryPattern.addGraphPattern(bgp);
-
- List<Expression> arguments = new ArrayList<Expression>();
- arguments.add(x);
- arguments.add(new LiteralExpression(LiteralFactory.getInstance().
- createTypedLiteral(".*uni.*")));
- BuiltInCall constraint = new BuiltInCall("REGEX", arguments);
- queryPattern.addConstraint(constraint);
- selectQuery.setQueryPattern(queryPattern);
- Assert.assertTrue(selectQuery.toString()
- .replaceAll("( |\n)+", " ").trim().equals(queryString));
- }
-}
diff --git a/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java b/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java
deleted file mode 100644
index c56170c..0000000
--- a/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java
+++ /dev/null
@@ -1,505 +0,0 @@
-/*
- * 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.clerezza.rdf.core.sparql;
-
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.clerezza.commons.rdf.IRI;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.access.TcManagerTest;
-import org.apache.clerezza.rdf.core.access.providers.WeightedA;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- *
- * @author hasan
- */
-public class SparqlPreParserTest {
-
- private TcManager graphAccess;
- private final WeightedA weightedA = new WeightedA();
- private final static IRI DEFAULT_GRAPH = new IRI("http://example.org/default.graph");
- private final static IRI TEST_GRAPH = new IRI("http://example.org/test.graph");
-
- @Before
- public void setUp() {
- graphAccess = TcManager.getInstance();
- graphAccess.addWeightedTcProvider(weightedA);
- }
-
- @After
- public void tearDown() {
- graphAccess = TcManager.getInstance();
- graphAccess.removeWeightedTcProvider(weightedA);
- }
-
- @Test
- public void testDefaultGraphInSelectQuery() throws ParseException {
-
- StringBuilder queryStrBuilder = new StringBuilder();
- queryStrBuilder.append(
- "PREFIX : <http://example.org/>\n" +
- "SELECT ?x \n" +
- "{\n" +
- ":order :item/:price ?x\n" +
- "}\n");
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStrBuilder.toString(), DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(DEFAULT_GRAPH));
- }
-
- @Test
- public void testAllGraphReferenceInSelectQuery() throws ParseException {
-
- StringBuilder queryStrBuilder = new StringBuilder();
- queryStrBuilder.append("SELECT DISTINCT ?g { GRAPH ?g { ?s ?p ?o } }\n");
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStrBuilder.toString(), DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs == null);
- }
-
- @Test
- public void testSelectQuery() throws ParseException {
-
- StringBuilder queryStrBuilder = new StringBuilder();
- queryStrBuilder.append(
- "PREFIX : <http://example.org/>\n" +
- "SELECT ?x (foo(2*3, ?x < ?y) AS ?f) (GROUP_CONCAT(?x ; separator=\"|\") AS ?gc) (sum(distinct *) AS ?total)\n" +
- "FROM " + TEST_GRAPH.toString() + "\n" +
- "{\n" +
- ":order :item/:price ?x\n" +
- "}\n");
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStrBuilder.toString(), DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(TEST_GRAPH));
- }
-
- @Test
- public void testSimpleDescribe() throws ParseException {
-
- String queryStr = "DESCRIBE <http://example.org/>";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(DEFAULT_GRAPH));
- }
-
- @Test
- public void testLoadingToDefaultGraph() throws ParseException {
-
- String queryStr = "LOAD SILENT <http://example.org/mydata>";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Set<IRI> expected = new HashSet<>();
- expected.add(DEFAULT_GRAPH);
- expected.add(new IRI("http://example.org/mydata"));
- Assert.assertTrue(referredGraphs.containsAll(expected));
- }
-
- @Test
- public void testLoadingToGraph() throws ParseException {
-
- String queryStr = "LOAD SILENT <http://example.org/mydata> INTO GRAPH " + TEST_GRAPH.toString();
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Set<IRI> expected = new HashSet<>();
- expected.add(TEST_GRAPH);
- expected.add(new IRI("http://example.org/mydata"));
- Assert.assertTrue(referredGraphs.containsAll(expected));
- }
-
- @Test
- public void testClearingDefaultGraph() throws ParseException {
-
- String queryStr = "CLEAR SILENT DEFAULT";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(DEFAULT_GRAPH));
- }
-
- @Test
- public void testClearingNamedGraph() throws ParseException {
-
- String queryStr = "CLEAR SILENT NAMED";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.contains(TcManagerTest.uriRefA));
- }
-
- @Test
- public void testClearingGraph() throws ParseException {
-
- String queryStr = "CLEAR SILENT GRAPH " + TEST_GRAPH.toString();
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(TEST_GRAPH));
- }
-
- @Test
- public void testDroppingDefaultGraph() throws ParseException {
-
- String queryStr = "DROP SILENT DEFAULT";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(DEFAULT_GRAPH));
- }
-
- @Test
- public void testDroppingNamedGraph() throws ParseException {
-
- String queryStr = "DROP SILENT NAMED";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.contains(TcManagerTest.uriRefA));
- }
-
- @Test
- public void testDroppingGraph() throws ParseException {
-
- String queryStr = "DROP SILENT GRAPH " + TEST_GRAPH.toString();
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(TEST_GRAPH));
- }
-
- @Test
- public void testCreatingGraph() throws ParseException {
-
- String queryStr = "CREATE SILENT GRAPH " + TEST_GRAPH.toString();
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(TEST_GRAPH));
- }
-
- @Test
- public void testAddingTriplesFromDefaultGraphToNamedGraph() throws ParseException {
-
- String queryStr = "ADD SILENT DEFAULT TO GRAPH " + TEST_GRAPH.toString();
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Set<IRI> expected = new HashSet<>();
- expected.add(DEFAULT_GRAPH);
- expected.add(TEST_GRAPH);
- Assert.assertTrue(referredGraphs.containsAll(expected));
- }
-
- @Test
- public void testAddingTriplesFromNamedGraphToDefaultGraph() throws ParseException {
-
- String queryStr = "ADD SILENT GRAPH " + TEST_GRAPH.toString() + " TO DEFAULT";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Set<IRI> expected = new HashSet<>();
- expected.add(DEFAULT_GRAPH);
- expected.add(TEST_GRAPH);
- Assert.assertTrue(referredGraphs.containsAll(expected));
- }
-
- @Test
- public void testMovingTriplesFromDefaultGraphToNamedGraph() throws ParseException {
-
- String queryStr = "MOVE SILENT DEFAULT TO GRAPH " + TEST_GRAPH.toString();
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Set<IRI> expected = new HashSet<>();
- expected.add(DEFAULT_GRAPH);
- expected.add(TEST_GRAPH);
- Assert.assertTrue(referredGraphs.containsAll(expected));
- }
-
- @Test
- public void testMovingTriplesFromNamedGraphToDefaultGraph() throws ParseException {
-
- String queryStr = "MOVE SILENT GRAPH " + TEST_GRAPH.toString() + " TO DEFAULT";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Set<IRI> expected = new HashSet<>();
- expected.add(DEFAULT_GRAPH);
- expected.add(TEST_GRAPH);
- Assert.assertTrue(referredGraphs.containsAll(expected));
- }
-
- @Test
- public void testCopyingTriplesFromDefaultGraphToNamedGraph() throws ParseException {
-
- String queryStr = "COPY SILENT DEFAULT TO GRAPH " + TEST_GRAPH.toString();
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Set<IRI> expected = new HashSet<>();
- expected.add(DEFAULT_GRAPH);
- expected.add(TEST_GRAPH);
- Assert.assertTrue(referredGraphs.containsAll(expected));
- }
-
- @Test
- public void testCopyingTriplesFromNamedGraphToDefaultGraph() throws ParseException {
-
- String queryStr = "COPY SILENT GRAPH " + TEST_GRAPH.toString() + " TO DEFAULT";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Set<IRI> expected = new HashSet<>();
- expected.add(DEFAULT_GRAPH);
- expected.add(TEST_GRAPH);
- Assert.assertTrue(referredGraphs.containsAll(expected));
- }
-
- @Test
- public void testInsertDataToDefaultGraph() throws ParseException {
-
- String queryStr = "PREFIX dc: <http://purl.org/dc/elements/1.1/> INSERT DATA { \n" +
- "<http://example/book1> dc:title \"A new book\" ; dc:creator \"A.N.Other\" . }";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(DEFAULT_GRAPH));
- }
-
- @Test
- public void testInsertDataToNamedGraph() throws ParseException {
-
- String queryStr = "PREFIX ns: <http://example.org/ns#>\n" +
- "INSERT DATA { GRAPH " + TEST_GRAPH.toString() + " { <http://example/book1> ns:price 42 } }";
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(TEST_GRAPH));
- }
-
- @Test
- public void testDeleteDataInDefaultGraph() throws ParseException {
-
- String queryStr = "PREFIX dc: <http://purl.org/dc/elements/1.1/> DELETE DATA { \n" +
- "<http://example/book1> dc:title \"A new book\" ; dc:creator \"A.N.Other\" . }";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(DEFAULT_GRAPH));
- }
-
- @Test
- public void testDeleteDataInNamedGraph() throws ParseException {
-
- String queryStr = "PREFIX ns: <http://example.org/ns#>\n" +
- "DELETE DATA { GRAPH " + TEST_GRAPH.toString() + " { <http://example/book1> ns:price 42 } }";
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(TEST_GRAPH));
- }
-
- @Test
- public void testInsertAndDeleteData() throws ParseException {
-
- String queryStr = "PREFIX ns: <http://example.org/ns#> " +
- "INSERT DATA { <http://example/book1> ns:price 42 }; " +
- "DELETE DATA { GRAPH " + TEST_GRAPH.toString() + " { <http://example/book1> ns:price 42 } }";
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
-
- Set<IRI> expected = new HashSet<>();
- expected.add(DEFAULT_GRAPH);
- expected.add(TEST_GRAPH);
- Assert.assertTrue(referredGraphs.containsAll(expected));
- }
-
- @Test
- public void testDeleteWhereInDefaultGraph() throws ParseException {
-
- String queryStr = "PREFIX foaf: <http://xmlns.com/foaf/0.1/> " +
- "DELETE WHERE { ?person foaf:givenName 'Fred'; ?property ?value }";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
-
- Assert.assertTrue(referredGraphs.toArray()[0].equals(DEFAULT_GRAPH));
- }
-
- @Test
- public void testDeleteWhereInNamedGraphs() throws ParseException {
-
- String queryStr = "PREFIX foaf: <http://xmlns.com/foaf/0.1/> DELETE WHERE " +
- "{ GRAPH <http://example.com/names> { ?person foaf:givenName 'Fred' ; ?property1 ?value1 } " +
- " GRAPH <http://example.com/addresses> { ?person ?property2 ?value2 } }";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
-
- Set<IRI> expected = new HashSet<>();
- expected.add(new IRI("http://example.com/names"));
- expected.add(new IRI("http://example.com/addresses"));
- Assert.assertTrue(referredGraphs.containsAll(expected));
- }
-
- @Test
- public void testModifyOperationWithFallbackGraph() throws ParseException {
- String queryStr = "PREFIX foaf: <http://xmlns.com/foaf/0.1/> WITH " + TEST_GRAPH.toString() +
- " DELETE { ?person foaf:givenName 'Bill' } INSERT { ?person foaf:givenName 'William' }" +
- " WHERE { ?person foaf:givenName 'Bill' }";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Set<IRI> expected = new HashSet<>();
- expected.add(TEST_GRAPH);
- expected.add(DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.containsAll(expected));
- }
-
- @Test
- public void testDeleteOperationInDefaultGraph() throws ParseException {
- String queryStr = "PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> " +
- "DELETE { ?book ?p ?v } WHERE { ?book dc:date ?date . " +
- "FILTER ( ?date > \"1970-01-01T00:00:00-02:00\"^^xsd:dateTime ) ?book ?p ?v }";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(DEFAULT_GRAPH));
- }
-
- @Test
- public void testInsertOperationToNamedGraph() throws ParseException {
- String queryStr = "PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> " +
- "INSERT { GRAPH <http://example/bookStore2> { ?book ?p ?v } } " +
- "WHERE { GRAPH <http://example/bookStore> { ?book dc:date ?date . " +
- "FILTER ( ?date > \"1970-01-01T00:00:00-02:00\"^^xsd:dateTime ) ?book ?p ?v } }";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
-
- Set<IRI> expected = new HashSet<>();
- expected.add(new IRI("http://example/bookStore2"));
- expected.add(new IRI("http://example/bookStore"));
- Assert.assertTrue(referredGraphs.containsAll(expected));
- }
-
- @Test
- public void testInsertAndDeleteWithCommonPrefix() throws ParseException {
- String queryStr = "PREFIX dc: <http://purl.org/dc/elements/1.1/>\n" +
- "PREFIX dcmitype: <http://purl.org/dc/dcmitype/>\n" +
- "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n\n" +
- "INSERT\n" +
- " { GRAPH <http://example/bookStore2> { ?book ?p ?v } }\n" +
- "WHERE\n" +
- " { GRAPH <http://example/bookStore>\n" +
- " { ?book dc:date ?date . \n" +
- " FILTER ( ?date < \"2000-01-01T00:00:00-02:00\"^^xsd:dateTime )\n" +
- " ?book ?p ?v\n" +
- " }\n" +
- " } ;\n\n" +
- "WITH <http://example/bookStore>\n" +
- "DELETE\n" +
- " { ?book ?p ?v }\n" +
- "WHERE\n" +
- " { ?book dc:date ?date ;\n" +
- " dc:type dcmitype:PhysicalObject .\n" +
- " FILTER ( ?date < \"2000-01-01T00:00:00-02:00\"^^xsd:dateTime ) \n" +
- " ?book ?p ?v\n" +
- " }";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
-
- Set<IRI> expected = new HashSet<>();
- expected.add(new IRI("http://example/bookStore2"));
- expected.add(new IRI("http://example/bookStore"));
- Assert.assertTrue(referredGraphs.containsAll(expected));
- }
-
- @Test
- public void testExistsFunction() throws ParseException {
- String queryStr = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
- "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n\n" +
- "SELECT ?person\n" +
- "WHERE \n" +
- "{\n" +
- " ?person rdf:type foaf:Person .\n" +
- " FILTER EXISTS { ?person foaf:name ?name }\n" +
- "}";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(DEFAULT_GRAPH));
- }
-
- @Test
- public void testNotExistsFunction() throws ParseException {
- String queryStr = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
- "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n\n" +
- "SELECT ?person\n" +
- "WHERE \n" +
- "{\n" +
- " ?person rdf:type foaf:Person .\n" +
- " FILTER NOT EXISTS { ?person foaf:name ?name }\n" +
- "}";
-
- SparqlPreParser parser;
- parser = new SparqlPreParser(TcManager.getInstance());
- Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
- Assert.assertTrue(referredGraphs.toArray()[0].equals(DEFAULT_GRAPH));
- }
-}