You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2014/01/08 16:25:25 UTC
[09/51] [abbrv] [partial] MARMOTTA-397: Reorganized and renamed
Marmotta Sesame Tools
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-util-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/UriRegexFilter.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-util-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/UriRegexFilter.java b/commons/marmotta-sesame-tools/marmotta-util-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/UriRegexFilter.java
new file mode 100644
index 0000000..c965916
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-util-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/resource/UriRegexFilter.java
@@ -0,0 +1,72 @@
+/**
+ * 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.marmotta.commons.sesame.filter.resource;
+
+import org.openrdf.model.Resource;
+import org.openrdf.model.URI;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+/**
+ * A filter only accepting URI resources where the URI matches one of the configured patterns.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class UriRegexFilter implements ResourceFilter {
+
+ private Set<Pattern> patterns;
+
+
+ public UriRegexFilter(Collection<String> regexps) {
+ patterns = new HashSet<Pattern>();
+
+ for(String s : regexps) {
+ Pattern p = Pattern.compile(s);
+ patterns.add(p);
+ }
+
+ }
+
+ /**
+ * Return false in case the filter does not accept the resource passed as argument, true otherwise.
+ *
+ *
+ * @param resource
+ * @return
+ */
+ @Override
+ public boolean accept(Resource resource) {
+ if(! (resource instanceof URI)) {
+ return false;
+ }
+
+ URI uri = (URI) resource;
+
+ for(Pattern p : patterns) {
+ if(p.matcher(uri.stringValue()).matches()) {
+ return true;
+ }
+ }
+
+
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-util-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/statement/StatementFilter.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-util-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/statement/StatementFilter.java b/commons/marmotta-sesame-tools/marmotta-util-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/statement/StatementFilter.java
new file mode 100644
index 0000000..3969e73
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-util-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/statement/StatementFilter.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.filter.statement;
+
+import org.apache.marmotta.commons.sesame.filter.SesameFilter;
+import org.openrdf.model.Statement;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert (sschaffert@apache.org)
+ */
+public interface StatementFilter extends SesameFilter<Statement> {
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-util-tripletable/pom.xml
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-util-tripletable/pom.xml b/commons/marmotta-sesame-tools/marmotta-util-tripletable/pom.xml
new file mode 100644
index 0000000..15c7a03
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-util-tripletable/pom.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>marmotta-parent</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ <relativePath>../../../parent/</relativePath>
+ </parent>
+
+ <artifactId>marmotta-util-tripletable</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Marmotta Sesame Tools: Triple Table</name>
+
+ <description>
+ Provides a simple in-memory table using the Java Collections API to access triples. Additionally, the
+ triple table offers in-memory indexes for typical query operations (e.g. listing by subject).
+ </description>
+
+ <dependencies>
+ <!-- data model -->
+ <dependency>
+ <groupId>org.openrdf.sesame</groupId>
+ <artifactId>sesame-model</artifactId>
+ </dependency>
+
+ <!-- Utilities -->
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>marmotta-commons</artifactId>
+ </dependency>
+
+ <dependency>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <artifactId>hamcrest-core</artifactId>
+ <groupId>org.hamcrest</groupId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <artifactId>hamcrest-library</artifactId>
+ <groupId>org.hamcrest</groupId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/ByteArray.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/ByteArray.java b/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/ByteArray.java
new file mode 100644
index 0000000..b4a56cf
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/ByteArray.java
@@ -0,0 +1,63 @@
+/**
+ * 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.marmotta.commons.sesame.tripletable;
+
+import java.util.Arrays;
+
+/**
+* Add file description here!
+* <p/>
+* Author: Sebastian Schaffert
+*/
+final class ByteArray implements Comparable<ByteArray> {
+
+ private byte[] data;
+
+ ByteArray(byte[] data) {
+ this.data = data;
+ }
+
+ @Override
+ public int compareTo(ByteArray o) {
+ for(int i=0; i < data.length && i < o.data.length; i++) {
+ if(((int) data[i] & 0xff) < ((int) o.data[i] & 0xff)) {
+ return -1;
+ } else if(((int)data[i] & 0xff) > ((int)o.data[i] & 0xff)) {
+ return 1;
+ }
+ }
+ return 0;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ByteArray byteArray = (ByteArray) o;
+
+ return Arrays.equals(data, byteArray.data);
+
+ }
+
+ @Override
+ public int hashCode() {
+ return data != null ? Arrays.hashCode(data) : 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/IntArray.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/IntArray.java b/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/IntArray.java
new file mode 100644
index 0000000..65002b4
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/IntArray.java
@@ -0,0 +1,213 @@
+/**
+ * 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.marmotta.commons.sesame.tripletable;
+
+import com.google.common.hash.HashCode;
+import com.google.common.hash.HashFunction;
+import com.google.common.hash.Hasher;
+import com.google.common.hash.Hashing;
+import org.openrdf.model.Literal;
+import org.openrdf.model.Resource;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+
+import java.io.Serializable;
+import java.nio.IntBuffer;
+import java.util.Arrays;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public final class IntArray implements Comparable<IntArray>, Serializable {
+
+ private static HashFunction hashFunction32 = Hashing.goodFastHash(32);
+ private static HashFunction hashFunction64 = Hashing.goodFastHash(64);
+
+ private int[] data;
+
+ private HashCode hashCode32, hashCode64;
+
+
+ public IntArray(int[] data) {
+ this.data = data;
+ }
+
+ private void ensureHashCode() {
+ if(hashCode32 == null) {
+ Hasher hasher = hashFunction32.newHasher();
+ for(int i : data) {
+ hasher.putInt(i);
+ }
+ hashCode32 = hasher.hash();
+ }
+ }
+
+ private void ensureLongHashCode() {
+ if(hashCode64 == null) {
+ Hasher hasher = hashFunction64.newHasher();
+ for(int i : data) {
+ hasher.putInt(i);
+ }
+ hashCode64 = hasher.hash();
+ }
+
+ }
+
+ public static final IntArray createSPOCKey(Resource subject, URI property, Value object, Resource context){
+
+ // the cache key is generated by appending the bytes of the hashcodes of subject, property, object, context and inferred and
+ // storing them as a BigInteger; generating the cache key should thus be very efficient
+
+ int s = subject != null ? subject.hashCode() : Integer.MIN_VALUE;
+ int p = property != null ? property.hashCode() : Integer.MIN_VALUE;
+ int o = object != null ? calcObjectHash(object) : Integer.MIN_VALUE;
+ int c = context != null ? context.hashCode() : Integer.MIN_VALUE;
+
+ IntBuffer bb = IntBuffer.allocate(4);
+ bb.put(s);
+ bb.put(p);
+ bb.put(o);
+ bb.put(c);
+
+ return new IntArray(bb.array());
+
+ }
+
+ public static final IntArray createSPOCMaxKey(Resource subject, URI property, Value object, Resource context){
+
+ // the cache key is generated by appending the bytes of the hashcodes of subject, property, object, context and inferred and
+ // storing them as a BigInteger; generating the cache key should thus be very efficient
+
+ int s = subject != null ? subject.hashCode() : Integer.MAX_VALUE;
+ int p = property != null ? property.hashCode() : Integer.MAX_VALUE;
+ int o = object != null ? calcObjectHash(object) : Integer.MAX_VALUE;
+ int c = context != null ? context.hashCode() : Integer.MAX_VALUE;
+
+ IntBuffer bb = IntBuffer.allocate(4);
+ bb.put(s);
+ bb.put(p);
+ bb.put(o);
+ bb.put(c);
+
+ return new IntArray(bb.array());
+
+ }
+
+ public static final IntArray createCSPOKey(Resource subject, URI property, Value object, Resource context){
+
+ // the cache key is generated by appending the bytes of the hashcodes of subject, property, object, context and inferred and
+ // storing them as a BigInteger; generating the cache key should thus be very efficient
+
+ int s = subject != null ? subject.hashCode() : Integer.MIN_VALUE;
+ int p = property != null ? property.hashCode() : Integer.MIN_VALUE;
+ int o = object != null ? calcObjectHash(object) : Integer.MIN_VALUE;
+ int c = context != null ? context.hashCode() : Integer.MIN_VALUE;
+
+ IntBuffer bb = IntBuffer.allocate(4);
+ bb.put(c);
+ bb.put(s);
+ bb.put(p);
+ bb.put(o);
+
+ return new IntArray(bb.array());
+
+ }
+
+ public static final IntArray createCSPOMaxKey(Resource subject, URI property, Value object, Resource context){
+
+ // the cache key is generated by appending the bytes of the hashcodes of subject, property, object, context and inferred and
+ // storing them as a BigInteger; generating the cache key should thus be very efficient
+
+ int s = subject != null ? subject.hashCode() : Integer.MAX_VALUE;
+ int p = property != null ? property.hashCode() : Integer.MAX_VALUE;
+ int o = object != null ? calcObjectHash(object) : Integer.MAX_VALUE;
+ int c = context != null ? context.hashCode() : Integer.MAX_VALUE;
+
+ IntBuffer bb = IntBuffer.allocate(4);
+ bb.put(c);
+ bb.put(s);
+ bb.put(p);
+ bb.put(o);
+
+ return new IntArray(bb.array());
+
+ }
+
+ private static int calcObjectHash(Value value) {
+ if(value instanceof Literal) {
+ int i = value.stringValue().hashCode();
+ if(((Literal) value).getLanguage() != null) {
+ i = i*31 + ((Literal) value).getLanguage().hashCode();
+ } else {
+ i = i*31;
+ }
+ if(((Literal) value).getDatatype() != null) {
+ i = i*31 + ((Literal) value).getDatatype().hashCode();
+ } else {
+ i = i*31;
+ }
+ return i;
+ } else {
+ return value.hashCode();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "IntArray{" +
+ "data=" + Arrays.toString(data) +
+ '}';
+ }
+
+ @Override
+ public int compareTo(IntArray o) {
+ for(int i=0; i < data.length && i < o.data.length; i++) {
+ if(data[i] < o.data[i]) {
+ return -1;
+ } else if(data[i] > o.data[i]) {
+ return 1;
+ }
+ }
+ return 0;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ IntArray intArray = (IntArray) o;
+
+ return Arrays.equals(data, intArray.data);
+
+ }
+
+ @Override
+ public int hashCode() {
+ ensureHashCode();
+ return hashCode32.asInt();
+ }
+
+ public long longHashCode() {
+ ensureLongHashCode();
+ return hashCode64.asLong();
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/TripleTable.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/TripleTable.java b/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/TripleTable.java
new file mode 100644
index 0000000..d149b87
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/TripleTable.java
@@ -0,0 +1,478 @@
+/**
+ * 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.marmotta.commons.sesame.tripletable;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import org.apache.marmotta.commons.collections.EquivalenceHashSet;
+import org.apache.marmotta.commons.sesame.model.StatementCommons;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * A triple table that allows efficient in-memory operations over large collections of triples. This can be used as
+ * a simplified version of a Sesame in-memory repository (MemStore) using typical collection methods.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TripleTable<Triple extends Statement> implements Set<Triple>, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private Set<Triple> data;
+
+ /**
+ * A set that orders triples orderd in a way that the subject is the most significant, while the context is the
+ * least significant property in the order. Can be used for efficient queries that involve either just a subject,
+ * a subject and a property, a subject, property and object or a subject, property, object and context
+ */
+ private NavigableMap<IntArray,Triple> indexSPOC;
+
+ /**
+ * A set that orders triples orderd in a way that the context is the most significant, while the object is the
+ * least significant property in the order. Can be used for efficient queries that involve either just a context,
+ * a context and a subject, a context, subject, and property
+ */
+ private NavigableMap<IntArray,Triple> indexCSPO;
+
+ public TripleTable() {
+ data = StatementCommons.newQuadrupleSet();
+ indexSPOC = new TreeMap<IntArray, Triple>();
+ indexCSPO = new TreeMap<IntArray, Triple>();
+ }
+
+
+ public TripleTable(Collection<Triple> triples) {
+ data = StatementCommons.newQuadrupleSet();
+ indexSPOC = new TreeMap<IntArray, Triple>();
+ indexCSPO = new TreeMap<IntArray, Triple>();
+ addAll(triples);
+ }
+
+
+ /**
+ * Returns the number of elements in this set (its cardinality). If this
+ * set contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
+ * <tt>Integer.MAX_VALUE</tt>.
+ *
+ * @return the number of elements in this set (its cardinality)
+ */
+ @Override
+ public synchronized int size() {
+ return data.size();
+ }
+
+ /**
+ * Returns <tt>true</tt> if this set contains no elements.
+ *
+ * @return <tt>true</tt> if this set contains no elements
+ */
+ @Override
+ public synchronized boolean isEmpty() {
+ return data.isEmpty();
+ }
+
+ /**
+ * Returns <tt>true</tt> if this set contains the specified element.
+ * More formally, returns <tt>true</tt> if and only if this set
+ * contains an element <tt>e</tt> such that
+ * <tt>(o==null ? e==null : o.equals(e))</tt>.
+ *
+ * @param o element whose presence in this set is to be tested
+ * @return <tt>true</tt> if this set contains the specified element
+ * @throws ClassCastException if the type of the specified element
+ * is incompatible with this set (optional)
+ * @throws NullPointerException if the specified element is null and this
+ * set does not permit null elements (optional)
+ */
+ @Override
+ public synchronized boolean contains(Object o) {
+ return data.contains(o);
+ }
+
+ /**
+ * Returns an iterator over the elements in this set. The elements are
+ * returned in no particular order (unless this set is an instance of some
+ * class that provides a guarantee).
+ *
+ * @return an iterator over the elements in this set
+ */
+ @Override
+ public Iterator<Triple> iterator() {
+ return data.iterator();
+ }
+
+ /**
+ * Returns an array containing all of the elements in this set.
+ * If this set makes any guarantees as to what order its elements
+ * are returned by its iterator, this method must return the
+ * elements in the same order.
+ *
+ * <p>The returned array will be "safe" in that no references to it
+ * are maintained by this set. (In other words, this method must
+ * allocate a new array even if this set is backed by an array).
+ * The caller is thus free to modify the returned array.
+ *
+ * <p>This method acts as bridge between array-based and collection-based
+ * APIs.
+ *
+ * @return an array containing all the elements in this set
+ */
+ @Override
+ public synchronized Object[] toArray() {
+ return data.toArray();
+ }
+
+ /**
+ * Returns an array containing all of the elements in this set; the
+ * runtime type of the returned array is that of the specified array.
+ * If the set fits in the specified array, it is returned therein.
+ * Otherwise, a new array is allocated with the runtime type of the
+ * specified array and the size of this set.
+ *
+ * <p>If this set fits in the specified array with room to spare
+ * (i.e., the array has more elements than this set), the element in
+ * the array immediately following the end of the set is set to
+ * <tt>null</tt>. (This is useful in determining the length of this
+ * set <i>only</i> if the caller knows that this set does not contain
+ * any null elements.)
+ *
+ * <p>If this set makes any guarantees as to what order its elements
+ * are returned by its iterator, this method must return the elements
+ * in the same order.
+ *
+ * <p>Like the {@link #toArray()} method, this method acts as bridge between
+ * array-based and collection-based APIs. Further, this method allows
+ * precise control over the runtime type of the output array, and may,
+ * under certain circumstances, be used to save allocation costs.
+ *
+ * <p>Suppose <tt>x</tt> is a set known to contain only strings.
+ * The following code can be used to dump the set into a newly allocated
+ * array of <tt>String</tt>:
+ *
+ * <pre>
+ * String[] y = x.toArray(new String[0]);</pre>
+ *
+ * Note that <tt>toArray(new Object[0])</tt> is identical in function to
+ * <tt>toArray()</tt>.
+ *
+ * @param a the array into which the elements of this set are to be
+ * stored, if it is big enough; otherwise, a new array of the same
+ * runtime type is allocated for this purpose.
+ * @return an array containing all the elements in this set
+ * @throws ArrayStoreException if the runtime type of the specified array
+ * is not a supertype of the runtime type of every element in this
+ * set
+ * @throws NullPointerException if the specified array is null
+ */
+ @Override
+ public synchronized <T> T[] toArray(T[] a) {
+ return data.toArray(a);
+ }
+
+ /**
+ * Adds the specified element to this set if it is not already present
+ * (optional operation). More formally, adds the specified element
+ * <tt>e</tt> to this set if the set contains no element <tt>e2</tt>
+ * such that
+ * <tt>(e==null ? e2==null : e.equals(e2))</tt>.
+ * If this set already contains the element, the call leaves the set
+ * unchanged and returns <tt>false</tt>. In combination with the
+ * restriction on constructors, this ensures that sets never contain
+ * duplicate elements.
+ *
+ * <p>The stipulation above does not imply that sets must accept all
+ * elements; sets may refuse to add any particular element, including
+ * <tt>null</tt>, and throw an exception, as described in the
+ * specification for {@link java.util.Collection#add Collection.add}.
+ * Individual set implementations should clearly document any
+ * restrictions on the elements that they may contain.
+ *
+ * @param triple element to be added to this set
+ * @return <tt>true</tt> if this set did not already contain the specified
+ * element
+ * @throws UnsupportedOperationException if the <tt>add</tt> operation
+ * is not supported by this set
+ * @throws ClassCastException if the class of the specified element
+ * prevents it from being added to this set
+ * @throws NullPointerException if the specified element is null and this
+ * set does not permit null elements
+ * @throws IllegalArgumentException if some property of the specified element
+ * prevents it from being added to this set
+ */
+ @Override
+ public synchronized boolean add(Triple triple) {
+ indexSPOC.put(IntArray.createSPOCKey(triple.getSubject(), triple.getPredicate(), triple.getObject(), triple.getContext()),triple);
+ indexCSPO.put(IntArray.createCSPOKey(triple.getSubject(), triple.getPredicate(), triple.getObject(), triple.getContext()),triple);
+ return data.add(triple);
+ }
+
+ /**
+ * Removes the specified element from this set if it is present
+ * (optional operation). More formally, removes an element <tt>e</tt>
+ * such that
+ * <tt>(o==null ? e==null : o.equals(e))</tt>, if
+ * this set contains such an element. Returns <tt>true</tt> if this set
+ * contained the element (or equivalently, if this set changed as a
+ * result of the call). (This set will not contain the element once the
+ * call returns.)
+ *
+ * @param o object to be removed from this set, if present
+ * @return <tt>true</tt> if this set contained the specified element
+ * @throws ClassCastException if the type of the specified element
+ * is incompatible with this set (optional)
+ * @throws NullPointerException if the specified element is null and this
+ * set does not permit null elements (optional)
+ * @throws UnsupportedOperationException if the <tt>remove</tt> operation
+ * is not supported by this set
+ */
+ @Override
+ public synchronized boolean remove(Object o) {
+ if(o instanceof Statement) {
+ Statement triple = (Statement)o;
+ indexSPOC.remove(IntArray.createSPOCKey(triple.getSubject(), triple.getPredicate(), triple.getObject(), triple.getContext()));
+ indexCSPO.remove(IntArray.createCSPOKey(triple.getSubject(), triple.getPredicate(), triple.getObject(), triple.getContext()));
+ }
+ return data.remove(o);
+ }
+
+ /**
+ * Returns <tt>true</tt> if this set contains all of the elements of the
+ * specified collection. If the specified collection is also a set, this
+ * method returns <tt>true</tt> if it is a <i>subset</i> of this set.
+ *
+ * @param c collection to be checked for containment in this set
+ * @return <tt>true</tt> if this set contains all of the elements of the
+ * specified collection
+ * @throws ClassCastException if the types of one or more elements
+ * in the specified collection are incompatible with this
+ * set (optional)
+ * @throws NullPointerException if the specified collection contains one
+ * or more null elements and this set does not permit null
+ * elements (optional), or if the specified collection is null
+ * @see #contains(Object)
+ */
+ @Override
+ public synchronized boolean containsAll(Collection<?> c) {
+ return data.containsAll(c);
+ }
+
+ /**
+ * Adds all of the elements in the specified collection to this set if
+ * they're not already present (optional operation). If the specified
+ * collection is also a set, the <tt>addAll</tt> operation effectively
+ * modifies this set so that its value is the <i>union</i> of the two
+ * sets. The behavior of this operation is undefined if the specified
+ * collection is modified while the operation is in progress.
+ *
+ * @param c collection containing elements to be added to this set
+ * @return <tt>true</tt> if this set changed as a result of the call
+ *
+ * @throws UnsupportedOperationException if the <tt>addAll</tt> operation
+ * is not supported by this set
+ * @throws ClassCastException if the class of an element of the
+ * specified collection prevents it from being added to this set
+ * @throws NullPointerException if the specified collection contains one
+ * or more null elements and this set does not permit null
+ * elements, or if the specified collection is null
+ * @throws IllegalArgumentException if some property of an element of the
+ * specified collection prevents it from being added to this set
+ * @see #add(Object)
+ */
+ @Override
+ public synchronized boolean addAll(Collection<? extends Triple> c) {
+ boolean modified = false;
+ for(Triple t : c) {
+ modified = add(t) || modified;
+ }
+ return modified;
+ }
+
+ /**
+ * Retains only the elements in this set that are contained in the
+ * specified collection (optional operation). In other words, removes
+ * from this set all of its elements that are not contained in the
+ * specified collection. If the specified collection is also a set, this
+ * operation effectively modifies this set so that its value is the
+ * <i>intersection</i> of the two sets.
+ *
+ * @param c collection containing elements to be retained in this set
+ * @return <tt>true</tt> if this set changed as a result of the call
+ * @throws UnsupportedOperationException if the <tt>retainAll</tt> operation
+ * is not supported by this set
+ * @throws ClassCastException if the class of an element of this set
+ * is incompatible with the specified collection (optional)
+ * @throws NullPointerException if this set contains a null element and the
+ * specified collection does not permit null elements (optional),
+ * or if the specified collection is null
+ * @see #remove(Object)
+ */
+ @Override
+ public synchronized boolean retainAll(Collection<?> c) {
+ Iterator<Map.Entry<IntArray,Triple>> it = indexSPOC.entrySet().iterator();
+ while(it.hasNext()) {
+ if(!c.contains(it.next().getValue())) {
+ it.remove();
+ }
+ }
+ Iterator<Map.Entry<IntArray,Triple>> it2 = indexCSPO.entrySet().iterator();
+ while(it2.hasNext()) {
+ if(!c.contains(it2.next().getValue())) {
+ it2.remove();
+ }
+ }
+ return data.retainAll(c);
+ }
+
+ /**
+ * Removes from this set all of its elements that are contained in the
+ * specified collection (optional operation). If the specified
+ * collection is also a set, this operation effectively modifies this
+ * set so that its value is the <i>asymmetric set difference</i> of
+ * the two sets.
+ *
+ * @param c collection containing elements to be removed from this set
+ * @return <tt>true</tt> if this set changed as a result of the call
+ * @throws UnsupportedOperationException if the <tt>removeAll</tt> operation
+ * is not supported by this set
+ * @throws ClassCastException if the class of an element of this set
+ * is incompatible with the specified collection (optional)
+ * @throws NullPointerException if this set contains a null element and the
+ * specified collection does not permit null elements (optional),
+ * or if the specified collection is null
+ * @see #remove(Object)
+ * @see #contains(Object)
+ */
+ @Override
+ public synchronized boolean removeAll(Collection<?> c) {
+ boolean modified = false;
+ for(Object o : c) {
+ modified = remove(o) || modified;
+ }
+ return modified;
+ }
+
+ /**
+ * Removes all of the elements from this set (optional operation).
+ * The set will be empty after this call returns.
+ *
+ * @throws UnsupportedOperationException if the <tt>clear</tt> method
+ * is not supported by this set
+ */
+ @Override
+ public synchronized void clear() {
+ data.clear();
+ indexSPOC.clear();
+ indexCSPO.clear();
+ }
+
+ /**
+ * Return a subset of the triples matching the filter criteria. Arguments with null value are treated as wildcards.
+ *
+ *
+ * @param subject
+ * @param property
+ * @param object
+ * @param context
+ * @param wildcardContext
+ * @return
+ */
+ public synchronized Collection<Triple> listTriples(final Resource subject, final URI property, final Value object, final Resource context, boolean wildcardContext) {
+ // in special cases we can make use of the index
+ if(subject != null && property != null && object != null && context != null) {
+ IntArray key = IntArray.createSPOCKey(subject, property, object, context);
+ Triple result = indexSPOC.get(key);
+ if(result != null) {
+ return Collections.singleton(result);
+ } else {
+ return Collections.emptyList();
+ }
+ } else if(wildcardContext &&
+ ( (subject != null && property != null && object != null)
+ || (subject != null && property != null)
+ || subject != null)) {
+ IntArray fromKey = IntArray.createSPOCKey(subject, property, object, context);
+ IntArray toKey = IntArray.createSPOCMaxKey(subject, property, object, context);
+
+ return indexSPOC.subMap(fromKey,true,toKey,true).values();
+ } else if( (context != null && subject != null && property != null)
+ || (context != null && subject != null)
+ || context != null) {
+ IntArray fromKey = IntArray.createCSPOKey(subject, property, object, context);
+ IntArray toKey = IntArray.createCSPOMaxKey(subject, property, object, context);
+
+ return indexCSPO.subMap(fromKey,true,toKey,true).values();
+ } else {
+ // in all other cases we need to iterate and filter :-(
+ Predicate<Statement> p = new Predicate<Statement>() {
+ @Override
+ public boolean apply(Statement triple) {
+ if(subject != null && !triple.getSubject().equals(subject)) {
+ return false;
+ }
+ if(property != null && !triple.getPredicate().equals(property)) {
+ return false;
+ }
+ if(object != null && !triple.getObject().equals(object)) {
+ return false;
+ }
+ if(context != null && !triple.getContext().equals(context)) {
+ return false;
+ }
+
+ return true;
+ }
+ };
+
+ return Collections2.filter(data, p);
+ }
+ }
+
+ public synchronized Collection<Resource> listContextIDs() {
+ Set<Resource> result = new HashSet<>();
+ for(Triple t : data) {
+ result.add(t.getContext());
+ }
+ return result;
+ }
+
+ @Override
+ public synchronized boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ @SuppressWarnings("rawtypes")
+ TripleTable that = (TripleTable) o;
+
+ if (!data.equals(that.data)) return false;
+
+ return true;
+ }
+
+ @Override
+ public synchronized int hashCode() {
+ return data.hashCode();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/test/java/org/apache/marmotta/commons/sesame/tripletable/TripleTableTest.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/test/java/org/apache/marmotta/commons/sesame/tripletable/TripleTableTest.java b/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/test/java/org/apache/marmotta/commons/sesame/tripletable/TripleTableTest.java
new file mode 100644
index 0000000..9a3db75
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-util-tripletable/src/test/java/org/apache/marmotta/commons/sesame/tripletable/TripleTableTest.java
@@ -0,0 +1,128 @@
+/*
+ * 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.marmotta.commons.sesame.tripletable;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.marmotta.commons.sesame.tripletable.TripleTable;
+import org.junit.Test;
+import org.openrdf.model.Literal;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.model.impl.LiteralImpl;
+import org.openrdf.model.impl.StatementImpl;
+import org.openrdf.model.impl.URIImpl;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Test cases for triple tables.
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class TripleTableTest {
+
+
+
+ @Test
+ public void testListTriples() {
+ URI subject1 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+ URI subject2 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+ URI predicate1 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+ URI predicate2 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+ Literal object1 = new LiteralImpl("http://localhost/"+ RandomStringUtils.random(40));
+ Literal object2 = new LiteralImpl("http://localhost/"+ RandomStringUtils.random(40));
+
+ Statement stmt1 = new StatementImpl(subject1,predicate1,object1);
+ Statement stmt2 = new StatementImpl(subject1,predicate1,object2);
+ Statement stmt3 = new StatementImpl(subject1,predicate2,object1);
+ Statement stmt4 = new StatementImpl(subject1,predicate2,object2);
+ Statement stmt5 = new StatementImpl(subject2,predicate1,object1);
+ Statement stmt6 = new StatementImpl(subject2,predicate1,object2);
+ Statement stmt7 = new StatementImpl(subject2,predicate2,object1);
+ Statement stmt8 = new StatementImpl(subject2,predicate2,object2);
+
+ TripleTable<Statement> table = new TripleTable<>();
+ table.add(stmt1);
+ table.add(stmt2);
+ table.add(stmt3);
+ table.add(stmt4);
+ table.add(stmt5);
+ table.add(stmt6);
+ table.add(stmt7);
+ //table.add(stmt8);
+
+ // tests
+
+ // 1. test existence and non-existence of a triple
+ assertEquals(1, table.listTriples(subject2,predicate2,object1,null, true).size());
+ assertEquals(0, table.listTriples(subject2,predicate2,object2,null, true).size());
+
+ // 2. test listing with wildcards
+ assertEquals(7, table.listTriples(null,null,null,null, true).size());
+ assertEquals(4, table.listTriples(subject1,null,null,null, true).size());
+ assertEquals(3, table.listTriples(subject2,null,null,null, true).size());
+ assertEquals(4, table.listTriples(null,predicate1,null,null, true).size());
+ assertEquals(3, table.listTriples(null,predicate2,null,null, true).size());
+ assertEquals(4, table.listTriples(null,null,object1,null, true).size());
+ assertEquals(3, table.listTriples(null,null,object2,null, true).size());
+ assertEquals(2, table.listTriples(subject1,predicate1,null,null, true).size());
+ assertEquals(1, table.listTriples(subject2,predicate2,null,null, true).size());
+ }
+
+ @Test
+ public void testRemoveTriples() {
+ URI subject1 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+ URI subject2 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+ URI predicate1 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+ URI predicate2 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+ Literal object1 = new LiteralImpl("http://localhost/"+ RandomStringUtils.random(40));
+ Literal object2 = new LiteralImpl("http://localhost/"+ RandomStringUtils.random(40));
+
+ Statement stmt1 = new StatementImpl(subject1,predicate1,object1);
+ Statement stmt2 = new StatementImpl(subject1,predicate1,object2);
+ Statement stmt3 = new StatementImpl(subject1,predicate2,object1);
+ Statement stmt4 = new StatementImpl(subject1,predicate2,object2);
+ Statement stmt5 = new StatementImpl(subject2,predicate1,object1);
+ Statement stmt6 = new StatementImpl(subject2,predicate1,object2);
+ Statement stmt7 = new StatementImpl(subject2,predicate2,object1);
+ Statement stmt8 = new StatementImpl(subject2,predicate2,object2);
+
+ TripleTable<Statement> table = new TripleTable<>();
+ table.add(stmt1);
+ table.add(stmt2);
+ table.add(stmt3);
+ table.add(stmt4);
+ table.add(stmt5);
+ table.add(stmt6);
+ table.add(stmt7);
+ table.add(stmt8);
+
+ // tests
+
+ // 1. test existence and non-existence of a triple
+ assertEquals(1, table.listTriples(subject2,predicate2,object1,null, true).size());
+ assertEquals(1, table.listTriples(subject2,predicate2,object2,null, true).size());
+
+
+ table.remove(stmt8);
+
+ assertEquals(1, table.listTriples(subject2,predicate2,object1,null, true).size());
+ assertEquals(0, table.listTriples(subject2,predicate2,object2,null, true).size());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/pom.xml
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/pom.xml b/commons/marmotta-sesame-tools/pom.xml
new file mode 100644
index 0000000..e55ae01
--- /dev/null
+++ b/commons/marmotta-sesame-tools/pom.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>marmotta-parent</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>marmotta-sesame-tools</artifactId>
+ <packaging>pom</packaging>
+
+ <name>Apache Marmotta Commons: Sesame Tools Reactor</name>
+ <description>A collection of support modules for Sesame, used in Marmotta but also valuable outside.</description>
+
+ <!-- release management -->
+ <build>
+ <plugins>
+ <!-- do not install / deploy reactor -->
+ <plugin>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+ <modules>
+ <module>marmotta-rio-api</module>
+ <module>marmotta-rio-ical</module>
+ <module>marmotta-rio-rss</module>
+ <module>marmotta-rio-vcard</module>
+ <module>marmotta-sail-contextaware</module>
+ <module>marmotta-sail-transactions</module>
+ <module>marmotta-util-facading</module>
+ <module>marmotta-util-filter</module>
+ <module>marmotta-util-tripletable</module>
+ </modules>
+
+</project>
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/pom.xml
----------------------------------------------------------------------
diff --git a/commons/pom.xml b/commons/pom.xml
index 35313b0..093a6d1 100644
--- a/commons/pom.xml
+++ b/commons/pom.xml
@@ -53,15 +53,7 @@
<modules>
<module>marmotta-commons</module>
- <module>sesame-filter</module>
- <module>sesame-contextaware</module>
- <module>sesame-tripletable</module>
- <module>sesame-transactions</module>
- <module>sesame-tools-rio-api</module>
- <module>sesame-tools-rio-ical</module>
- <module>sesame-tools-rio-rss</module>
- <module>sesame-tools-rio-vcard</module>
- <module>sesame-tools-facading</module>
+ <module>marmotta-sesame-tools</module>
</modules>
</project>
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-contextaware/pom.xml
----------------------------------------------------------------------
diff --git a/commons/sesame-contextaware/pom.xml b/commons/sesame-contextaware/pom.xml
deleted file mode 100644
index cd6900e..0000000
--- a/commons/sesame-contextaware/pom.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.marmotta</groupId>
- <artifactId>marmotta-parent</artifactId>
- <version>3.2.0-SNAPSHOT</version>
- <relativePath>../../parent/</relativePath>
- </parent>
-
- <artifactId>sesame-contextaware</artifactId>
- <packaging>jar</packaging>
-
- <name>Sesame Tools: Contextual Sail</name>
-
- <description>
- This module provides a Sesame SailWrapper that allows defining a context that overwrites all
- contexts defined in statements to be added, read, or deleted. It can be used to have a view
- on repositories that only allows accessing a single named graph.
- </description>
-
- <dependencies>
- <dependency>
- <groupId>org.openrdf.sesame</groupId>
- <artifactId>sesame-model</artifactId>
- </dependency>
- <dependency>
- <groupId>org.openrdf.sesame</groupId>
- <artifactId>sesame-sail-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.openrdf.sesame</groupId>
- <artifactId>sesame-sail-memory</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-contextaware/src/main/java/org/apache/marmotta/commons/sesame/contextaware/ContextAwareSail.java
----------------------------------------------------------------------
diff --git a/commons/sesame-contextaware/src/main/java/org/apache/marmotta/commons/sesame/contextaware/ContextAwareSail.java b/commons/sesame-contextaware/src/main/java/org/apache/marmotta/commons/sesame/contextaware/ContextAwareSail.java
deleted file mode 100644
index 62e4cf7..0000000
--- a/commons/sesame-contextaware/src/main/java/org/apache/marmotta/commons/sesame/contextaware/ContextAwareSail.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.marmotta.commons.sesame.contextaware;
-
-import org.openrdf.model.Resource;
-import org.openrdf.sail.Sail;
-import org.openrdf.sail.SailConnection;
-import org.openrdf.sail.SailException;
-import org.openrdf.sail.helpers.SailWrapper;
-
-/**
- * A SAIL wrapper that allows overriding any context given in repository operations
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
- */
-public class ContextAwareSail extends SailWrapper {
-
- private final Resource context;
-
- /**
- * Creates a new SailWrapper that wraps the supplied Sail.
- */
- public ContextAwareSail(Sail baseSail, Resource context) {
- super(baseSail);
- this.context = context;
- }
-
- @Override
- public SailConnection getConnection() throws SailException {
- return new ContextAwareSailConnection(super.getConnection(),context);
- }
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-contextaware/src/main/java/org/apache/marmotta/commons/sesame/contextaware/ContextAwareSailConnection.java
----------------------------------------------------------------------
diff --git a/commons/sesame-contextaware/src/main/java/org/apache/marmotta/commons/sesame/contextaware/ContextAwareSailConnection.java b/commons/sesame-contextaware/src/main/java/org/apache/marmotta/commons/sesame/contextaware/ContextAwareSailConnection.java
deleted file mode 100644
index 9ca5a64..0000000
--- a/commons/sesame-contextaware/src/main/java/org/apache/marmotta/commons/sesame/contextaware/ContextAwareSailConnection.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.marmotta.commons.sesame.contextaware;
-
-import info.aduna.iteration.CloseableIteration;
-import info.aduna.iteration.SingletonIteration;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
-import org.openrdf.sail.SailConnection;
-import org.openrdf.sail.SailException;
-import org.openrdf.sail.UpdateContext;
-import org.openrdf.sail.helpers.SailConnectionWrapper;
-
-/**
- * A SAIL connection overriding all provided context values with the default context used when creating the connection
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
- */
-public class ContextAwareSailConnection extends SailConnectionWrapper {
-
- private final Resource context;
-
- public ContextAwareSailConnection(SailConnection wrappedCon, Resource context) {
- super(wrappedCon);
- this.context = context;
- }
-
- @Override
- public CloseableIteration<? extends Statement, SailException> getStatements(Resource subj, URI pred, Value obj, boolean includeInferred, Resource... contexts) throws SailException {
- return super.getStatements(subj, pred, obj, includeInferred, context);
- }
-
- @Override
- public void addStatement(Resource subj, URI pred, Value obj, Resource... contexts) throws SailException {
- super.addStatement(subj, pred, obj, context);
- }
-
- @Override
- public void addStatement(UpdateContext modify, Resource subj, URI pred, Value obj, Resource... contexts) throws SailException {
- super.addStatement(modify, subj, pred, obj, context);
- }
-
- @Override
- public CloseableIteration<? extends Resource, SailException> getContextIDs() throws SailException {
- return new SingletonIteration<Resource, SailException>(context);
- }
-
- @Override
- public void removeStatements(Resource subj, URI pred, Value obj, Resource... contexts) throws SailException {
- super.removeStatements(subj, pred, obj, context);
- }
-
- @Override
- public void removeStatement(UpdateContext modify, Resource subj, URI pred, Value obj, Resource... contexts) throws SailException {
- super.removeStatement(modify, subj, pred, obj, context);
- }
-
- @Override
- public void clear(Resource... contexts) throws SailException {
- super.clear(context);
- }
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-contextaware/src/test/java/org/apache/marmotta/commons/sesame/AbstractContextTest.java
----------------------------------------------------------------------
diff --git a/commons/sesame-contextaware/src/test/java/org/apache/marmotta/commons/sesame/AbstractContextTest.java b/commons/sesame-contextaware/src/test/java/org/apache/marmotta/commons/sesame/AbstractContextTest.java
deleted file mode 100644
index 6f6681c..0000000
--- a/commons/sesame-contextaware/src/test/java/org/apache/marmotta/commons/sesame/AbstractContextTest.java
+++ /dev/null
@@ -1,108 +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.marmotta.commons.sesame;
-
-import info.aduna.iteration.CloseableIteration;
-
-import java.util.UUID;
-
-import org.junit.After;
-import org.junit.Before;
-import org.openrdf.model.Literal;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
-import org.openrdf.model.ValueFactory;
-import org.openrdf.sail.Sail;
-import org.openrdf.sail.SailConnection;
-import org.openrdf.sail.SailException;
-import org.openrdf.sail.memory.MemoryStore;
-
-public abstract class AbstractContextTest {
-
- protected static final String NS = "http://test.marmotta.apache.org/resource/";
-
- protected static boolean hasStatement(SailConnection con, Resource subj,
- URI pred, Value object, Resource... contexts) throws SailException {
- final CloseableIteration<? extends Statement, SailException> stmts = con.getStatements(subj, pred, object, true, contexts);
- try {
- return stmts.hasNext();
- } finally {
- stmts.close();
- }
- }
-
- protected Sail sail;
-
- protected URI u1, u2, u3, u4;
- protected URI p1, p2, p3, p4;
- protected Resource c1, c2;
- protected Literal l1, l2, l3, l4;
-
- @Before
- public void setUp() throws SailException {
- sail = new MemoryStore();
- sail.initialize();
-
- final ValueFactory vf = sail.getValueFactory();
- u1 = vf.createURI(NS, UUID.randomUUID().toString());
- u2 = vf.createURI(NS, UUID.randomUUID().toString());
- u3 = vf.createURI(NS, UUID.randomUUID().toString());
- u4 = vf.createURI(NS, UUID.randomUUID().toString());
-
- p1 = vf.createURI(NS, UUID.randomUUID().toString());
- p2 = vf.createURI(NS, UUID.randomUUID().toString());
- p3 = vf.createURI(NS, UUID.randomUUID().toString());
- p4 = vf.createURI(NS, UUID.randomUUID().toString());
-
- c1 = vf.createURI(NS, UUID.randomUUID().toString());
- c2 = vf.createBNode();
-
- l1 = vf.createLiteral(UUID.randomUUID().toString());
- l2 = vf.createLiteral(UUID.randomUUID().toString());
- l3 = vf.createLiteral(UUID.randomUUID().toString());
- l4 = vf.createLiteral(UUID.randomUUID().toString());
-
- final SailConnection con = sail.getConnection();
- try {
- con.begin();
-
- con.addStatement(u1, p1, l1, c1);
- con.addStatement(u2, p2, l2, c2);
- con.addStatement(u3, p3, l3, c1);
- con.addStatement(u4, p4, l4, c2);
-
- con.commit();
- } catch (final Throwable t) {
- con.rollback();
- throw t;
- } finally {
- con.close();
- }
- }
-
- @After
- public void tearDown() throws SailException {
- if (sail != null) {
- sail.shutDown();
- }
- sail = null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-contextaware/src/test/java/org/apache/marmotta/commons/sesame/contextaware/ContextAwareSailTest.java
----------------------------------------------------------------------
diff --git a/commons/sesame-contextaware/src/test/java/org/apache/marmotta/commons/sesame/contextaware/ContextAwareSailTest.java b/commons/sesame-contextaware/src/test/java/org/apache/marmotta/commons/sesame/contextaware/ContextAwareSailTest.java
deleted file mode 100644
index 7f8a134..0000000
--- a/commons/sesame-contextaware/src/test/java/org/apache/marmotta/commons/sesame/contextaware/ContextAwareSailTest.java
+++ /dev/null
@@ -1,195 +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.marmotta.commons.sesame.contextaware;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import info.aduna.iteration.CloseableIteration;
-
-import org.apache.marmotta.commons.sesame.AbstractContextTest;
-import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.openrdf.model.Resource;
-import org.openrdf.sail.SailConnection;
-import org.openrdf.sail.SailException;
-
-/**
- * @author Jakob Frank <ja...@apache.org>
- *
- */
-public class ContextAwareSailTest extends AbstractContextTest {
-
- protected ContextAwareSail cas;
-
- @Override
- @Before
- public void setUp() throws SailException {
- super.setUp();
-
- cas = new ContextAwareSail(sail, c1);
- }
-
-
- @Test
- public void testGetStatements() throws SailException {
- final SailConnection con = cas.getConnection();
- try {
- con.begin();
-
- Assert.assertTrue(hasStatement(con, u1, p1, l1));
- Assert.assertFalse(hasStatement(con, u2, p2, l2));
-
- con.commit();
- } catch (final Throwable t) {
- con.rollback();
- throw t;
- } finally {
- con.close();
- }
- }
-
- @Test
- public void testAddStatement() throws SailException {
- final SailConnection con = cas.getConnection();
- try {
- con.begin();
- con.addStatement(u1, p2, l3);
- con.commit();
- } catch (final Throwable t) {
- con.rollback();
- throw t;
- } finally {
- con.close();
- }
- final SailConnection con2 = sail.getConnection();
- try {
- con2.begin();
-
- Assert.assertTrue(hasStatement(con2, u1, p2, l3, c1));
- Assert.assertFalse(hasStatement(con2, u1, p2, l3, c2));
-
- con2.commit();
- } catch (final Throwable t) {
- con2.rollback();
- throw t;
- } finally {
- con2.close();
- }
- }
-
- @Test
- public void testGetContextIDs() throws SailException {
- final SailConnection con = cas.getConnection();
- try {
- con.begin();
-
- final CloseableIteration<? extends Resource, SailException> cid = con.getContextIDs();
- try {
- assertTrue(cid.hasNext());
- assertThat(cid.next(), CoreMatchers.is(c1));
- assertFalse(cid.hasNext());
- } finally {
- cid.close();
- }
-
- con.commit();
- } catch (final Throwable t) {
- con.rollback();
- throw t;
- } finally {
- con.close();
- }
- }
-
- @Test
- public void testClear() throws SailException {
- final SailConnection con = cas.getConnection();
- try {
- con.begin();
-
- assertTrue(hasStatement(con, null, null, null));
- con.clear();
- assertFalse(hasStatement(con, null, null, null));
-
- con.commit();
- } catch (final Throwable t) {
- con.rollback();
- throw t;
- } finally {
- con.close();
- }
- final SailConnection con2 = sail.getConnection();
- try {
- con2.begin();
-
- assertFalse(hasStatement(con2, null, null, null, c1));
- assertTrue(hasStatement(con2, null, null, null, c2));
-
- con2.commit();
- } catch (final Throwable t) {
- con2.rollback();
- throw t;
- } finally {
- con2.close();
- }
- }
-
- @Test
- public void testRemoveStatements() throws SailException {
- final SailConnection con = cas.getConnection();
- try {
- con.begin();
-
- assertTrue(hasStatement(con, u1, p1, l1));
- assertTrue(hasStatement(con, u3, p3, l3));
-
- con.removeStatements(u1, p1, l1, c1);
- con.removeStatements(u2, p2, l2);
- con.removeStatements(u4, p4, l4, c1);
-
- assertFalse(hasStatement(con, u1, p1, l1));
- assertTrue(hasStatement(con, u3, p3, l3));
-
- con.commit();
- } catch (final Throwable t) {
- con.rollback();
- throw t;
- } finally {
- con.close();
- }
- final SailConnection con2 = sail.getConnection();
- try {
- con2.begin();
-
- assertFalse(hasStatement(con2, u1, p1, l1, c1));
- assertTrue(hasStatement(con2, u2, p2, l2, c2));
- assertTrue(hasStatement(con2, u3, p3, l3, c1));
-
- con2.commit();
- } catch (final Throwable t) {
- con2.rollback();
- throw t;
- } finally {
- con2.close();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-filter/pom.xml
----------------------------------------------------------------------
diff --git a/commons/sesame-filter/pom.xml b/commons/sesame-filter/pom.xml
deleted file mode 100644
index 8652095..0000000
--- a/commons/sesame-filter/pom.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.marmotta</groupId>
- <artifactId>marmotta-parent</artifactId>
- <version>3.2.0-SNAPSHOT</version>
- <relativePath>../../parent</relativePath>
- </parent>
-
- <artifactId>sesame-filter</artifactId>
- <name>Sesame Tools: Resource Filters</name>
-
- <description>
- This module provides generic components for composite resource filtering, e.g. checking if
- a resource conforms to a certain pattern.
- </description>
-
- <dependencies>
- <dependency>
- <groupId>org.openrdf.sesame</groupId>
- <artifactId>sesame-model</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
-
- <!-- Testing -->
- <dependency>
- <groupId>org.openrdf.sesame</groupId>
- <artifactId>sesame-repository-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.openrdf.sesame</groupId>
- <artifactId>sesame-sail-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.openrdf.sesame</groupId>
- <artifactId>sesame-repository-sail</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.openrdf.sesame</groupId>
- <artifactId>sesame-sail-memory</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.openrdf.sesame</groupId>
- <artifactId>sesame-rio-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.openrdf.sesame</groupId>
- <artifactId>sesame-rio-rdfxml</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-library</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <scope>test</scope>
- </dependency>
-
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/AllOfFilter.java
----------------------------------------------------------------------
diff --git a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/AllOfFilter.java b/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/AllOfFilter.java
deleted file mode 100644
index 570981d..0000000
--- a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/AllOfFilter.java
+++ /dev/null
@@ -1,62 +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.marmotta.commons.sesame.filter;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A filter combining several filters and requiring that all filters match.
- * <p/>
- * Author: Sebastian Schaffert
- *
- * @param <T> the type of object to filter
- */
-public class AllOfFilter<T> implements SesameFilter<T> {
-
- private Set<SesameFilter<T>> children;
-
-
- public AllOfFilter(SesameFilter<T>... children) {
- this(new HashSet<SesameFilter<T>>(Arrays.asList(children)));
- }
-
- public AllOfFilter(Set<SesameFilter<T>> children) {
- this.children = children;
- }
-
- /**
- * Return false in case the filter does not accept the resource passed as argument, true otherwise.
- *
- *
- * @param resource
- * @return
- */
- @Override
- public boolean accept(T resource) {
-
- for(SesameFilter<T> filter : children) {
- if(!filter.accept(resource)) {
- return false;
- }
- }
-
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/AlwaysFalseFilter.java
----------------------------------------------------------------------
diff --git a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/AlwaysFalseFilter.java b/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/AlwaysFalseFilter.java
deleted file mode 100644
index 67e5a7a..0000000
--- a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/AlwaysFalseFilter.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.marmotta.commons.sesame.filter;
-
-/**
- * A filter that always returns false.
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
- *
- * @param <T> the type of object to filter
- */
-public class AlwaysFalseFilter<T> implements SesameFilter<T> {
-
- /**
- * Return false in case the filter does not accept the object passed as argument, true otherwise.
- *
- * @param object the object to check
- * @return true in case the object is accepted, false otherwise
- */
- @Override
- public boolean accept(T object) {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/AlwaysTrueFilter.java
----------------------------------------------------------------------
diff --git a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/AlwaysTrueFilter.java b/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/AlwaysTrueFilter.java
deleted file mode 100644
index 9f8520c..0000000
--- a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/AlwaysTrueFilter.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.marmotta.commons.sesame.filter;
-
-/**
- * A filter that accepts everything.
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
- *
- * @param <T> the type of object to filter
- */
-public class AlwaysTrueFilter<T> implements SesameFilter<T> {
-
- /**
- * Return false in case the filter does not accept the object passed as argument, true otherwise.
- *
- * @param object the object to check
- * @return true in case the object is accepted, false otherwise
- */
- @Override
- public boolean accept(T object) {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/NotFilter.java
----------------------------------------------------------------------
diff --git a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/NotFilter.java b/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/NotFilter.java
deleted file mode 100644
index 08c1a38..0000000
--- a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/NotFilter.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.marmotta.commons.sesame.filter;
-
-/**
- * Negates a wrapped filter
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
- */
-public class NotFilter<T> implements SesameFilter<T> {
-
- SesameFilter<T> wrapped;
-
- public NotFilter(SesameFilter<T> wrapped) {
- this.wrapped = wrapped;
- }
-
- /**
- * Return false in case the filter does not accept the resource passed as argument, true otherwise.
- *
- * @param resource
- * @return
- */
- @Override
- public boolean accept(T resource) {
- return !wrapped.accept(resource);
- }
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/OneOfFilter.java
----------------------------------------------------------------------
diff --git a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/OneOfFilter.java b/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/OneOfFilter.java
deleted file mode 100644
index 9d9a926..0000000
--- a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/OneOfFilter.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.marmotta.commons.sesame.filter;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A filter combining several other filters with a disjunction, i.e. it is sufficient that one of the other filters
- * matches.
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class OneOfFilter<T> implements SesameFilter<T> {
-
- private Set<SesameFilter<T>> children;
-
-
- public OneOfFilter(SesameFilter<T>... children) {
- this(new HashSet<SesameFilter<T>>(Arrays.asList(children)));
- }
-
- public OneOfFilter(Set<SesameFilter<T>> children) {
- this.children = children;
- }
-
- /**
- * Return false in case the filter does not accept the resource passed as argument, true otherwise.
- *
- *
- * @param resource
- * @return
- */
- @Override
- public boolean accept(T resource) {
- for(SesameFilter<T> filter : children) {
- if(filter.accept(resource)) {
- return true;
- }
- }
-
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/SesameFilter.java
----------------------------------------------------------------------
diff --git a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/SesameFilter.java b/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/SesameFilter.java
deleted file mode 100644
index 09b24af..0000000
--- a/commons/sesame-filter/src/main/java/org/apache/marmotta/commons/sesame/filter/SesameFilter.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.marmotta.commons.sesame.filter;
-
-/**
- * Generic superinterface for all filters. Only defines an accept() method.
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
- */
-public interface SesameFilter<T> {
-
- /**
- * Return false in case the filter does not accept the object passed as argument, true otherwise.
- *
- *
- * @param object the object to check
- * @return true in case the object is accepted, false otherwise
- */
- public boolean accept(T object);
-
-}