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 2013/02/21 12:23:27 UTC

[15/19] MARMOTTA-104: renamed packages in ldpath (resolved)

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-sesame/src/main/java/at/newmedialab/ldpath/backend/sesame/ThreadingSesameBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-sesame/src/main/java/at/newmedialab/ldpath/backend/sesame/ThreadingSesameBackend.java b/libraries/ldpath/ldpath-backend-sesame/src/main/java/at/newmedialab/ldpath/backend/sesame/ThreadingSesameBackend.java
deleted file mode 100644
index 952abbf..0000000
--- a/libraries/ldpath/ldpath-backend-sesame/src/main/java/at/newmedialab/ldpath/backend/sesame/ThreadingSesameBackend.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed 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 at.newmedialab.ldpath.backend.sesame;
-
-
-import org.openrdf.repository.Repository;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadPoolExecutor;
-
-/**
- * A threading version of the sesame backend.
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class ThreadingSesameBackend extends SesameRepositoryBackend {
-
-    private ThreadPoolExecutor workers;
-
-    /**
-     * Initialise a new sesame backend. Repository needs to be set using setRepository.
-     */
-    protected ThreadingSesameBackend() {
-        workers = (ThreadPoolExecutor) Executors.newCachedThreadPool();
-    }
-
-    /**
-     * Initialise a new sesame backend using the repository passed as argument.
-     *
-     * @param repository
-     */
-    public ThreadingSesameBackend(Repository repository) {
-        super(repository);
-        workers = (ThreadPoolExecutor)Executors.newFixedThreadPool(4);
-    }
-
-    /**
-     * Return true if the underlying backend supports the parallel execution of queries.
-     *
-     * @return
-     */
-    @Override
-    public boolean supportsThreading() {
-        return true;
-    }
-
-    /**
-     * In case the backend supports threading, this method should return the ExecutorService representing the
-     * thread pool. LDPath lets the backend manage the thread pool to avoid excessive threading.
-     *
-     * @return
-     */
-    @Override
-    public ThreadPoolExecutor getThreadPool() {
-        return workers;
-    }
-
-    /**
-     * Shut down the thread pool
-     */
-    public void shutdown() {
-        workers.shutdownNow();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/AbstractSesameBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/AbstractSesameBackend.java b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/AbstractSesameBackend.java
new file mode 100644
index 0000000..28a9be3
--- /dev/null
+++ b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/AbstractSesameBackend.java
@@ -0,0 +1,324 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed 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.ldpath.backend.sesame;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collection;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+import java.util.concurrent.ThreadPoolExecutor;
+
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.apache.marmotta.ldpath.api.backend.RDFBackend;
+import org.openrdf.model.BNode;
+import org.openrdf.model.Literal;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Statement;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.RepositoryResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public abstract class AbstractSesameBackend implements RDFBackend<Value> {
+
+	private static final Logger log = LoggerFactory.getLogger(AbstractSesameBackend.class);
+
+	/**
+	 * Return true if the underlying backend supports the parallel execution of queries.
+	 *
+	 * @return
+	 */
+	@Override
+	public boolean supportsThreading() {
+	    return false;
+	}
+
+	/**
+	 * In case the backend supports threading, this method should return the ExecutorService representing the
+	 * thread pool. LDPath lets the backend manage the thread pool to avoid excessive threading.
+	 *
+	 * @return
+	 */
+	@Override
+	public ThreadPoolExecutor getThreadPool() {
+	    return null;
+	}
+
+	/**
+	 * Test whether the node passed as argument is a literal
+	 *
+	 * @param n the node to check
+	 * @return true if the node is a literal
+	 */
+	@Override
+	public boolean isLiteral(Value n) {
+	    return n instanceof Literal;
+	}
+
+	/**
+	 * Test whether the node passed as argument is a URI
+	 *
+	 * @param n the node to check
+	 * @return true if the node is a URI
+	 */
+	@Override
+	public boolean isURI(Value n) {
+	    return n instanceof org.openrdf.model.URI;
+	}
+
+	/**
+	 * Test whether the node passed as argument is a blank node
+	 *
+	 * @param n the node to check
+	 * @return true if the node is a blank node
+	 */
+	@Override
+	public boolean isBlank(Value n) {
+	    return n instanceof BNode;
+	}
+
+	/**
+	 * Return the language of the literal node passed as argument.
+	 *
+	 * @param n the literal node for which to return the language
+	 * @return a Locale representing the language of the literal, or null if the literal node has no language
+	 * @throws IllegalArgumentException in case the node is no literal
+	 */
+	@Override
+	public Locale getLiteralLanguage(Value n) {
+	    try {
+	        if(((Literal)n).getLanguage() != null) {
+	            return new Locale( ((Literal)n).getLanguage() );
+	        } else {
+	            return null;
+	        }
+	    } catch (ClassCastException e) {
+	        throw new IllegalArgumentException("Value "+n.stringValue()+" is not a literal" +
+	                "but of type "+debugType(n));
+	    }
+	}
+
+	/**
+	 * Return the URI of the type of the literal node passed as argument.
+	 *
+	 * @param n the literal node for which to return the typer
+	 * @return a URI representing the type of the literal content, or null if the literal is untyped
+	 * @throws IllegalArgumentException in case the node is no literal
+	 */
+	@Override
+	public URI getLiteralType(Value n) {
+	    try {
+	        if(((Literal)n).getDatatype() != null) {
+	            try {
+	                return new URI(((Literal)n).getDatatype().stringValue());
+	            } catch (URISyntaxException e) {
+	                log.error("literal datatype was not a valid URI: {}",((Literal) n).getDatatype());
+	                return null;
+	            }
+	        } else {
+	            return null;
+	        }
+	    } catch (ClassCastException e) {
+	        throw new IllegalArgumentException("Value "+n.stringValue()+" is not a literal" +
+	                "but of type "+debugType(n));
+	    }
+	}
+
+	/**
+	 * Return the string value of a node. For a literal, this will be the content, for a URI node it will be the
+	 * URI itself, and for a blank node it will be the identifier of the node.
+	 *
+	 * @param value
+	 * @return
+	 */
+	@Override
+	public String stringValue(Value value) {
+	    return value.stringValue();
+	}
+
+	@Override
+	public BigDecimal decimalValue(Value node) {
+	    try {
+	        return ((Literal)node).decimalValue();
+	    } catch (ClassCastException e) {
+	        throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" +
+	                "but of type "+debugType(node));
+	    }
+	}
+
+	@Override
+	public BigInteger integerValue(Value node) {
+	    try {
+	        return ((Literal)node).integerValue();
+	    } catch (ClassCastException e) {
+	        throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" +
+	                "but of type "+debugType(node));
+	    }
+	}
+
+	@Override
+	public Boolean booleanValue(Value node) {
+	    try {
+	        return ((Literal)node).booleanValue();
+	    } catch (ClassCastException e) {
+	        throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" +
+	                "but of type "+debugType(node));
+	    }
+	}
+
+	@Override
+	public Date dateTimeValue(Value node) {
+	    try {
+	        XMLGregorianCalendar cal = ((Literal)node).calendarValue();
+	        //TODO: check if we need to deal with timezone and Local here
+	        return cal.toGregorianCalendar().getTime();
+	    } catch (ClassCastException e) {
+	        throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" +
+	                "but of type "+debugType(node));
+	    }
+	}
+
+	@Override
+	public Date dateValue(Value node) {
+	    try {
+	        XMLGregorianCalendar cal = ((Literal)node).calendarValue();
+	        return new GregorianCalendar(cal.getYear(), cal.getMonth(), cal.getDay()).getTime();
+	    } catch (ClassCastException e) {
+	        throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" +
+	                "but of type "+debugType(node));
+	    }
+	}
+
+	@Override
+	public Date timeValue(Value node) {
+	    //TODO: Unless someone knwos how to create a Date that only has the time
+	    //      from a XMLGregorianCalendar
+	    return dateTimeValue(node);
+	}
+
+	@Override
+	public Long longValue(Value node) {
+	    try {
+	        return ((Literal)node).longValue();
+	    } catch (ClassCastException e) {
+	        throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" +
+	                "but of type "+debugType(node));
+	    }
+	}
+
+	@Override
+	public Double doubleValue(Value node) {
+	    try {
+	        return ((Literal)node).doubleValue();
+	    } catch (ClassCastException e) {
+	        throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" +
+	                "but of type "+debugType(node));
+	    }
+	}
+
+	@Override
+	public Float floatValue(Value node) {
+	    try {
+	        return ((Literal)node).floatValue();
+	    } catch (ClassCastException e) {
+	        throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" +
+	                "but of type "+debugType(node));
+	    }
+	}
+
+	@Override
+	public Integer intValue(Value node) {
+	    try {
+	        return ((Literal)node).intValue();
+	    } catch (ClassCastException e) {
+	        throw new IllegalArgumentException("Value "+node.stringValue()+" is not a literal" +
+	                "but of type "+debugType(node));
+	    }
+	}
+
+	protected Collection<Value> listObjectsInternal(RepositoryConnection connection, Resource subject, org.openrdf.model.URI property)
+			throws RepositoryException {
+				Set<Value> result = new HashSet<Value>();
+				RepositoryResult<Statement> qResult = connection.getStatements(subject, property, null, true);
+				try {
+					while(qResult.hasNext()) {
+						result.add(qResult.next().getObject());
+					}
+				} finally {
+					qResult.close();
+				}
+				return  result;
+			}
+
+	protected Collection<Value> listSubjectsInternal(final RepositoryConnection connection, org.openrdf.model.URI property, Value object)
+			throws RepositoryException {
+				Set<Value> result = new HashSet<Value>();
+				RepositoryResult<Statement> qResult = connection.getStatements(null, property, object, true);
+				try {
+				    while(qResult.hasNext()) {
+				        result.add(qResult.next().getSubject());
+				    }
+				} finally {
+					qResult.close();
+				}
+				return  result;
+			}
+
+	protected Value createURIInternal(final ValueFactory valueFactory, String uri) {
+		return valueFactory.createURI(uri);
+	}
+
+	protected Value createLiteralInternal(final ValueFactory valueFactory, String content) {
+		log.debug("creating literal with content \"{}\"",content);
+		return valueFactory.createLiteral(content);
+	}
+
+	protected Value createLiteralInternal(final ValueFactory valueFactory, String content, Locale language, URI type) {
+		log.debug("creating literal with content \"{}\", language {}, datatype {}",new Object[]{content,language,type});
+		if(language == null && type == null) {
+	        return valueFactory.createLiteral(content);
+	    } else if(type == null) {
+	        return valueFactory.createLiteral(content,language.getLanguage());
+	    } else  {
+	        return valueFactory.createLiteral(content, valueFactory.createURI(type.toString()));
+	    }
+	}
+
+	/**
+	 * Prints the type (URI,bNode,literal) by inspecting the parsed {@link Value}
+	 * to improve error messages and other loggings. In case of literals 
+	 * also the {@link #getLiteralType(Value) literal type} is printed
+	 * @param value the value or <code>null</code> 
+	 * @return the type as string.
+	 */
+	protected String debugType(Value value) {
+	    return value == null ? "null":isURI(value)?"URI":isBlank(value)?"bNode":
+	            "literal ("+getLiteralType(value)+")";
+	}
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameConnectionBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameConnectionBackend.java b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameConnectionBackend.java
new file mode 100644
index 0000000..008e180
--- /dev/null
+++ b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameConnectionBackend.java
@@ -0,0 +1,85 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed 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.ldpath.backend.sesame;
+
+import java.net.URI;
+import java.util.Collection;
+import java.util.Locale;
+
+import org.openrdf.model.Resource;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+
+public class SesameConnectionBackend extends AbstractSesameBackend {
+
+	private final RepositoryConnection connection;
+	private final ValueFactory valueFactory;
+
+	public SesameConnectionBackend(RepositoryConnection connection) {
+		this.connection = connection;
+		valueFactory = connection.getValueFactory();
+	}
+
+	@Override
+	public Value createLiteral(String content) {
+		return createLiteralInternal(valueFactory, content);
+	}
+
+	@Override
+	public Value createLiteral(String content, Locale language, URI type) {
+		return createLiteralInternal(valueFactory, content, language, type);
+	}
+
+	@Override
+	public Value createURI(String uri) {
+		return createURIInternal(valueFactory, uri);
+	}
+
+	@Override
+	public Collection<Value> listObjects(Value subject, Value property) {
+		try {
+			return listObjectsInternal(connection, (Resource) subject, (org.openrdf.model.URI) property);
+		} catch (RepositoryException e) {
+			throw new RuntimeException(
+					"error while querying Sesame repository!", e);
+		} catch (ClassCastException e) {
+			throw new IllegalArgumentException(String.format(
+					"Subject needs to be a URI or blank node, property a URI node "
+							+ "(types: [subject: %s, property: %s])",
+					debugType(subject), debugType(property)), e);
+		}
+	}
+
+	@Override
+	public Collection<Value> listSubjects(Value property, Value object) {
+        try {
+        	return listSubjectsInternal(connection, (org.openrdf.model.URI) property, object);
+        } catch (RepositoryException e) {
+            throw new RuntimeException("error while querying Sesame repository!",e);
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException(String.format(
+                    "Property needs to be a URI node (property type: %s)",
+                    isURI(property)?"URI":isBlank(property)?"bNode":"literal"),e);
+        }
+	}
+
+	public static SesameConnectionBackend withConnection(RepositoryConnection connection) {
+		return new SesameConnectionBackend(connection);
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameRepositoryBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameRepositoryBackend.java b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameRepositoryBackend.java
new file mode 100644
index 0000000..0e2d218
--- /dev/null
+++ b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameRepositoryBackend.java
@@ -0,0 +1,161 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed 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.ldpath.backend.sesame;
+
+import java.net.URI;
+import java.util.Collection;
+import java.util.Locale;
+
+import org.openrdf.model.Resource;
+import org.openrdf.model.Value;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+
+/**
+ * Generic implementation of a Sesame backend for LDPath. A Sesame repository is passed as argument to the
+ * constructor.
+ * <p/>
+ * Implementatins can either use this class directly or implement their own Sesame-based backend by subclassing
+ * and calling the super constructor.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class SesameRepositoryBackend extends AbstractSesameBackend {
+
+    private Repository repository;
+
+    /**
+     * Initialise a new sesame backend. Repository needs to be set using setRepository.
+     */
+    protected SesameRepositoryBackend() {
+    }
+
+    /**
+     * Initialise a new sesame backend using the repository passed as argument.
+     *
+     * @param repository
+     */
+    public SesameRepositoryBackend(Repository repository) {
+        this.repository = repository;
+    }
+
+    public Repository getRepository() {
+        return repository;
+    }
+
+    public void setRepository(Repository repository) {
+        this.repository = repository;
+    }
+
+
+    /**
+     * Create a literal node with the content passed as argument
+     *
+     * @param content string content to represent inside the literal
+     * @return a literal node in using the model used by this backend
+     */
+    @Override
+    public Value createLiteral(String content) {
+    	return createLiteralInternal(repository.getValueFactory(), content);
+    }
+
+
+    /**
+     * Create a literal node with the content passed as argument
+     *
+     * @param content string content to represent inside the literal
+     * @return a literal node in using the model used by this backend
+     */
+    @Override
+    public Value createLiteral(String content, Locale language, URI type) {
+    	return createLiteralInternal(repository.getValueFactory(), content, language, type);
+    }
+
+
+    /**
+     * Create a URI mode with the URI passed as argument
+     *
+     * @param uri URI of the resource to create
+     * @return a URI node using the model used by this backend
+     */
+    @Override
+    public Value createURI(String uri) {
+        return createURIInternal(repository.getValueFactory(), uri);
+    }
+
+    /**
+     * List the objects of triples in the triple store underlying this backend that have the subject and
+     * property given as argument.
+     *
+     * @param subject  the subject of the triples to look for
+     * @param property the property of the triples to look for
+     * @return all objects of triples with matching subject and property
+     */
+    @Override
+    public Collection<Value> listObjects(Value subject, Value property) {
+        try {
+            RepositoryConnection connection = repository.getConnection();
+
+            try {
+            	connection.begin();
+            	return listObjectsInternal(connection, (Resource) subject, (org.openrdf.model.URI) property);
+            } finally {
+                connection.commit();
+                connection.close();
+            }
+        } catch (RepositoryException e) {
+            throw new RuntimeException("error while querying Sesame repository!",e);
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException(String.format(
+                    "Subject needs to be a URI or blank node, property a URI node " +
+                            "(types: [subject: %s, property: %s])",
+                    debugType(subject),debugType(property)),e);
+        }
+
+    }
+
+	/**
+     * List the subjects of triples in the triple store underlying this backend that have the object and
+     * property given as argument.
+     *
+     * @param object   the object of the triples to look for
+     * @param property the property of the triples to look for
+     * @return all subjects of triples with matching object and property
+     * @throws UnsupportedOperationException in case reverse selection is not supported (e.g. when querying Linked Data)
+     */
+    @Override
+    public Collection<Value> listSubjects(Value property, Value object) {
+        try {
+            final RepositoryConnection connection = repository.getConnection();
+
+            try {
+            	connection.begin();
+            	return listSubjectsInternal(connection, (org.openrdf.model.URI) property, object);
+            } finally {
+                connection.commit();
+                connection.close();
+            }
+        } catch (RepositoryException e) {
+            throw new RuntimeException("error while querying Sesame repository!",e);
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException(String.format(
+                    "Property needs to be a URI node (property type: %s)",
+                    isURI(property)?"URI":isBlank(property)?"bNode":"literal"),e);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/ThreadingSesameBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/ThreadingSesameBackend.java b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/ThreadingSesameBackend.java
new file mode 100644
index 0000000..fede1bf
--- /dev/null
+++ b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/ThreadingSesameBackend.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed 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.ldpath.backend.sesame;
+
+
+import org.openrdf.repository.Repository;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * A threading version of the sesame backend.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class ThreadingSesameBackend extends SesameRepositoryBackend {
+
+    private ThreadPoolExecutor workers;
+
+    /**
+     * Initialise a new sesame backend. Repository needs to be set using setRepository.
+     */
+    protected ThreadingSesameBackend() {
+        workers = (ThreadPoolExecutor) Executors.newCachedThreadPool();
+    }
+
+    /**
+     * Initialise a new sesame backend using the repository passed as argument.
+     *
+     * @param repository
+     */
+    public ThreadingSesameBackend(Repository repository) {
+        super(repository);
+        workers = (ThreadPoolExecutor)Executors.newFixedThreadPool(4);
+    }
+
+    /**
+     * Return true if the underlying backend supports the parallel execution of queries.
+     *
+     * @return
+     */
+    @Override
+    public boolean supportsThreading() {
+        return true;
+    }
+
+    /**
+     * In case the backend supports threading, this method should return the ExecutorService representing the
+     * thread pool. LDPath lets the backend manage the thread pool to avoid excessive threading.
+     *
+     * @return
+     */
+    @Override
+    public ThreadPoolExecutor getThreadPool() {
+        return workers;
+    }
+
+    /**
+     * Shut down the thread pool
+     */
+    public void shutdown() {
+        workers.shutdownNow();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-core/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/pom.xml b/libraries/ldpath/ldpath-core/pom.xml
index cb4a42c..e9817b8 100644
--- a/libraries/ldpath/ldpath-core/pom.xml
+++ b/libraries/ldpath/ldpath-core/pom.xml
@@ -107,7 +107,6 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-jar-plugin</artifactId>
-                <version>2.4</version>
                 <executions>
                     <execution>
                         <goals>
@@ -115,7 +114,7 @@
                         </goals>
                         <configuration>
                             <includes>
-                                <include>core/**</include>
+                                <include>org/apache/marmotta/ldpath/test/**</include>
                             </includes>
                         </configuration>
                     </execution>
@@ -171,11 +170,11 @@
                         <!-- Enable this for including your enhancement chain configuration -->
                         <!-- <Install-Path>config</Install-Path> -->
                         <Export-Package>
-                            at.newmedialab.ldpath;version=${project.version},
-                            at.newmedialab.ldpath.exception;version=${project.version},
-                            at.newmedialab.ldpath.model.*;version=${project.version},
-                            at.newmedialab.ldpath.util;version=${project.version}
-                            at.newmedialab.ldpath.parser;version=${project.version}
+                            org.apache.marmotta.ldpath;version=${project.version},
+                            org.apache.marmotta.ldpath.exception;version=${project.version},
+                            org.apache.marmotta.ldpath.model.*;version=${project.version},
+                            org.apache.marmotta.ldpath.util;version=${project.version}
+                            org.apache.marmotta.ldpath.parser;version=${project.version}
                         </Export-Package>
                         <_include>src/main/resources/META-INF/MANIFEST.MF</_include>
                     </instructions>

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/LDPath.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/LDPath.java b/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/LDPath.java
deleted file mode 100644
index 5c6e867..0000000
--- a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/LDPath.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed 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 at.newmedialab.ldpath;
-
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.api.functions.SelectorFunction;
-import at.newmedialab.ldpath.api.selectors.NodeSelector;
-import at.newmedialab.ldpath.api.transformers.NodeTransformer;
-import at.newmedialab.ldpath.exception.LDPathParseException;
-import at.newmedialab.ldpath.model.fields.FieldMapping;
-import at.newmedialab.ldpath.model.programs.Program;
-import at.newmedialab.ldpath.parser.Configuration;
-import at.newmedialab.ldpath.parser.DefaultConfiguration;
-import at.newmedialab.ldpath.parser.ParseException;
-import at.newmedialab.ldpath.parser.RdfPathParser;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Main class providing query functionality for the different RDF backends.
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class LDPath<Node> {
-
-    private RDFBackend<Node> backend;
-
-    private HashSet<SelectorFunction<Node>> functions;
-
-    private HashMap<String,NodeTransformer<?,Node>> transformers;
-
-    private Configuration<Node> config;
-
-    /**
-     * Initialise a new LDPath instance for querying the backend passed as argument with the default configuration.
-     * @param backend
-     */
-    public LDPath(RDFBackend<Node> backend) {
-        this(backend,new DefaultConfiguration<Node>());
-    }
-
-    /**
-     * Initialise a new LDPath instance for querying the backend passed as argument with a custom configuration
-     * for default functions, transformers and namespaces.
-     *
-     * @param backend
-     * @param config
-     */
-    public LDPath(RDFBackend<Node> backend, Configuration<Node> config) {
-        this.backend      = backend;
-        this.functions    = new HashSet<SelectorFunction<Node>>();
-        this.transformers = new HashMap<String, NodeTransformer<?, Node>>();
-        this.config       = config;
-    }
-
-    /**
-     * Execute a single path query starting from the given context node and return a collection of nodes resulting
-     * from the selection. Default namespaces (rdf, rdfs, skos, dc, foaf) are added automatically, further namespaces
-     * need to be passed as arguments.
-     * <p/>
-     * Paths need to conform to the RdfPath Selector syntax described at
-     * <a href="http://code.google.com/p/kiwi/wiki/RdfPathLanguage#Path_Selectors">the wiki</a>.
-     * For example, the following selection would select the names of all friends:
-     * <p/>
-     * <code>
-     * foaf:knows / foaf:name
-     * </code>
-     * <p/>
-     * Note that since this method returns a collection of nodes, no transformations can be used.
-     *
-     * @param context the context node where to start the path query
-     * @param path  the LDPath path specification
-     * @param namespaces an optional map mapping namespace prefixes to URIs (used for lookups of prefixes used in the path);
-     *                   can be null
-     * @return a collection of nodes
-     * @throws LDPathParseException when the path passed as argument is not valid
-     */
-    public Collection<Node> pathQuery(Node context, String path, Map<String, String> namespaces) throws LDPathParseException {
-        RdfPathParser<Node> parser = new RdfPathParser<Node>(backend,config,new StringReader(path));
-        for(SelectorFunction<Node> function : functions) {
-            parser.registerFunction(function);
-        }
-        for(String typeUri : transformers.keySet()) {
-            parser.registerTransformer(typeUri,transformers.get(typeUri));
-        }
-
-        try {
-            NodeSelector<Node> selector = parser.parseSelector(namespaces);
-
-            return selector.select(backend,context,null,null);
-
-        } catch (ParseException e) {
-            throw new LDPathParseException("error while parsing path expression",e);
-        }
-
-    }
-
-
-    /**
-     * Execute a single path query starting from the given context node and return a collection of nodes resulting
-     * from the selection. In addition, the paths leading to the individual results are returned in the map passed as
-     * argument "paths".
-     * <p/>
-     * Default namespaces (rdf, rdfs, skos, dc, foaf) are added automatically, further namespaces
-     * need to be passed as arguments.
-     * <p/>
-     * Paths need to conform to the RdfPath Selector syntax described at
-     * <a href="http://code.google.com/p/kiwi/wiki/RdfPathLanguage#Path_Selectors">the wiki</a>.
-     * For example, the following selection would select the names of all friends:
-     * <p/>
-     * <code>
-     * foaf:knows / foaf:name
-     * </code>
-     * <p/>
-     * Note that since this method returns a collection of nodes, no transformations can be used.
-     *
-     * @param context the context node where to start the path query
-     * @param path  the LDPath path specification
-     * @param namespaces an optional map mapping namespace prefixes to URIs (used for lookups of prefixes used in the path);
-     *                   can be null
-     * @return a collection of nodes
-     * @throws LDPathParseException when the path passed as argument is not valid
-     */
-    public Collection<Node> pathQuery(Node context, String path, Map<String, String> namespaces, Map<Node,List<Node>> paths) throws LDPathParseException {
-        RdfPathParser<Node> parser = new RdfPathParser<Node>(backend,config,new StringReader(path));
-        for(SelectorFunction<Node> function : functions) {
-            parser.registerFunction(function);
-        }
-        for(String typeUri : transformers.keySet()) {
-            parser.registerTransformer(typeUri,transformers.get(typeUri));
-        }
-
-        try {
-            NodeSelector<Node> selector = parser.parseSelector(namespaces);
-
-            return selector.select(backend, context, ImmutableList.<Node> of(), paths);
-
-        } catch (ParseException e) {
-            throw new LDPathParseException("error while parsing path expression",e);
-        }
-
-    }
-
-
-
-    /**
-     * Execute a single path query starting from the given context node and return a collection of nodes resulting
-     * from the selection. Default namespaces (rdf, rdfs, skos, dc, foaf) are added automatically, further namespaces
-     * need to be passed as arguments.
-     * <p/>
-     * Paths need to conform to the RdfPath Selector syntax described at
-     * <a href="http://code.google.com/p/kiwi/wiki/RdfPathLanguage#Path_Selectors">the wiki</a>.
-     * For example, the following selection would select the names of all friends:
-     * <p/>
-     * <code>
-     * foaf:knows / foaf:name
-     * </code>
-     * <p/>
-     * Note that since this method returns a collection of nodes, no transformations can be used.
-     *
-     * @param context the context node where to start the path query
-     * @param path  the LDPath path specification
-     * @param namespaces an optional map mapping namespace prefixes to URIs (used for lookups of prefixes used in the path);
-     *                   can be null
-     * @return a collection of nodes
-     * @throws LDPathParseException when the path passed as argument is not valid
-     */
-    public <T> Collection<T> pathTransform(Node context, String path, Map<String, String> namespaces) throws LDPathParseException {
-        RdfPathParser<Node> parser = new RdfPathParser<Node>(backend,config,new StringReader(path));
-        for(SelectorFunction<Node> function : functions) {
-            parser.registerFunction(function);
-        }
-        for(String typeUri : transformers.keySet()) {
-            parser.registerTransformer(typeUri,transformers.get(typeUri));
-        }
-
-        try {
-            FieldMapping<T,Node> mapping = parser.parseRule(namespaces);
-
-            return mapping.getValues(backend, context);
-
-        } catch (ParseException e) {
-            throw new LDPathParseException("error while parsing path expression",e);
-        }
-
-    }
-
-    /**
-     * Evaluate a path program passed as argument starting from the given context node and return a mapping for
-     * each field in the program to the selected values.
-     *
-     * @param context
-     * @param program
-     * @return
-     * @throws LDPathParseException
-     */
-    public Map<String,Collection<?>> programQuery(Node context, Reader program) throws LDPathParseException {
-        RdfPathParser<Node> parser = new RdfPathParser<Node>(backend,config,program);
-        for(SelectorFunction<Node> function : functions) {
-            parser.registerFunction(function);
-        }
-        for(String typeUri : transformers.keySet()) {
-            parser.registerTransformer(typeUri, transformers.get(typeUri));
-        }
-
-        try {
-            Program<Node> p = parser.parseProgram();
-
-            Map<String,Collection<?>> result = new HashMap<String, Collection<?>>();
-
-            for(FieldMapping<?,Node> mapping : p.getFields()) {
-                result.put(mapping.getFieldName(),mapping.getValues(backend,context));
-            }
-
-            return result;
-
-        } catch (ParseException e) {
-            throw new LDPathParseException("error while parsing path expression",e);
-        }
-    }
-
-    /**
-     * Parse a program passed as argument and return it for further use.
-     *
-     * @param program a reader containing the program in LDPath syntax
-     * @return the parsed program
-     * @throws LDPathParseException
-     */
-    public Program<Node> parseProgram(Reader program) throws LDPathParseException {
-        RdfPathParser<Node> parser = new RdfPathParser<Node>(backend,config,program);
-        for(SelectorFunction<Node> function : functions) {
-            parser.registerFunction(function);
-        }
-        for(String typeUri : transformers.keySet()) {
-            parser.registerTransformer(typeUri, transformers.get(typeUri));
-        }
-
-        try {
-            return parser.parseProgram();
-        } catch (ParseException e) {
-            throw new LDPathParseException("error while parsing path program",e);
-        }
-    }
-
-    /**
-     * Register a selector function to be used in LDPath. Use this method in your own
-     * projects to register custom selector functions.
-     * @param function
-     */
-    public void registerFunction(SelectorFunction<Node> function) {
-        functions.add(function);
-    }
-
-    /**
-     * Return the collection of selector functions registered with this LDPath instance.
-     *
-     * @return
-     */
-    public Set<SelectorFunction<Node>> getFunctions() {
-        return ImmutableSet.copyOf(functions);
-    }
-
-    /**
-     * Register a result transformer for a type URI. Use this method in your own projects
-     * to register custom result transformers.
-     *
-     * @param typeUri a URI identifying the type for which to use this transformer; can be specified in path programs
-     * @param transformer instance of a node transformer
-     */
-    public void registerTransformer(String typeUri, NodeTransformer<?,Node> transformer) {
-        transformers.put(typeUri,transformer);
-    }
-
-    public Map<String, NodeTransformer<?,Node>> getTransformers() {
-        return ImmutableMap.copyOf(transformers);
-    }
-
-
-    /**
-     * Return the configuration underlying this LDPath instance.
-     * @return
-     */
-    public Configuration<Node> getConfig() {
-        return config;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/exception/LDPathParseException.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/exception/LDPathParseException.java b/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/exception/LDPathParseException.java
deleted file mode 100644
index ebd0254..0000000
--- a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/exception/LDPathParseException.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed 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 at.newmedialab.ldpath.exception;
-
-/**
- * Thrown when parsing a path query failed.
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class LDPathParseException extends Exception {
-
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * Constructs a new exception with <code>null</code> as its detail message.
-     * The cause is not initialized, and may subsequently be initialized by a
-     * call to {@link #initCause}.
-     */
-    public LDPathParseException() {
-    }
-
-    /**
-     * Constructs a new exception with the specified detail message.  The
-     * cause is not initialized, and may subsequently be initialized by
-     * a call to {@link #initCause}.
-     *
-     * @param message the detail message. The detail message is saved for
-     *                later retrieval by the {@link #getMessage()} method.
-     */
-    public LDPathParseException(String message) {
-        super(message);
-    }
-
-    /**
-     * Constructs a new exception with the specified detail message and
-     * cause.  <p>Note that the detail message associated with
-     * <code>cause</code> is <i>not</i> automatically incorporated in
-     * this exception's detail message.
-     *
-     * @param message the detail message (which is saved for later retrieval
-     *                by the {@link #getMessage()} method).
-     * @param cause   the cause (which is saved for later retrieval by the
-     *                {@link #getCause()} method).  (A <tt>null</tt> value is
-     *                permitted, and indicates that the cause is nonexistent or
-     *                unknown.)
-     * @since 1.4
-     */
-    public LDPathParseException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    /**
-     * Constructs a new exception with the specified cause and a detail
-     * message of <tt>(cause==null ? null : cause.toString())</tt> (which
-     * typically contains the class and detail message of <tt>cause</tt>).
-     * This constructor is useful for exceptions that are little more than
-     * wrappers for other throwables (for example, {@link
-     * java.security.PrivilegedActionException}).
-     *
-     * @param cause the cause (which is saved for later retrieval by the
-     *              {@link #getCause()} method).  (A <tt>null</tt> value is
-     *              permitted, and indicates that the cause is nonexistent or
-     *              unknown.)
-     * @since 1.4
-     */
-    public LDPathParseException(Throwable cause) {
-        super(cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/Constants.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/Constants.java b/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/Constants.java
deleted file mode 100644
index f3c8cb9..0000000
--- a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/Constants.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed 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 at.newmedialab.ldpath.model;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class Constants {
-
-    public static final String NS_XSD          = "http://www.w3.org/2001/XMLSchema#";
-
-
-    public static final String NS_RDF          = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
-    public static final String NS_RDFS         = "http://www.w3.org/2000/01/rdf-schema#";
-    public static final String NS_OWL          = "http://www.w3.org/2002/07/owl#";
-
-
-    public static final String NS_FOAF         = "http://xmlns.com/foaf/0.1/";
-    public static final String NS_DC           = "http://purl.org/dc/elements/1.1/";
-    public static final String NS_SKOS         = "http://www.w3.org/2004/02/skos/core#";
-
-
-    // LMF Namespaces
-    public static final String NS_LMF_TYPES    = "http://www.newmedialab.at/lmf/types/1.0/";
-    public static final String NS_LMF_FUNCS    = "http://www.newmedialab.at/lmf/functions/1.0/";
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/backend/AbstractBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/backend/AbstractBackend.java b/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/backend/AbstractBackend.java
deleted file mode 100644
index 176dc9f..0000000
--- a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/backend/AbstractBackend.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed 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 at.newmedialab.ldpath.model.backend;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.util.FormatUtils;
-
-
-/**
- * This provides an generic implementation of all <code>**Value(Node node)</code> 
- * methods other than {@link #stringValue(Object)}.<p>
- * This allows to implement {@link RDFBackend}s without dealing with the actual
- * conversions needed for types literals not directly supported by a backend.<p>
- * Backends however should implement - override default implementations provided
- * by this class - <code>**Value(Node node)</code> methods with natively supported
- * types to avoid unnecessary type conversions.
- * <p>
- * An Example for a RDFRepository&lt;Object&gt; that directly uses the the
- * Java types for typed literals as nodes.
- * <code><pre>
- *     public Double doubleValue(Object node) {
- *         //assume that this is typically only called on Double values
- *         try { 
- *             return (Double)node;
- *         } catch (ClassCastException e){
- *             //not a Double - call super to trigger parsing from
- *             //the lexical form.
- *             return super.doubleValue(node);
- *         }
- * </pre></code>
- * Here an other possible implementation that does not assume that the node is
- * of the requested type.
- * <code><pre>
- *     public Double doubleValue(Object node) {
- *         if(node instanceof Double){
- *             return (Double)node;
- *         } else {
- *             //not a Double - call super to trigger parsing from
- *             //the lexical form.
- *             return super.doubleValue(node);
- *         }
- * </pre></code>
- * It will depend on the use cases what of the two implementations performs 
- * better.
- * @see at.newmedialab.ldpath.api.backend.RDFBackend#stringValue(java.lang.Object)
- */
-public abstract class AbstractBackend<Node> implements RDFBackend<Node> {
-
-    /**
-     * A clone of the DateFormat provided by {@link FormatUtils} to parse xsd:date 
-     * values. This is necessary because {@link SimpleDateFormat} is not thread 
-     * save and therefore we do not directly use a public static member.
-     */
-    private SimpleDateFormat dateFormat = (SimpleDateFormat)FormatUtils.ISO8601FORMAT_DATE.clone();
-    
-    /**
-     * A clone of the DateFormat provided by {@link FormatUtils} to parse xsd:time 
-     * values. This is necessary because {@link SimpleDateFormat} is not thread 
-     * save and therefore we do not directly use a public static member.
-     */
-    private SimpleDateFormat timeFormat = (SimpleDateFormat)FormatUtils.ISO8601FORMAT_TIME.clone();
-    /**
-     * Parses the Double value of the parsed node based on its lexical form as
-     * returned by {@link #stringValue(Object)}.
-     * @return the double value
-     * @throws NumberFormatException if the lexical form can not be converted
-     * to a Double.
-     * @see at.newmedialab.ldpath.api.backend.RDFBackend#doubleValue(java.lang.Object)
-     */
-    @Override
-    public Double doubleValue(Node node) {
-        return new Double(trimPlusSign(stringValue(node)));
-    }
-    /**
-     * Parses the Float value of the parsed node based on its lexical form as
-     * returned by {@link #stringValue(Object)}.
-     * @return the float value
-     * @throws NumberFormatException if the lexical form can not be converted
-     * to a Double.
-     * @see at.newmedialab.ldpath.api.backend.RDFBackend#floatValue(java.lang.Object)
-     */
-    public Float floatValue(Node node) {
-        return new Float(trimPlusSign(stringValue(node)));
-    };
-
-    /**
-     * Parses the {@link BigDecimal#longValueExact() Long value} of the parsed 
-     * node by using {@link #decimalValue(Object)}. This has the advantage, that
-     * decimal values that are also valid long values - such as '1.0' are also
-     * correctly converted to long.<p>
-     * @return the long value
-     * @throws NumberFormatException if the lexical form can not be converted
-     * to an Long.
-     * @throws ArithmeticException if the lexical form can not be converted
-     * to a Long.
-     * @see at.newmedialab.ldpath.api.backend.RDFBackend#longValue(java.lang.Object)
-     */
-    @Override
-    public Long longValue(Node node) {
-        return decimalValue(node).longValueExact();
-    }
-
-    /**
-     * Parses the {@link BigDecimal#intValueExact() Integer value} of the parsed 
-     * node by using {@link #decimalValue(Object)}. This has the advantage, that
-     * decimal values that are also valid integer values - such as '1.0' are also
-     * correctly converted to {@link Integer}.<p>
-     * @return the int value
-     * @throws NumberFormatException if the lexical form can not be converted
-     * to an Long.
-     * @throws ArithmeticException if the lexical form can not be converted
-     * to a Long.
-     * @see at.newmedialab.ldpath.api.backend.RDFBackend#intValue(java.lang.Object)
-     */
-    @Override
-    public Integer intValue(Node node) {
-        return decimalValue(node).intValueExact();
-    };
-    /**
-     * Parses the {@link BigDecimal} value from the lexical form of the parsed
-     * node as returned by {@link RDFBackend#stringValue(Object)}. This
-     * trims loading '+' sings.
-     * @return the int value
-     * @throws NumberFormatException if the lexical form can not be converted
-     * to an Long.
-     * @throws ArithmeticException if the lexical form can not be converted
-     * to a Long.
-     * @see at.newmedialab.ldpath.api.backend.RDFBackend#decimalValue(java.lang.Object)
-     */
-    public BigDecimal decimalValue(Node node) {
-        return new BigDecimal(trimPlusSign(stringValue(node)));
-    };
-    /**
-     * Parses the {@link BigDecimal#toBigIntegerExact() BugIneger value} of the parsed 
-     * node by using {@link #decimalValue(Object)}. This has the advantage, that
-     * decimal values that are also valid integer values - such as '1.0' are also
-     * correctly converted to {@link BigInteger}.<p>
-     * @see at.newmedialab.ldpath.api.backend.RDFBackend#integerValue(java.lang.Object)
-     */
-    public java.math.BigInteger integerValue(Node node) {
-        return decimalValue(node).toBigIntegerExact();
-    };
-    /**
-     * Parses the boolean value from the {@link #stringValue(Object) lexical form}.
-     * Supports both '1' and {@link Boolean#parseBoolean(String)}.
-     * @return the boolean value
-     * @see at.newmedialab.ldpath.api.backend.RDFBackend#booleanValue(java.lang.Object)
-     */
-    public Boolean booleanValue(Node node) {
-        String lexicalForm = stringValue(node);
-        if(lexicalForm.length() == 1){ //support '1' as true
-            return lexicalForm.charAt(0) == '1'; 
-        } else {
-            return Boolean.parseBoolean(lexicalForm);
-        }
-    };
-    /**
-     * Parses date vales based on the ISO8601 specification by using the
-     * {@link #stringValue(Object) lexical form} of the parsed node.
-     * @return the {@link Date} representing the parsed date.
-     * @throws IllegalArgumentException on any {@link ParseException} while 
-     * parsing the {@link #stringValue(Object) lexical form} of the parsed
-     * node.
-     * @see at.newmedialab.ldpath.api.backend.RDFBackend#dateValue(java.lang.Object)
-     */
-    public Date dateValue(Node node) {
-        String lexicalForm = stringValue(node);
-        try {
-            return parseDate(lexicalForm);
-        } catch (ParseException e) {
-            throw new IllegalArgumentException("could not parse ISO8601 date from '"+
-                lexicalForm+"'!",e);
-        }
-    };
-    
-    /**
-     * Parses time value based on the ISO8601 specification by using the
-     * {@link #stringValue(Object) lexical form} of the parsed node.
-     * @return the {@link Date} representing the parsed date.
-     * @throws IllegalArgumentException on any {@link ParseException} while 
-     * parsing the {@link #stringValue(Object) lexical form} of the parsed
-     * node.
-     * @see at.newmedialab.ldpath.api.backend.RDFBackend#timeValue(java.lang.Object)
-     */
-    public Date timeValue(Node node) {
-        String lexicalForm = stringValue(node);
-        try {
-            return parseTime(lexicalForm);
-        } catch (ParseException e) {
-            throw new IllegalArgumentException("could not parse ISO8601 time from '"+
-                lexicalForm+"'!",e);
-        }
-    };
-    
-    /**
-     * Parses dateTime value based on the {@link #stringValue(Object) lexical form} 
-     * of the parsed node. For details about parsing see
-     * {@link FormatUtils#parseDate(String)}.
-     * @return the {@link Date} representing the parsed date.
-     * @throws IllegalArgumentException if the parsed node can not be converted
-     * to an {@link Date}. 
-     * @see at.newmedialab.ldpath.api.backend.RDFBackend#dateTimeValue(java.lang.Object)
-     */
-    public Date dateTimeValue(Node node) {
-        String lexicalForm = stringValue(node);
-        Date date = FormatUtils.parseDate(lexicalForm);
-        if(date == null){
-            throw new IllegalArgumentException("could not parse xsd:dateTime from '"+
-                lexicalForm+"'!");
-        } else {
-            return date;
-        }
-    };
-    
-    @Override
-    public abstract String stringValue(Node node);
-    
-    /**
-     * Removes the first character from the supplied string if this is a plus
-     * sign ('+'). Number strings with leading plus signs cannot be parsed by
-     * methods such as {@link Integer#parseInt(String)}.<p>
-     * Taken from the Sesame XMLDatatypeUtil.
-     */
-    private static String trimPlusSign(String s) {
-        return (s.length() > 0 && s.charAt(0) == '+') ? s.substring(1) : s;
-    }
-    /**
-     * Utility to parse xsd:date strings
-     * @param dateString
-     * @return
-     * @throws ParseException
-     */
-    protected Date parseDate(String dateString) throws ParseException {
-        synchronized (dateFormat) {
-            return dateFormat.parse(dateString);
-        }
-    }
-    /**
-     * Utility to parse xsd:time strings
-     * @param timeString
-     * @return
-     * @throws ParseException
-     */
-    protected Date parseTime(String timeString) throws ParseException {
-        synchronized (timeFormat) {
-            return timeFormat.parse(timeString);
-        }
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/fields/FieldMapping.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/fields/FieldMapping.java b/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/fields/FieldMapping.java
deleted file mode 100644
index 1991919..0000000
--- a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/fields/FieldMapping.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed 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 at.newmedialab.ldpath.model.fields;
-
-import at.newmedialab.ldpath.api.LDPathConstruct;
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.api.selectors.NodeSelector;
-import at.newmedialab.ldpath.api.transformers.NodeTransformer;
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableList;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A field mapping maps a field name to a node selection and transforms it into the appropriate type.
- * <p/>
- * Author: Sebastian Schaffert <se...@salzburgresearch.at>
- */
-public class FieldMapping<T,Node> implements LDPathConstruct<Node> {
-
-    /**
-     * The name of the field in the search index
-     */
-    private String fieldName;
-
-    /**
-     * The type of the field in the search index
-     */
-    private String fieldType;
-
-    /**
-     * The selector to use for selecting nodes
-     */
-    private NodeSelector<Node> selector;
-
-    /**
-     * The transformer to use for generating values
-     */
-    private NodeTransformer<T,Node> transformer;
-
-    /**
-     * Additional config params for the (solr) field.
-     */
-    private Map<String, String> fieldConfig;
-
-    public FieldMapping() {
-    }
-
-    public FieldMapping(String fieldName, String fieldType, NodeSelector<Node> selector, NodeTransformer<T,Node> transformer, Map<String, String> fieldConfig) {
-    	this();
-        this.fieldName = fieldName;
-        this.fieldType = fieldType;
-        this.selector = selector;
-        this.transformer = transformer;
-        this.fieldConfig = fieldConfig;
-    }
-
-
-    public String getFieldName() {
-        return fieldName;
-    }
-
-    public String getFieldType() {
-        return fieldType;
-    }
-
-    public NodeSelector<Node> getSelector() {
-        return selector;
-    }
-
-    public void setSelector(NodeSelector<Node> selector) {
-        this.selector = selector;
-    }
-
-    public NodeTransformer<T, Node> getTransformer() {
-        return transformer;
-    }
-
-    public void setTransformer(NodeTransformer<T, Node> transformer) {
-        this.transformer = transformer;
-    }
-
-    public Map<String, String> getFieldConfig() {
-        return fieldConfig;
-    }
-
-    public void setFieldConfig(Map<String, String> fieldConfig) {
-        this.fieldConfig = fieldConfig;
-    }
-
-    /**
-     * Get the values of this mapping for the context node passed as argument, transformed into the
-     * datatype generated by the transformer.
-     *
-     * @param backend
-     * @param context
-     * @return
-     */
-    public Collection<T> getValues(final RDFBackend<Node> backend, final Node context, Map<Node,List<Node>> paths) {
-        Function<Node,T> function = new Function<Node, T>() {
-            @Override
-            public T apply(Node input) {
-                return transformer.transform(backend,input);
-            }
-        };
-
-        return Collections2.transform(selector.select(backend,context, ImmutableList.of(context), paths),function);
-    }
-
-    /**
-     * Get the values of this mapping for the context node passed as argument, transformed into the
-     * datatype generated by the transformer.
-     *
-     * @param backend
-     * @param context
-     * @return
-     */
-    public Collection<T> getValues(final RDFBackend<Node> backend, final Node context) {
-        Function<Node,T> function = new Function<Node, T>() {
-            @Override
-            public T apply(Node input) {
-                return transformer.transform(backend,input);
-            }
-        };
-
-        return Collections2.transform(selector.select(backend,context, null, null),function);
-    }
-
-    
-    
-    public String getPathExpression(RDFBackend<Node> backend) {
-        StringBuilder fc = new StringBuilder();
-        if (fieldConfig != null) {
-            fc.append("(");
-            boolean first = true;
-            for (Map.Entry<String, String> e : fieldConfig.entrySet()) {
-                if (!first) {
-                    fc.append(", ");
-                }
-                fc.append(e.getKey()).append("=\"").append(e.getValue()).append("\"");
-                first = false;
-            }
-            fc.append(")");
-        }
-        return String.format("%s = %s :: <%s>%s ;", fieldName, selector.getPathExpression(backend), fieldType, fc.toString());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/ConcatenateFunction.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/ConcatenateFunction.java b/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/ConcatenateFunction.java
deleted file mode 100644
index 4d775c0..0000000
--- a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/ConcatenateFunction.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed 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 at.newmedialab.ldpath.model.functions;
-
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.api.functions.SelectorFunction;
-import at.newmedialab.ldpath.model.transformers.StringTransformer;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-/**
- * A node function concatenating a list of nodes interpreted as strings.
- * <p/>
- * Author: Sebastian Schaffert <se...@salzburgresearch.at>
- */
-public class ConcatenateFunction<Node> extends SelectorFunction<Node> {
-
-    private final StringTransformer<Node> transformer = new StringTransformer<Node>();
-
-    /**
-     * Apply the function to the list of nodes passed as arguments and return the result as type T.
-     * Throws IllegalArgumentException if the function cannot be applied to the nodes passed as argument
-     * or the number of arguments is not correct.
-     *
-     * @param args a nested list of KiWiNodes
-     * @return
-     */
-    @Override
-    public Collection<Node> apply(RDFBackend<Node> rdfBackend, Node context, Collection<Node>... args) throws IllegalArgumentException {
-        Iterator<Node> it = at.newmedialab.ldpath.util.Collections.iterator(args);
-        StringBuilder result = new StringBuilder();
-        while (it.hasNext()) {
-            result.append(transformer.transform(rdfBackend,it.next()));
-        }
-
-        return Collections.singleton(rdfBackend.createLiteral(result.toString()));
-    }
-
-    /**
-     * Return the name of the NodeFunction for registration in the function registry
-     *
-     * @return
-     * @param backend
-     */
-    @Override
-    public String getLocalName() {
-        return "concat";
-    }
-
-    /**
-     * A string describing the signature of this node function, e.g. "fn:content(uris : Nodes) : Nodes". The
-     * syntax for representing the signature can be chosen by the implementer. This method is for informational
-     * purposes only.
-     *
-     * @return
-     */
-    @Override
-    public String getSignature() {
-        return "fn:concat(nodes : NodeList) : String";
-    }
-
-    /**
-     * A short human-readable description of what the node function does.
-     *
-     * @return
-     */
-    @Override
-    public String getDescription() {
-        return "A node function concatenating a list of nodes interpreted as strings.";
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/CountFunction.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/CountFunction.java b/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/CountFunction.java
deleted file mode 100644
index b6d86f1..0000000
--- a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/CountFunction.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed 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 at.newmedialab.ldpath.model.functions;
-
-
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.api.functions.SelectorFunction;
-
-import java.net.URI;
-import java.util.Collection;
-import java.util.LinkedList;
-
-public class CountFunction<Node> extends SelectorFunction<Node> {
-
-    private final URI dataType = URI.create("http://www.w3.org/2001/XMLSchema#integer");
-
-    @Override
-    public Collection<Node> apply(RDFBackend<Node> backend, Node context, Collection<Node>... args) throws IllegalArgumentException {
-
-        LinkedList<Node> result = new LinkedList<Node>();
-        for (Collection<Node> coll : args) {
-            final Node intLit = backend.createLiteral(String.valueOf(coll.size()), null, dataType);
-            result.add(intLit);
-        }
-
-        return result;
-    }
-
-    @Override
-    public String getSignature() {
-        return "fn:count(nodes : URIResourceList, ...) : IntegerLiteralList";
-    }
-
-    @Override
-    public String getDescription() {
-        return "Counts the number of resources in the arguments";
-    }
-
-    @Override
-    public String getLocalName() {
-        return "count";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/FirstFunction.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/FirstFunction.java b/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/FirstFunction.java
deleted file mode 100644
index c8301ce..0000000
--- a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/FirstFunction.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed 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 at.newmedialab.ldpath.model.functions;
-
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.api.functions.SelectorFunction;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * Selects the <code>first</code> node in the argument list.
- * 
- * @author jakob
- * 
- */
-public class FirstFunction<Node> extends SelectorFunction<Node> {
-
-
-    /**
-     * Apply the function to the list of nodes passed as arguments and return the result as type T.
-     * Throws IllegalArgumentException if the function cannot be applied to the nodes passed as argument
-     * or the number of arguments is not correct.
-     *
-     * @param args a nested list of KiWiNodes
-     * @return
-     */
-    @Override
-    public Collection<Node> apply(RDFBackend<Node> rdfBackend, Node context, Collection<Node>... args) throws IllegalArgumentException {
-        for (Collection<Node> arg : args) {
-            if (arg.size() > 0) { return arg; }
-        }
-        return Collections.emptyList();
-    }
-
-    /**
-     * Return the name of the NodeFunction for registration in the function registry
-     *
-     * @return
-     * @param backend
-     */
-    @Override
-    public String getLocalName() {
-        return "first";
-    }
-
-    /**
-     * A string describing the signature of this node function, e.g. "fn:content(uris : Nodes) : Nodes". The
-     * syntax for representing the signature can be chosen by the implementer. This method is for informational
-     * purposes only.
-     *
-     * @return
-     */
-    @Override
-    public String getSignature() {
-        return "fn:first(nodes : NodeList) : Node";
-    }
-
-    /**
-     * A short human-readable description of what the node function does.
-     *
-     * @return
-     */
-    @Override
-    public String getDescription() {
-        return "Selects the first node in the argument list.";
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/LastFunction.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/LastFunction.java b/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/LastFunction.java
deleted file mode 100644
index 15523dc..0000000
--- a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/LastFunction.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed 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 at.newmedialab.ldpath.model.functions;
-
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.api.functions.SelectorFunction;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * Selects the <code>last</code> node in the argument list.
- * 
- * @author jfrank
- * 
- */
-public class LastFunction<Node> extends SelectorFunction<Node> {
-
-    /**
-     * Apply the function to the list of nodes passed as arguments and return the result as type T.
-     * Throws IllegalArgumentException if the function cannot be applied to the nodes passed as argument
-     * or the number of arguments is not correct.
-     *
-     * @param args a nested list of KiWiNodes
-     * @return
-     */
-    @Override
-    public Collection<Node> apply(RDFBackend<Node> rdfBackend, Node context, Collection<Node>... args) throws IllegalArgumentException {
-        for (int i = args.length - 1; i >= 0; i--) {
-            if (args[i].size() > 0) { return args[i]; }
-        }
-        return Collections.emptyList();
-    }
-
-    /**
-     * Return the name of the NodeFunction for registration in the function registry
-     *
-     * @return
-     * @param backend
-     */
-    @Override
-    public String getLocalName() {
-        return "last";
-    }
-
-    /**
-     * A string describing the signature of this node function, e.g. "fn:content(uris : Nodes) : Nodes". The
-     * syntax for representing the signature can be chosen by the implementer. This method is for informational
-     * purposes only.
-     *
-     * @return
-     */
-    @Override
-    public String getSignature() {
-        return "fn:last(nodes : NodeList) : Node";
-    }
-
-    /**
-     * A short human-readable description of what the node function does.
-     *
-     * @return
-     */
-    @Override
-    public String getDescription() {
-        return "Returns the last element in the node list.";
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5b8766b3/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/SortFunction.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/SortFunction.java b/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/SortFunction.java
deleted file mode 100644
index 218de84..0000000
--- a/libraries/ldpath/ldpath-core/src/main/java/at/newmedialab/ldpath/model/functions/SortFunction.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed 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 at.newmedialab.ldpath.model.functions;
-
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.api.functions.SelectorFunction;
-import at.newmedialab.ldpath.model.transformers.DateTimeTransformer;
-import at.newmedialab.ldpath.model.transformers.StringTransformer;
-
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Locale;
-
-/**
- * Allow sorting of the selection passed as first argument. Usage:
- *
- * <ul>
- *   <li><b>fn:sort(path-expression)</b>: sorts the results according to ascending string order</li>
- *   <li><b>fn:sort(path-expression, order)</b>: sorts the results according to the given order in
- *        ascending direction; order can be one of "string", "number" or "date"</li>
- *   <li><b>fn:sort(path-expression, order, direction)</b>: sorts the results according to the
- *        given order in the specified direction; order can be one of "string", "number" or "date";
- *        direction can be one of "asc" or "desc"</li>
- *
- * </ul>
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class SortFunction<Node> extends SelectorFunction<Node> {
-
-    private StringTransformer<Node> transformer;
-    private DateTimeTransformer<Node> dateTransformer;
-
-
-    public SortFunction() {
-        transformer = new StringTransformer<Node>();
-        dateTransformer = new DateTimeTransformer<Node>();
-    }
-
-    /**
-     * Apply the function to the list of nodes passed as arguments and return the result as type T.
-     * Throws IllegalArgumentException if the function cannot be applied to the nodes passed as argument
-     * or the number of arguments is not correct.
-     *
-     * @param args a nested list of KiWiNodes
-     * @return
-     */
-    @Override
-    public Collection<Node> apply(final RDFBackend<Node> nodeRDFBackend, Node context, Collection<Node>... args) throws IllegalArgumentException {
-        String order     = "string";
-        String direction = "asc";
-
-        // parse arguments
-        if(args.length > 1) {
-            order     = transformer.transform(nodeRDFBackend,args[1].iterator().next());
-        }
-        if(args.length > 2) {
-            direction = transformer.transform(nodeRDFBackend,args[2].iterator().next());
-        }
-
-        Comparator<Node> comparator = null;
-
-        // some local classes for carrying out the comparison
-        if("string".equalsIgnoreCase(order)) {
-            comparator = new Comparator<Node>() {
-
-                Collator stringCollator = Collator.getInstance(Locale.getDefault());
-
-                @Override
-                public int compare(Node o1, Node o2) {
-                    return stringCollator.compare(transformer.transform(nodeRDFBackend,o1),
-                            transformer.transform(nodeRDFBackend,o2));
-                }
-            };
-        } else if("number".equalsIgnoreCase(order)) {
-            comparator = new Comparator<Node>() {
-                @Override
-                public int compare(Node o1, Node o2) {
-                    return (int)Math.signum(nodeRDFBackend.doubleValue(o2) - nodeRDFBackend.doubleValue(o1));
-                }
-            };
-        } else if("date".equalsIgnoreCase(order)) {
-            comparator = new Comparator<Node>() {
-                @Override
-                public int compare(Node o1, Node o2) {
-                    return  (int) (dateTransformer.transform(nodeRDFBackend,o2).getTime() -
-                            dateTransformer.transform(nodeRDFBackend,o1).getTime());
-                }
-            };
-        }
-
-        if("desc".equalsIgnoreCase(direction) && comparator != null) {
-            final Comparator<Node> comparator2 = comparator;
-            comparator = new Comparator<Node>() {
-
-                @Override
-                public int compare(Node o1, Node o2) {
-                    return comparator2.compare(o2,o1);
-                }
-            };
-        }
-
-        List<Node> result = new ArrayList<Node>(args[0]);
-        if(comparator != null) {
-            java.util.Collections.sort(result,comparator);
-        }
-
-        return result;
-    }
-
-    /**
-     * Return the representation of the NodeFunction or NodeSelector in the RDF Path Language
-     *
-     * @param nodeRDFBackend
-     * @return
-     */
-    @Override
-    public String getLocalName() {
-        return "sort";
-    }
-
-
-    /**
-     * A string describing the signature of this node function, e.g. "fn:content(uris : Nodes) : Nodes". The
-     * syntax for representing the signature can be chosen by the implementer. This method is for informational
-     * purposes only.
-     *
-     * @return
-     */
-    @Override
-    public String getSignature() {
-        return "fn:sort(nodes : NodeList [, (\"string\"|\"number\"|\"date\") [, (\"asc\"|\"desc\") ] ]) : NodeList ";
-    }
-
-    /**
-     * A short human-readable description of what the node function does.
-     *
-     * @return
-     */
-    @Override
-    public String getDescription() {
-        return "Sort the node list passed as first argument. The second argument can be used to determine the " +
-                "sort method, the third argument to determine the sort direction.";
-    }
-}