You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/06/15 14:36:13 UTC

[camel] branch main updated (bb6f15db2a3 -> edc9fe2756f)

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from bb6f15db2a3 Regen for commit 7e691aca78f684b7842289367bbea7cfd8a5ea24 (#10407)
     new 343321f3f77  (chores) camel-core-languages: cleanup duplicated code for appending class to the type
     new 34bad642324  (chores) camel-core-languages: cleanup duplicated code for parsing in headers
     new edc9fe2756f  (chores) camel-core-languages: cleanup duplicated code for appending class to the type

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../simple/ast/SimpleFunctionExpression.java       | 90 ++++++++--------------
 1 file changed, 34 insertions(+), 56 deletions(-)


[camel] 02/03: (chores) camel-core-languages: cleanup duplicated code for parsing in headers

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 34bad642324412471b87934ec1d406b48da6b2a0
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Thu Jun 15 09:23:28 2023 +0200

     (chores) camel-core-languages: cleanup duplicated code for parsing in headers
---
 .../simple/ast/SimpleFunctionExpression.java       | 37 ++++++++++------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
index e93a78125fc..d7413f0c9e6 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
@@ -385,16 +385,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
         }
 
         // in header function
-        remainder = ifStartsWithReturnRemainder("in.headers", function);
-        if (remainder == null) {
-            remainder = ifStartsWithReturnRemainder("in.header", function);
-        }
-        if (remainder == null) {
-            remainder = ifStartsWithReturnRemainder("headers", function);
-        }
-        if (remainder == null) {
-            remainder = ifStartsWithReturnRemainder("header", function);
-        }
+        remainder = parseInHeader(function);
         if (remainder != null) {
             // remove leading character (dot, colon or ?)
             if (remainder.startsWith(".") || remainder.startsWith(":") || remainder.startsWith("?")) {
@@ -1113,16 +1104,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
         }
 
         // in header function
-        remainder = ifStartsWithReturnRemainder("in.headers", function);
-        if (remainder == null) {
-            remainder = ifStartsWithReturnRemainder("in.header", function);
-        }
-        if (remainder == null) {
-            remainder = ifStartsWithReturnRemainder("headers", function);
-        }
-        if (remainder == null) {
-            remainder = ifStartsWithReturnRemainder("header", function);
-        }
+        remainder = parseInHeader(function);
         if (remainder != null) {
             // remove leading character (dot, colon or ?)
             if (remainder.startsWith(".") || remainder.startsWith(":") || remainder.startsWith("?")) {
@@ -1181,6 +1163,21 @@ public class SimpleFunctionExpression extends LiteralExpression {
         return null;
     }
 
+    private String parseInHeader(String function) {
+        String remainder;
+        remainder = ifStartsWithReturnRemainder("in.headers", function);
+        if (remainder == null) {
+            remainder = ifStartsWithReturnRemainder("in.header", function);
+        }
+        if (remainder == null) {
+            remainder = ifStartsWithReturnRemainder("headers", function);
+        }
+        if (remainder == null) {
+            remainder = ifStartsWithReturnRemainder("header", function);
+        }
+        return remainder;
+    }
+
     private String createCodeExchangeProperty(final String function) {
         // exchangePropertyAsIndex
         String remainder = ifStartsWithReturnRemainder("exchangePropertyAsIndex(", function);


[camel] 01/03: (chores) camel-core-languages: cleanup duplicated code for appending class to the type

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 343321f3f77f45f34449b396212ed28f74eec16c
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Thu Jun 15 09:15:52 2023 +0200

     (chores) camel-core-languages: cleanup duplicated code for appending class to the type
---
 .../simple/ast/SimpleFunctionExpression.java       | 43 ++++++++--------------
 1 file changed, 15 insertions(+), 28 deletions(-)

diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
index f14dee8105c..e93a78125fc 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
@@ -660,10 +660,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
         if (remainder != null) {
             String type = StringHelper.before(remainder, ")");
             remainder = StringHelper.after(remainder, ")");
-            type = StringHelper.removeQuotes(type);
-            if (!type.endsWith(".class")) {
-                type = type + ".class";
-            }
+            type = appendClass(type);
             type = type.replace('$', '.');
             type = type.trim();
             boolean invalid = OgnlHelper.isInvalidValidOgnlExpression(remainder);
@@ -915,10 +912,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
             if (type == null) {
                 throw new SimpleParserException("Valid syntax: ${bodyAs(type)} was: " + function, token.getIndex());
             }
-            type = StringHelper.removeQuotes(type);
-            if (!type.endsWith(".class")) {
-                type = type + ".class";
-            }
+            type = appendClass(type);
             type = type.replace('$', '.');
             type = type.trim();
             remainder = StringHelper.after(remainder, ")");
@@ -989,10 +983,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
             if (type == null) {
                 throw new SimpleParserException("Valid syntax: ${mandatoryBodyAs(type)} was: " + function, token.getIndex());
             }
-            type = StringHelper.removeQuotes(type);
-            if (!type.endsWith(".class")) {
-                type = type + ".class";
-            }
+            type = appendClass(type);
             type = type.replace('$', '.');
             type = type.trim();
             remainder = StringHelper.after(remainder, ")");
@@ -1075,10 +1066,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
             }
             key = StringHelper.removeQuotes(key);
             key = key.trim();
-            type = StringHelper.removeQuotes(type);
-            if (!type.endsWith(".class")) {
-                type = type + ".class";
-            }
+            type = appendClass(type);
             type = type.replace('$', '.');
             type = type.trim();
             index = StringHelper.removeQuotes(index);
@@ -1113,10 +1101,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
             }
             key = StringHelper.removeQuotes(key);
             key = key.trim();
-            type = StringHelper.removeQuotes(type);
-            if (!type.endsWith(".class")) {
-                type = type + ".class";
-            }
+            type = appendClass(type);
             type = type.replace('$', '.');
             type = type.trim();
             return "headerAs(message, \"" + key + "\", " + type + ")" + ognlCodeMethods(remainder, type);
@@ -1219,10 +1204,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
             }
             key = StringHelper.removeQuotes(key);
             key = key.trim();
-            type = StringHelper.removeQuotes(type);
-            if (!type.endsWith(".class")) {
-                type = type + ".class";
-            }
+            type = appendClass(type);
             type = type.replace('$', '.');
             type = type.trim();
             index = StringHelper.removeQuotes(index);
@@ -1260,10 +1242,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
             }
             key = StringHelper.removeQuotes(key);
             key = key.trim();
-            type = StringHelper.removeQuotes(type);
-            if (!type.endsWith(".class")) {
-                type = type + ".class";
-            }
+            type = appendClass(type);
             type = type.replace('$', '.');
             type = type.trim();
             return "exchangePropertyAs(exchange, \"" + key + "\", " + type + ")" + ognlCodeMethods(remainder, type);
@@ -1315,6 +1294,14 @@ public class SimpleFunctionExpression extends LiteralExpression {
         return null;
     }
 
+    private static String appendClass(String type) {
+        type = StringHelper.removeQuotes(type);
+        if (!type.endsWith(".class")) {
+            type = type + ".class";
+        }
+        return type;
+    }
+
     private String createCodeFileExpression(String remainder) {
         if (ObjectHelper.equal(remainder, "name")) {
             return "fileName(message)";


[camel] 03/03: (chores) camel-core-languages: cleanup duplicated code for appending class to the type

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit edc9fe2756f0b1485ea0cc33e405465e783dad7d
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Thu Jun 15 09:51:09 2023 +0200

     (chores) camel-core-languages: cleanup duplicated code for appending class to the type
---
 .../camel/language/simple/ast/SimpleFunctionExpression.java    | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
index d7413f0c9e6..0ce40d61838 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
@@ -876,11 +876,8 @@ public class SimpleFunctionExpression extends LiteralExpression {
                 throw new SimpleParserException(
                         "Valid syntax: ${bodyAsIndex(type, index).OGNL} was: " + function, token.getIndex());
             }
-            type = StringHelper.removeQuotes(type);
             type = type.trim();
-            if (!type.endsWith(".class")) {
-                type = type + ".class";
-            }
+            type = appendClass(type);
             type = type.replace('$', '.');
             index = StringHelper.removeQuotes(index);
             index = index.trim();
@@ -947,11 +944,8 @@ public class SimpleFunctionExpression extends LiteralExpression {
                 throw new SimpleParserException(
                         "Valid syntax: ${mandatoryBodyAsIndex(type, index).OGNL} was: " + function, token.getIndex());
             }
-            type = StringHelper.removeQuotes(type);
             type = type.trim();
-            if (!type.endsWith(".class")) {
-                type = type + ".class";
-            }
+            type = appendClass(type);
             type = type.replace('$', '.');
             index = StringHelper.removeQuotes(index);
             index = index.trim();