Repository: marmotta
Updated Branches:
  refs/heads/develop b24553cdc -> fabf99090


http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NCeil.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NCeil.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NCeil.java
new file mode 100644
index 0000000..850ac94
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NCeil.java
@@ -0,0 +1,99 @@
+/*
+ * 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.kiwi.sparql.function.numeric;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.numeric.Ceil;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NCeil extends Ceil implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        return String.format("ceil(%s)", args[0]);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.INT;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.DOUBLE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NFloor.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NFloor.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NFloor.java
new file mode 100644
index 0000000..b5e207c
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NFloor.java
@@ -0,0 +1,99 @@
+/*
+ * 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.kiwi.sparql.function.numeric;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.numeric.Floor;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NFloor extends Floor implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        return String.format("floor(%s)", args[0]);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.INT;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.DOUBLE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NRand.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NRand.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NRand.java
new file mode 100644
index 0000000..1a5b46d
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NRand.java
@@ -0,0 +1,104 @@
+/*
+ * 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.kiwi.sparql.function.numeric;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.numeric.Rand;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NRand extends Rand implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if(dialect instanceof PostgreSQLDialect) {
+            return "random()";
+        } else if(dialect instanceof H2Dialect || dialect instanceof 
MySQLDialect) {
+            return "RAND()";
+        }
+        throw new UnsupportedOperationException("RANDOM not supported in 
dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.DOUBLE;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.ANY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 0;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NRound.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NRound.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NRound.java
new file mode 100644
index 0000000..eae1127
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/numeric/NRound.java
@@ -0,0 +1,99 @@
+/*
+ * 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.kiwi.sparql.function.numeric;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.numeric.Round;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NRound extends Round implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        return String.format("round(%s)", args[0]);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.INT;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.DOUBLE;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/rdfterm/NSTRUUID.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/rdfterm/NSTRUUID.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/rdfterm/NSTRUUID.java
new file mode 100644
index 0000000..3c60294
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/rdfterm/NSTRUUID.java
@@ -0,0 +1,103 @@
+/*
+ * 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.kiwi.sparql.function.rdfterm;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.rdfterm.STRUUID;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NSTRUUID extends STRUUID implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if(dialect instanceof PostgreSQLDialect) {
+            return "CAST(gen_random_uuid() AS text)";
+        } else if(dialect instanceof MySQLDialect) {
+            return "UUID()";
+        }
+        throw new UnsupportedOperationException("STRUUID not supported in 
dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.ANY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 0;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/rdfterm/NUUID.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/rdfterm/NUUID.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/rdfterm/NUUID.java
new file mode 100644
index 0000000..04a6962
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/rdfterm/NUUID.java
@@ -0,0 +1,103 @@
+/*
+ * 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.kiwi.sparql.function.rdfterm;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.rdfterm.UUID;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NUUID extends UUID implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if(dialect instanceof PostgreSQLDialect) {
+            return "'urn:uuid:' || gen_random_uuid()";
+        } else if(dialect instanceof MySQLDialect) {
+            return "CONCAT('urn:uuid:', UUID())";
+        }
+        throw new UnsupportedOperationException("UUID not supported in dialect 
"+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.URI;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.ANY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 0;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NConcat.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NConcat.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NConcat.java
new file mode 100644
index 0000000..c7ad3b8
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NConcat.java
@@ -0,0 +1,105 @@
+/*
+ * 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.kiwi.sparql.function.string;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.string.Concat;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NConcat extends Concat implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("(%s)", StringUtils.join(args, "||"));
+        } else if (dialect instanceof H2Dialect || dialect instanceof 
MySQLDialect) {
+            return String.format("CONCAT(%s)", StringUtils.join(args, ","));
+        }
+        throw new UnsupportedOperationException("CONCAT not supported by " + 
dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return Integer.MAX_VALUE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NContains.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NContains.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NContains.java
new file mode 100644
index 0000000..e786b8c
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NContains.java
@@ -0,0 +1,106 @@
+/*
+ * 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.kiwi.sparql.function.string;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.string.Contains;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NContains extends Contains implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("(position(%s in %s) > 0)", args[1], args[0]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("(POSITION(%s, %s) > 0)", args[1], args[0]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("(POSITION(%s IN %s) > 0)", args[1], args[0]);
+        }
+        throw new UnsupportedOperationException("CONTAINS not supported in 
dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.BOOL;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NLowerCase.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NLowerCase.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NLowerCase.java
new file mode 100644
index 0000000..ac8226e
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NLowerCase.java
@@ -0,0 +1,99 @@
+/*
+ * 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.kiwi.sparql.function.string;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.string.LowerCase;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NLowerCase extends LowerCase implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        return String.format("LOWER(%s)", args[0]);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NReplace.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NReplace.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NReplace.java
new file mode 100644
index 0000000..cd1b848
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NReplace.java
@@ -0,0 +1,116 @@
+/*
+ * 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.kiwi.sparql.function.string;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.string.Replace;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NReplace extends Replace implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            if(args.length == 3) {
+                // no flags
+                return String.format("regexp_replace(%s, %s, %s, 'g')", 
args[0], args[1], args[2]);
+            } else if(args.length == 4) {
+                // flags
+                StringBuilder psqlFlags = new StringBuilder();
+                if(StringUtils.containsIgnoreCase(args[3], "i")) {
+                    psqlFlags.append("i");
+                }
+
+                return String.format("regexp_replace(%s, %s, %s, 'g%s')", 
args[0], args[1], args[2], psqlFlags.toString());
+            }
+        } else if (dialect instanceof H2Dialect) {
+            // no flags
+            return String.format("REGEXP_REPLACE(%s, %s, %s)", args[0], 
args[1], args[2]);
+        }
+        throw new UnsupportedOperationException("REPLACE not supported in 
dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 3;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 4;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrAfter.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrAfter.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrAfter.java
new file mode 100644
index 0000000..cfd7286
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrAfter.java
@@ -0,0 +1,106 @@
+/*
+ * 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.kiwi.sparql.function.string;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.string.StrAfter;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NStrAfter extends StrAfter implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("(CASE WHEN position(%2$s in %1$s) > 0 THEN 
substring(%1$s from position(%2$s in %1$s) + char_length(%2$s) ) ELSE '' END)", 
args[0], args[1]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("(CASE WHEN position(%2$s, %1$s) > 0 THEN 
substring(%1$s, position(%2$s, %1$s)  + CHAR_LENGTH(%2$s)) ELSE '' END)", 
args[0], args[1]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("(CASE WHEN position(%2$s IN %1$s) > 0 THEN 
substring(%1$s, position(%2$s IN %1$s) + CHAR_LENGTH(%2$s)) ELSE '' END)", 
args[0], args[1]);
+        }
+        throw new UnsupportedOperationException("SUBSTRING-AFTER not supported 
in dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrBefore.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrBefore.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrBefore.java
new file mode 100644
index 0000000..2136e18
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrBefore.java
@@ -0,0 +1,106 @@
+/*
+ * 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.kiwi.sparql.function.string;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.string.StrBefore;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NStrBefore extends StrBefore implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("(CASE WHEN position(%2$s in %1$s) > 0 THEN 
substring(%1$s from 1 for position(%2$s in %1$s)-1) ELSE '' END)", args[0], 
args[1]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("(CASE WHEN position(%2$s, %1$s) > 0 THEN 
substring(%1$s, 1, position(%2$s, %1$s)-1) ELSE '' END)", args[0], args[1]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("(CASE WHEN position(%2$s IN %1$s) > 0 THEN 
substring(%1$s, 1, position(%2$s IN %1$s)-1) ELSE '' END)", args[0], args[1]);
+        }
+        throw new UnsupportedOperationException("SUBSTRING-BEFORE not 
supported in dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrEnds.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrEnds.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrEnds.java
new file mode 100644
index 0000000..4b98dbb
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrEnds.java
@@ -0,0 +1,106 @@
+/*
+ * 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.kiwi.sparql.function.string;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.string.StrEnds;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NStrEnds extends StrEnds implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("(POSITION(reverse(%2$s) IN reverse(%1$s)) = 
1)", args[0], args[1]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("(SUBSTRING(%1$s, - CHAR_LENGTH(%2$s)) = 
%2$s)", args[0], args[1]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("(POSITION(reverse(%2$s) IN reverse(%1$s)) = 
1)", args[0], args[1]);
+        }
+        throw new UnsupportedOperationException("ENDS-WITH not supported in 
dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.BOOL;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrLen.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrLen.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrLen.java
new file mode 100644
index 0000000..6f30c87
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrLen.java
@@ -0,0 +1,99 @@
+/*
+ * 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.kiwi.sparql.function.string;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.string.StrLen;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NStrLen extends StrLen implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        return String.format("CHAR_LENGTH(%s)", args[0]);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.INT;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrStarts.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrStarts.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrStarts.java
new file mode 100644
index 0000000..fdb2d27
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NStrStarts.java
@@ -0,0 +1,106 @@
+/*
+ * 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.kiwi.sparql.function.string;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.string.StrStarts;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NStrStarts extends StrStarts implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("(POSITION(%2$s IN %1$s) = 1)", args[0], 
args[1]);
+        } else if (dialect instanceof H2Dialect) {
+            return String.format("(POSITION(%2$s, %1$s) = 1)", args[0], 
args[1]);
+        } else if(dialect instanceof MySQLDialect) {
+            return String.format("(POSITION(%2$s IN %1$s) = 1)", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("STARTS-WITH not supported in 
dialect "+dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.BOOL;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NUpperCase.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NUpperCase.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NUpperCase.java
new file mode 100644
index 0000000..2ecb231
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/string/NUpperCase.java
@@ -0,0 +1,99 @@
+/*
+ * 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.kiwi.sparql.function.string;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.OPTypes;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.openrdf.query.algebra.evaluation.function.string.UpperCase;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert ([email protected])
+ */
+public class NUpperCase extends UpperCase implements NativeFunction {
+
+    /**
+     * Return true if this function has available native support for the given 
dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect || dialect instanceof 
H2Dialect || dialect instanceof MySQLDialect;
+    }
+
+    /**
+     * Return a string representing how this function is translated into SQL 
in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        return String.format("UPPER(%s)", args[0]);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type 
casting inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public OPTypes getReturnType() {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Get the argument type of the function for the arg'th argument (starting 
to count at 0).
+     * This is needed for SQL type casting inside KiWi.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public OPTypes getArgumentType(int arg) {
+        return OPTypes.STRING;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/67c2b878/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
 
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
index fc74898..972c704 100644
--- 
a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
+++ 
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
@@ -302,7 +302,7 @@ public class PostgreSQLDialect extends KiWiDialect {
             }
         } else if(FN_MARMOTTA.MD5.equals(fnUri)) {
             if(args.length == 1) {
-                return String.format("encode(digest('%s', 'md5'), 'hex')", 
args[0]);
+                return String.format("encode(digest(%s, 'md5'), 'hex')", 
args[0]);
             } else {
                 throw new IllegalArgumentException("MD5() takes exactly 1 
argument");
             }

Reply via email to