You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/05/03 08:50:57 UTC

camel git commit: CAMEL-5252: Simple language. Lazy eval nested functions that avoid provisional conversion to String value when using simple in method call OGNL expression style. This allows to call methods with the nested functions as-is.

Repository: camel
Updated Branches:
  refs/heads/master 19ae13a4c -> eb51dfb5f


CAMEL-5252: Simple language. Lazy eval nested functions that avoid provisional conversion to String value when using simple in method call OGNL expression style. This allows to call methods with the nested functions as-is.


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

Branch: refs/heads/master
Commit: eb51dfb5f6519c5b11cbe08640a959a9155c24c7
Parents: 19ae13a
Author: Claus Ibsen <da...@apache.org>
Authored: Tue May 3 08:44:03 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue May 3 08:50:51 2016 +0200

----------------------------------------------------------------------
 .../camel/language/simple/SimpleLanguage.java   | 14 +++++++++----
 .../camel/language/simple/SimpleTokenizer.java  | 21 ++++++++++++++++++--
 2 files changed, 29 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/eb51dfb5/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java b/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
index d77ec36..1962a1c 100644
--- a/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
+++ b/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
@@ -101,10 +101,6 @@ public class SimpleLanguage extends LanguageSupport {
     public SimpleLanguage() {
     }
 
-    public static boolean hasSimpleFunction(String expression) {
-        return SimpleTokenizer.hasFunctionStartToken(expression);
-    }
-
     public Predicate createPredicate(String expression) {
         ObjectHelper.notNull(expression, "expression");
 
@@ -187,6 +183,16 @@ public class SimpleLanguage extends LanguageSupport {
     }
 
     /**
+     * Does the expression include a simple function.
+     *
+     * @param expression the expression
+     * @return <tt>true</tt> if one or more simple function is included in the expression
+     */
+    public static boolean hasSimpleFunction(String expression) {
+        return SimpleTokenizer.hasFunctionStartToken(expression);
+    }
+
+    /**
      * Change the start tokens used for functions.
      * <p/>
      * This can be used to alter the function tokens to avoid clashes with other

http://git-wip-us.apache.org/repos/asf/camel/blob/eb51dfb5/camel-core/src/main/java/org/apache/camel/language/simple/SimpleTokenizer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/language/simple/SimpleTokenizer.java b/camel-core/src/main/java/org/apache/camel/language/simple/SimpleTokenizer.java
index 85bb775..7c3aa1b 100644
--- a/camel-core/src/main/java/org/apache/camel/language/simple/SimpleTokenizer.java
+++ b/camel-core/src/main/java/org/apache/camel/language/simple/SimpleTokenizer.java
@@ -85,6 +85,12 @@ public final class SimpleTokenizer {
         // static methods
     }
 
+    /**
+     * Does the expression include a simple function.
+     *
+     * @param expression the expression
+     * @return <tt>true</tt> if one or more simple function is included in the expression
+     */
     public static boolean hasFunctionStartToken(String expression) {
         if (expression != null) {
             for (SimpleTokenType type : KNOWN_TOKENS) {
@@ -92,6 +98,9 @@ public final class SimpleTokenizer {
                     if (expression.contains(type.getValue())) {
                         return true;
                     }
+                } else {
+                    // function start are always first
+                    return false;
                 }
             }
         }
@@ -124,9 +133,17 @@ public final class SimpleTokenizer {
             }
         }
 
-        // add in start of list as its a more common token to be used
+        // add after the start tokens
+        int pos = 0;
+        for (SimpleTokenType type : KNOWN_TOKENS) {
+            if (type.getType() == TokenType.functionStart) {
+                pos++;
+            }
+        }
+
+        // add after function start of list as its a more common token to be used
         for (String token : endToken) {
-            KNOWN_TOKENS.add(0, new SimpleTokenType(TokenType.functionEnd, token));
+            KNOWN_TOKENS.add(pos, new SimpleTokenType(TokenType.functionEnd, token));
         }
     }