Repository: marmotta
Updated Branches:
  refs/heads/develop b6e3d5c3c -> 5cfbf7a25


more cleanups


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/5cfbf7a2
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/5cfbf7a2
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/5cfbf7a2

Branch: refs/heads/develop
Commit: 5cfbf7a25f9ad1211d0c4385e3d9341b8ea6bea4
Parents: b6e3d5c
Author: Sebastian Schaffert <[email protected]>
Authored: Fri Sep 19 19:03:56 2014 +0200
Committer: Sebastian Schaffert <[email protected]>
Committed: Fri Sep 19 19:03:56 2014 +0200

----------------------------------------------------------------------
 .../kiwi/sparql/builder/OPTypeFinder.java       | 38 +++-----------------
 1 file changed, 5 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/5cfbf7a2/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/OPTypeFinder.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/OPTypeFinder.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/OPTypeFinder.java
index a0051be..b10c322 100644
--- 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/OPTypeFinder.java
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/OPTypeFinder.java
@@ -19,17 +19,14 @@ package org.apache.marmotta.kiwi.sparql.builder;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.marmotta.commons.sesame.model.Namespaces;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunctionRegistry;
 import org.openrdf.model.Literal;
-import org.openrdf.model.URI;
-import org.openrdf.model.impl.URIImpl;
-import org.openrdf.model.vocabulary.FN;
 import org.openrdf.query.algebra.*;
 import org.openrdf.query.algebra.helpers.QueryModelVisitorBase;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /**
  * Determine the operand type of a value expression. Get the coerced value by 
calling coerce().
@@ -40,27 +37,6 @@ public class OPTypeFinder extends 
QueryModelVisitorBase<RuntimeException> {
 
     List<OPTypes> optypes = new ArrayList<>();
 
-    private static Map<URI,OPTypes> functionReturnTypes = new HashMap<>();
-    static {
-        functionReturnTypes.put(FN.CONCAT, OPTypes.STRING);
-        functionReturnTypes.put(FN.CONTAINS, OPTypes.BOOL);
-        functionReturnTypes.put(FN.LOWER_CASE, OPTypes.STRING);
-        functionReturnTypes.put(FN.UPPER_CASE, OPTypes.STRING);
-        functionReturnTypes.put(FN.REPLACE, OPTypes.STRING);
-        functionReturnTypes.put(FN.SUBSTRING_AFTER, OPTypes.STRING);
-        functionReturnTypes.put(FN.SUBSTRING_BEFORE, OPTypes.STRING);
-        functionReturnTypes.put(FN.STARTS_WITH, OPTypes.BOOL);
-        functionReturnTypes.put(FN.ENDS_WITH, OPTypes.BOOL);
-        functionReturnTypes.put(FN.STRING_LENGTH, OPTypes.INT);
-        functionReturnTypes.put(FN.SUBSTRING, OPTypes.STRING);
-
-        functionReturnTypes.put(FN.NUMERIC_ABS, OPTypes.DOUBLE);
-        functionReturnTypes.put(FN.NUMERIC_CEIL, OPTypes.INT);
-        functionReturnTypes.put(FN.NUMERIC_FLOOR, OPTypes.INT);
-        functionReturnTypes.put(FN.NUMERIC_ROUND, OPTypes.INT);
-
-    }
-
 
 
     public OPTypeFinder(ValueExpr expr) {
@@ -125,15 +101,11 @@ public class OPTypeFinder extends 
QueryModelVisitorBase<RuntimeException> {
 
     @Override
     public void meet(FunctionCall fc) throws RuntimeException {
-        URI fnUri = new URIImpl(fc.getURI());
-
-        String[] args = new String[fc.getArgs().size()];
+        NativeFunction nf = 
NativeFunctionRegistry.getInstance().get(fc.getURI());
 
-        OPTypes fOpType = functionReturnTypes.get(fnUri);
-        if(fOpType == null) {
-            fOpType = OPTypes.ANY;
+        if (nf != null) {
+            optypes.add(nf.getReturnType());
         }
-        optypes.add(fOpType);
     }
 
 

Reply via email to