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 2026/09/23 17:23:26 UTC
(camel) branch fix/CAMEL-24962 created (now 0eab29ad902f)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch fix/CAMEL-24962
in repository https://gitbox.apache.org/repos/asf/camel.git
at 0eab29ad902f CAMEL-24962: upgrade guide notes for the simple language fixes
This branch includes the following new commits:
new 2c518175f101 CAMEL-24969: simple - range(max) starts at 0 as documented; CAMEL-24968: fix substring docs and catalog
new da044e3bbaa0 CAMEL-24963: simple - an operator word in a property default or a bracket key is text, not a predicate
new a80d45acd87e CAMEL-24966: simple - fix numeric literals, elvis, ++/-- and null range/regex
new d15f234b6f54 CAMEL-24969: simple - fix collection function arguments, split, sort, uuid(), range and null numbers
new 1746815b241f CAMEL-24968: simple - fix string, math, date and file function edge cases
new 3bd9ca7e4aad CAMEL-24965: simple - fix init block comments, one-liners, CRLF, predicates and local functions
new c6211c63109a CAMEL-24964: simple - fix quotes, braces, chain and ternary edge cases in the parser
new 28e3825dc4c5 CAMEL-24967: simple - fix how function names are matched and arguments are split
new c83b9f71c8de CAMEL-24970: simple - fix catalog entries, docs and syntax hints
new 7713bf5e0dda CAMEL-24971: simple - internal tidy-ups
new 0eab29ad902f CAMEL-24962: upgrade guide notes for the simple language fixes
The 11 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.
(camel) 11/11: CAMEL-24962: upgrade guide notes for the simple language fixes
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch fix/CAMEL-24962
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0eab29ad902fd548a7d26036d7b79b07f3f53744
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 23 19:15:53 2026 +0200
CAMEL-24962: upgrade guide notes for the simple language fixes
Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
.../ROOT/pages/camel-4x-upgrade-guide-4_23.adoc | 23 ++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
index de0993249bb3..4c173cbb8896 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
@@ -41,6 +41,29 @@ The `range(max)` function now starts at 0, as documented and as `range` does in
`[0, 1, 2, 3, 4]` where it used to return `[1, 2, 3, 4]`. Routes that relied on the range starting at 1 must use
`${range(1,5)}` instead. The two-argument form `range(min,max)` is unchanged.
+A review of the simple language fixed a number of edge cases. These change what an existing expression returns:
+
+* `split` uses the separator as plain text, not as a regular expression: `${split(${body},'.')}` splits on dots
+ (it used to return an empty array), and `${split(${body},'|')}` splits on the bar. A route that relied on a regular
+ expression separator such as `'\s+'` must use `${body.split('\s+')}` instead.
+* The elvis operator `?:` treats any numeric zero as falsy (such as `0L`, `0.0` or `BigDecimal.ZERO`), not only `0` as
+ an `Integer`.
+* `++` and `--` keep decimals: `1.5` becomes `2.5` (it used to be `2.0`).
+* `safeQuote` escapes double quotes, backslashes and control characters in the value, so the result is a valid JSON
+ string. A `BigDecimal` is a number, so it is not quoted.
+* `kindOfType` returns `object` for a `Map` (it used to return `array`).
+* A name glued to a function prefix is an unknown function instead of being read as that function, such as
+ `${headerfoo}` (which returned the header `foo`), `${uuidv7}` or `${exceptionInfo}`. Use `${header.foo}`.
+* A hidden file name has no extension: for `.bashrc` then `${file:name.ext}` is `null` (it used to be `bashrc`), and
+ for `.route.yaml` then `${file:name.noext}` is `.route`. This comes from `FileUtil.onlyExt` and `FileUtil.stripExt`.
+* The chain operator `~>` needs a space on both sides, as the other operators do, so `A~>B` is text.
+* Inside `${ }` the ternary `?` and `:` need whitespace around them, so `${bean:svc?method=at(10:30)}` is not a
+ ternary.
+
+The simple catalog (`simple.json`) now spells these functions as they are written: `hostname` (was `hostName`),
+`exception.stacktrace` (was `exception.stackTrace`), `throwException(msg,type)` (was `throwException(type,msg)`, the
+order the function has always used), `not(exp)`, and `setAttachment(key,exp)`.
+
=== Circuit Breaker EIP
The exchange property `CamelCircuitBreakerResponseRejected` is now also set inside the `onFallback`,
(camel) 04/11: CAMEL-24969: simple - fix collection function arguments, split, sort, uuid(), range and null numbers
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch fix/CAMEL-24962
in repository https://gitbox.apache.org/repos/asf/camel.git
commit d15f234b6f542a553072e40526297a85a037a340
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 23 18:47:25 2026 +0200
CAMEL-24969: simple - fix collection function arguments, split, sort, uuid(), range and null numbers
- a space after a comma no longer leaks into the argument: ${sort(${body}, true)}, mapAdd, listAdd, ...
- split uses the separator as plain text, not a regular expression ('.' and '|')
- ${sort(${header.list})} sorts the given list instead of the body
- ${uuid()} is the default generator, and the kind is case insensitive
- range allows a negative start (as Python); range, collate and random report null or invalid numbers
- a body of a single comma no longer fails in the collection functions (camel-util StringHelper)
Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
.../simple/CollectionExpressionBuilder.java | 16 ++++++--
.../language/simple/MiscExpressionBuilder.java | 25 +++++++++----
.../functions/CollectionFunctionFactory.java | 43 ++++++++++++++++------
.../apache/camel/language/simple/SimpleTest.java | 29 +++++++++++++++
.../functions/CollectionFunctionFactoryTest.java | 43 ++++++++++++++++++++++
.../java/org/apache/camel/util/StringHelper.java | 8 ++++
.../org/apache/camel/util/StringHelperTest.java | 6 +++
7 files changed, 147 insertions(+), 23 deletions(-)
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/CollectionExpressionBuilder.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/CollectionExpressionBuilder.java
index 54b38e923e31..5ef3370a872a 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/CollectionExpressionBuilder.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/CollectionExpressionBuilder.java
@@ -25,6 +25,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.regex.Pattern;
import org.apache.camel.CamelContext;
import org.apache.camel.CamelExecutionException;
@@ -272,6 +273,9 @@ public final class CollectionExpressionBuilder {
* Split the String values from the expression using the given separator
*/
public static Expression splitStringExpression(final String expression, final String separator) {
+ // the separator is plain text (not a regular expression), such as '.' or '|'
+ final Pattern pattern = Pattern.compile(Pattern.quote(
+ separator.replace("\\n", "\n").replace("\\r", "\r").replace("\\t", "\t")));
return new ExpressionAdapter() {
private Expression exp;
@@ -287,7 +291,7 @@ public final class CollectionExpressionBuilder {
if (text == null) {
return null;
}
- return text.split(separator);
+ return pattern.split(text);
}
@Override
@@ -667,9 +671,13 @@ public final class CollectionExpressionBuilder {
@Override
public Object evaluate(Exchange exchange) {
- int num1 = exp1.evaluate(exchange, Integer.class);
- int num2 = exp2.evaluate(exchange, Integer.class);
- if (num1 >= 0 && num1 <= num2 && num1 != num2) {
+ Integer num1 = exp1.evaluate(exchange, Integer.class);
+ Integer num2 = exp2.evaluate(exchange, Integer.class);
+ if (num1 == null || num2 == null) {
+ throw new IllegalArgumentException("range expression evaluated to null: " + min + "," + max);
+ }
+ // as Python, the range may start below zero: range(-2,2) is [-2, -1, 0, 1]
+ if (num1 < num2) {
List<Integer> answer = new ArrayList<>();
for (int i = num1; i < num2; i++) {
answer.add(i);
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MiscExpressionBuilder.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MiscExpressionBuilder.java
index 439a8cc7cb6f..f1a7c23e0a1d 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MiscExpressionBuilder.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MiscExpressionBuilder.java
@@ -149,6 +149,9 @@ public final class MiscExpressionBuilder {
@Override
public Object evaluate(Exchange exchange) {
Integer n = num.evaluate(exchange, Integer.class);
+ if (n == null) {
+ throw new IllegalArgumentException("collate number expression evaluated to null: " + group);
+ }
Expression grouped = ExpressionBuilder.groupIteratorExpression(exp, null, Integer.toString(n), false);
grouped.init(exchange.getContext());
return grouped.evaluate(exchange, Object.class);
@@ -725,8 +728,12 @@ public final class MiscExpressionBuilder {
@Override
public Object evaluate(Exchange exchange) {
- int num1 = exp1.evaluate(exchange, Integer.class);
- int num2 = exp2.evaluate(exchange, Integer.class);
+ Integer num1 = exp1.evaluate(exchange, Integer.class);
+ Integer num2 = exp2.evaluate(exchange, Integer.class);
+ if (num1 == null || num2 == null || num2 <= num1) {
+ throw new IllegalArgumentException(
+ "random(min,max) requires max to be greater than min, was: " + num1 + "," + num2);
+ }
Random random = new Random(); // NOSONAR
return random.nextInt(num2 - num1) + num1;
}
@@ -813,19 +820,21 @@ public final class MiscExpressionBuilder {
@Override
public void init(CamelContext context) {
- if ("classic".equalsIgnoreCase(generator)) {
+ // ${uuid()} is the same as ${uuid}
+ String kind = generator != null ? StringHelper.removeLeadingAndEndingQuotes(generator.trim()) : null;
+ if ("classic".equalsIgnoreCase(kind)) {
uuid = new ClassicUuidGenerator();
- } else if ("short".equals(generator)) {
+ } else if ("short".equalsIgnoreCase(kind)) {
uuid = new ShortUuidGenerator();
- } else if ("simple".equals(generator)) {
+ } else if ("simple".equalsIgnoreCase(kind)) {
uuid = new SimpleUuidGenerator();
- } else if ("random".equals(generator)) {
+ } else if ("random".equalsIgnoreCase(kind)) {
uuid = new RandomUuidGenerator();
- } else if (generator == null || "default".equals(generator)) {
+ } else if (kind == null || kind.isEmpty() || "default".equalsIgnoreCase(kind)) {
uuid = new DefaultUuidGenerator();
} else {
// lookup custom generator
- uuid = CamelContextHelper.mandatoryLookup(context, generator, UuidGenerator.class);
+ uuid = CamelContextHelper.mandatoryLookup(context, kind, UuidGenerator.class);
}
}
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/CollectionFunctionFactory.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/CollectionFunctionFactory.java
index aee3d6a1a7a9..4a7a98a78497 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/CollectionFunctionFactory.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/CollectionFunctionFactory.java
@@ -49,7 +49,7 @@ public final class CollectionFunctionFactory implements SimpleLanguageFunctionFa
throw new SimpleParserException(
"Valid syntax: ${setHeader(name,exp)} or ${setHeader(name,type,exp)} was: " + function, index);
}
- String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', false);
+ String[] tokens = splitArguments(values);
if (tokens.length < 2 || tokens.length > 3) {
throw new SimpleParserException(
"Valid syntax: ${setHeader(name,exp)} or ${setHeader(name,type,exp)} was: " + function, index);
@@ -74,7 +74,7 @@ public final class CollectionFunctionFactory implements SimpleLanguageFunctionFa
throw new SimpleParserException(
"Valid syntax: ${setVariable(name,exp)} or ${setVariable(name,type,exp)} was: " + function, index);
}
- String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', false);
+ String[] tokens = splitArguments(values);
if (tokens.length < 2 || tokens.length > 3) {
throw new SimpleParserException(
"Valid syntax: ${setVariable(name,exp)} or ${setVariable(name,type,exp)} was: " + function, index);
@@ -153,7 +153,7 @@ public final class CollectionFunctionFactory implements SimpleLanguageFunctionFa
String exp = "${body}";
String separator = ",";
if (ObjectHelper.isNotEmpty(values)) {
- String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', false);
+ String[] tokens = splitArguments(values);
if (tokens.length > 2) {
throw new SimpleParserException(
"Valid syntax: ${split(separator)} or ${split(exp,separator)} was: " + function, index);
@@ -176,7 +176,7 @@ public final class CollectionFunctionFactory implements SimpleLanguageFunctionFa
String exp = "${body}";
boolean reverse = false;
if (ObjectHelper.isNotEmpty(values)) {
- String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', false);
+ String[] tokens = splitArguments(values);
if (tokens.length > 2) {
throw new SimpleParserException(
"Valid syntax: ${sort(reverse)} or ${sort(exp,reverse)} was: " + function, index);
@@ -184,8 +184,11 @@ public final class CollectionFunctionFactory implements SimpleLanguageFunctionFa
if (tokens.length == 2) {
exp = tokens[0];
reverse = Boolean.parseBoolean(tokens[1]);
- } else {
+ } else if ("true".equalsIgnoreCase(tokens[0]) || "false".equalsIgnoreCase(tokens[0])) {
reverse = Boolean.parseBoolean(tokens[0]);
+ } else {
+ // ${sort(${header.list})}: the only argument is what to sort
+ exp = tokens[0];
}
}
return CollectionExpressionBuilder.sortExpression(exp, reverse);
@@ -198,7 +201,7 @@ public final class CollectionFunctionFactory implements SimpleLanguageFunctionFa
throw new SimpleParserException(
"Valid syntax: ${forEach(exp,exp)} was: " + function, index);
}
- String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', false);
+ String[] tokens = splitArguments(values);
if (tokens.length < 2) {
throw new SimpleParserException(
"Valid syntax: ${forEach(exp,exp)} was: " + function, index);
@@ -215,7 +218,7 @@ public final class CollectionFunctionFactory implements SimpleLanguageFunctionFa
throw new SimpleParserException(
"Valid syntax: ${filter(exp,exp)} was: " + function, index);
}
- String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', false);
+ String[] tokens = splitArguments(values);
if (tokens.length < 2) {
throw new SimpleParserException(
"Valid syntax: ${filter(exp,exp)} was: " + function, index);
@@ -232,7 +235,7 @@ public final class CollectionFunctionFactory implements SimpleLanguageFunctionFa
throw new SimpleParserException(
"Valid syntax: ${listAdd(exp)} or ${listAdd(exp,exp)} was: " + function, index);
}
- String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', false);
+ String[] tokens = splitArguments(values);
int skip = 0;
String exp1 = "${body}";
if (tokens.length > 1) {
@@ -250,7 +253,7 @@ public final class CollectionFunctionFactory implements SimpleLanguageFunctionFa
throw new SimpleParserException(
"Valid syntax: ${listRemove(exp)} or ${listRemove(exp,exp)} was: " + function, index);
}
- String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', false);
+ String[] tokens = splitArguments(values);
int skip = 0;
String exp1 = "${body}";
if (tokens.length > 1) {
@@ -268,7 +271,7 @@ public final class CollectionFunctionFactory implements SimpleLanguageFunctionFa
throw new SimpleParserException(
"Valid syntax: ${mapAdd(key,exp)} or ${mapAdd(exp,key,exp)} was: " + function, index);
}
- String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', false);
+ String[] tokens = splitArguments(values);
int skip;
String exp1 = "${body}";
String key;
@@ -294,7 +297,7 @@ public final class CollectionFunctionFactory implements SimpleLanguageFunctionFa
throw new SimpleParserException(
"Valid syntax: ${mapRemove(key)} or ${mapRemove(exp,key)} was: " + function, index);
}
- String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', false);
+ String[] tokens = splitArguments(values);
if (tokens.length > 2) {
throw new SimpleParserException(
"Valid syntax: ${mapRemove(key)} or ${mapRemove(exp,key)} was: " + function, index);
@@ -336,4 +339,22 @@ public final class CollectionFunctionFactory implements SimpleLanguageFunctionFa
return null;
}
+
+ /**
+ * Splits the function arguments by comma. Unquoted arguments are trimmed, so ${sort(${body}, true)} works, while a
+ * quoted argument such as ' ' is kept as written (without its quotes).
+ */
+ private static String[] splitArguments(String values) {
+ String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', false, true);
+ for (int i = 0; i < tokens.length; i++) {
+ String token = tokens[i];
+ String trimmed = token.trim();
+ if (!trimmed.isEmpty()) {
+ // a whitespace only argument such as a new line is kept as-is
+ token = trimmed;
+ }
+ tokens[i] = StringHelper.removeLeadingAndEndingQuotes(token);
+ }
+ return tokens;
+ }
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index 165cc21096e4..e693c5f6719b 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -2211,11 +2211,40 @@ public class SimpleTest extends LanguageTestSupport {
s = expression.evaluate(exchange, String.class);
assertNotNull(s);
+ // empty parentheses and any case of the kind
+ expression = context.resolveLanguage("simple").createExpression("${uuid()}");
+ s = expression.evaluate(exchange, String.class);
+ assertNotNull(s);
+
+ expression = context.resolveLanguage("simple").createExpression("${uuid(Short)}");
+ s = expression.evaluate(exchange, String.class);
+ assertNotNull(s);
+
// custom generator
context.getRegistry().bind("mygen", (UuidGenerator) () -> "1234");
assertExpression("${uuid(mygen)}", "1234");
}
+ @Test
+ public void testCollectionFunctionsOnASingleComma() {
+ exchange.getMessage().setBody(",");
+ assertExpression("${isEmpty()}", true);
+ }
+
+ @Test
+ public void testNullNumberArguments() {
+ Exception e = assertThrows(Exception.class, () -> evaluate("${collate(${header.none})}"));
+ assertTrue(e.getMessage().contains("collate number expression evaluated to null"), e.getMessage());
+ e = assertThrows(Exception.class, () -> evaluate("${range(1,${header.none})}"));
+ assertTrue(e.getMessage().contains("range expression evaluated to null"), e.getMessage());
+ e = assertThrows(Exception.class, () -> evaluate("${random(5,5)}"));
+ assertTrue(e.getMessage().contains("requires max to be greater than min"), e.getMessage());
+ }
+
+ private Object evaluate(String text) {
+ return context.resolveLanguage("simple").createExpression(text).evaluate(exchange, Object.class);
+ }
+
@Test
public void testHash() throws Exception {
Expression expression = context.resolveLanguage("simple").createExpression("${hash(hello)}");
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/functions/CollectionFunctionFactoryTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/functions/CollectionFunctionFactoryTest.java
index a1fbdb462d27..7cd75dc80ee7 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/simple/functions/CollectionFunctionFactoryTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/functions/CollectionFunctionFactoryTest.java
@@ -220,4 +220,47 @@ public class CollectionFunctionFactoryTest extends AbstractSimpleFunctionFactory
assertEquals("v2", result.get("k2"));
}
+ // --- CAMEL-24969 ---
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public void testRangeNegativeStart() {
+ assertEquals(List.of(-2, -1, 0, 1), evaluate("range(-2,2)", List.class));
+ }
+
+ @Test
+ public void testSplitSeparatorIsNotARegex() {
+ exchange.getIn().setBody("a.b.c");
+ assertEquals(List.of("a", "b", "c"), List.of(evaluate("split(${body},'.')", String[].class)));
+ exchange.getIn().setBody("a|b|c");
+ assertEquals(List.of("a", "b", "c"), List.of(evaluate("split(${body},'|')", String[].class)));
+ exchange.getIn().setBody("a b c");
+ assertEquals(List.of("a", "b", "c"), List.of(evaluate("split(${body}, ' ')", String[].class)));
+ exchange.getIn().setBody("a;b");
+ assertEquals(List.of("a", "b"), List.of(evaluate("split(${body}, ;)", String[].class)));
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public void testSortOnlyArgumentIsWhatToSort() {
+ exchange.getIn().setBody(new ArrayList<>(List.of("b", "a")));
+ exchange.getIn().setHeader("list", new ArrayList<>(List.of("z", "y")));
+ assertEquals(List.of("y", "z"), evaluate("sort(${header.list})", List.class));
+ assertEquals(List.of("b", "a"), evaluate("sort(true)", List.class));
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public void testSpaceAfterComma() {
+ exchange.getIn().setBody(new ArrayList<>(List.of("a", "b")));
+ assertEquals(List.of("b", "a"), evaluate("sort(${body}, true)", List.class));
+
+ exchange.getIn().setBody(new ArrayList<>(List.of("X")));
+ assertEquals(List.of("X", "Y"), evaluate("listAdd(${body}, 'Y')", List.class));
+
+ exchange.getIn().setBody(new HashMap<>());
+ Map<String, Object> map = evaluate("mapAdd(${body}, 'k', 'v')", Map.class);
+ assertEquals("v", map.get("k"));
+ }
+
}
diff --git a/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java b/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java
index 082b71c98435..7e37a000d964 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java
@@ -414,6 +414,10 @@ public final class StringHelper {
}
public static Iterator<String> splitOnCharacterAsIterator(String value, char needle, int count) {
+ if (value.length() == 1 && value.charAt(0) == needle) {
+ // only the needle, such as a single comma, so there are no values
+ return Collections.emptyIterator();
+ }
// skip leading and trailing needles
int end = value.length() - 1;
boolean skipStart = value.charAt(0) == needle;
@@ -462,6 +466,10 @@ public final class StringHelper {
}
public static List<String> splitOnCharacterAsList(String value, char needle, int count) {
+ if (value.length() == 1 && value.charAt(0) == needle) {
+ // only the needle, such as a single comma, so there are no values
+ return new ArrayList<>();
+ }
// skip leading and trailing needles
int end = value.length() - 1;
boolean skipStart = value.charAt(0) == needle;
diff --git a/core/camel-util/src/test/java/org/apache/camel/util/StringHelperTest.java b/core/camel-util/src/test/java/org/apache/camel/util/StringHelperTest.java
index cbde328e73c9..c6bf59aaa6a5 100644
--- a/core/camel-util/src/test/java/org/apache/camel/util/StringHelperTest.java
+++ b/core/camel-util/src/test/java/org/apache/camel/util/StringHelperTest.java
@@ -246,6 +246,9 @@ public class StringHelperTest {
assertEquals("foo", list.get(0));
assertEquals("bar", list.get(1));
+ list = splitOnCharacterAsList(",", ',', 2);
+ assertEquals(0, list.size());
+
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 100; i++) {
sb.append(i);
@@ -267,6 +270,9 @@ public class StringHelperTest {
assertEquals("foo", it.next());
assertFalse(it.hasNext());
+ it = splitOnCharacterAsIterator(",", ',', 2);
+ assertFalse(it.hasNext());
+
it = splitOnCharacterAsIterator("foo,bar", ',', 2);
assertEquals("foo", it.next());
assertEquals("bar", it.next());
(camel) 10/11: CAMEL-24971: simple - internal tidy-ups
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch fix/CAMEL-24962
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7713bf5e0ddab623aa0bbaa87ce08f379c7835ae
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 23 19:15:32 2026 +0200
CAMEL-24971: simple - internal tidy-ups
- remove the static SimpleLanguage singleton that was only written, never read
- remove the always-true strict flag in SimpleFunctionExpression
- import ObjectHelper instead of the fully qualified name in the math and collection builders
- the logical operators && and || build their predicate once, not for every message
- concat names its arguments first/second, and concat and pad show all arguments in toString
- move the orphaned Javadoc to normalizeWhitespaceExpression
Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
.../simple/CollectionExpressionBuilder.java | 14 +++---
.../language/simple/MathExpressionBuilder.java | 10 ++---
.../camel/language/simple/SimpleLanguage.java | 7 +--
.../language/simple/StringExpressionBuilder.java | 22 ++++++----
.../language/simple/ast/LogicalExpression.java | 30 +++----------
.../simple/ast/SimpleFunctionExpression.java | 51 +++++++++-------------
6 files changed, 54 insertions(+), 80 deletions(-)
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/CollectionExpressionBuilder.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/CollectionExpressionBuilder.java
index 5ef3370a872a..d8c5b9ac15c6 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/CollectionExpressionBuilder.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/CollectionExpressionBuilder.java
@@ -35,8 +35,8 @@ import org.apache.camel.Predicate;
import org.apache.camel.spi.ClassResolver;
import org.apache.camel.support.ExchangeHelper;
import org.apache.camel.support.ExpressionAdapter;
+import org.apache.camel.support.ObjectHelper;
import org.apache.camel.support.builder.ExpressionBuilder;
-import org.apache.camel.util.ObjectHelper;
/**
* Expression builder for collection and list functions used by the simple language.
@@ -69,7 +69,7 @@ public final class CollectionExpressionBuilder {
for (Expression exp : exps) {
Object o = exp.evaluate(exchange, Object.class);
// this may be an object that we can iterate
- Iterable<?> it = org.apache.camel.support.ObjectHelper.createIterable(o);
+ Iterable<?> it = ObjectHelper.createIterable(o);
for (Object i : it) {
answer.add(i);
}
@@ -107,7 +107,7 @@ public final class CollectionExpressionBuilder {
for (Expression exp : exps) {
Object o = exp.evaluate(exchange, Object.class);
// this may be an object that we can iterate
- Iterable<?> it = org.apache.camel.support.ObjectHelper.createIterable(o);
+ Iterable<?> it = ObjectHelper.createIterable(o);
for (Object i : it) {
answer.add(i);
}
@@ -146,7 +146,7 @@ public final class CollectionExpressionBuilder {
for (Expression exp : exps) {
Object o = exp.evaluate(exchange, Object.class);
// this may be an object that we can iterate
- Iterable<?> it = org.apache.camel.support.ObjectHelper.createIterable(o);
+ Iterable<?> it = ObjectHelper.createIterable(o);
for (Object i : it) {
answer.add(i);
}
@@ -319,7 +319,7 @@ public final class CollectionExpressionBuilder {
List answer = new ArrayList<>();
Object o = exp.evaluate(exchange, Object.class);
// this may be an object that we can iterate
- Iterable<?> it = org.apache.camel.support.ObjectHelper.createIterable(o);
+ Iterable<?> it = ObjectHelper.createIterable(o);
for (Object i : it) {
answer.add(i);
}
@@ -359,7 +359,7 @@ public final class CollectionExpressionBuilder {
public Object evaluate(Exchange exchange) {
List<Object> answer = new ArrayList<>();
Object o = exp1.evaluate(exchange, Object.class);
- Iterable<?> it = org.apache.camel.support.ObjectHelper.createIterable(o);
+ Iterable<?> it = ObjectHelper.createIterable(o);
for (Object i : it) {
// use a dummy exchange as the input is to be the message body
Exchange dummy = ExchangeHelper.createCopy(exchange, true);
@@ -558,7 +558,7 @@ public final class CollectionExpressionBuilder {
public Object evaluate(Exchange exchange) {
List<Object> answer = new ArrayList<>();
Object o = exp1.evaluate(exchange, Object.class);
- Iterable<?> it = org.apache.camel.support.ObjectHelper.createIterable(o);
+ Iterable<?> it = ObjectHelper.createIterable(o);
for (Object i : it) {
// use a dummy exchange as the input is to be the message body
Exchange dummy = ExchangeHelper.createCopy(exchange, true);
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MathExpressionBuilder.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MathExpressionBuilder.java
index bcc830538791..dba909cd269c 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MathExpressionBuilder.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MathExpressionBuilder.java
@@ -22,7 +22,7 @@ import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.support.ExpressionAdapter;
-import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.support.ObjectHelper;
/**
* Expression builder for numeric and math functions used by the simple language.
@@ -180,7 +180,7 @@ public final class MathExpressionBuilder {
for (Expression exp : exps) {
Object o = exp.evaluate(exchange, Object.class);
// this may be an object that we can iterate
- Iterable<?> it = org.apache.camel.support.ObjectHelper.createIterable(o);
+ Iterable<?> it = ObjectHelper.createIterable(o);
for (Object i : it) {
Long val = exchange.getContext().getTypeConverter().tryConvertTo(Long.class, exchange, i);
if (val != null) {
@@ -224,7 +224,7 @@ public final class MathExpressionBuilder {
for (Expression exp : exps) {
Object o = exp.evaluate(exchange, Object.class);
// this may be an object that we can iterate
- Iterable<?> it = org.apache.camel.support.ObjectHelper.createIterable(o);
+ Iterable<?> it = ObjectHelper.createIterable(o);
for (Object i : it) {
Long val = exchange.getContext().getTypeConverter().tryConvertTo(Long.class, exchange, i);
if (val != null) {
@@ -268,7 +268,7 @@ public final class MathExpressionBuilder {
for (Expression exp : exps) {
Object o = exp.evaluate(exchange, Object.class);
// this may be an object that we can iterate
- Iterable<?> it = org.apache.camel.support.ObjectHelper.createIterable(o);
+ Iterable<?> it = ObjectHelper.createIterable(o);
for (Object i : it) {
Long val = exchange.getContext().getTypeConverter().tryConvertTo(Long.class, exchange, i);
if (val != null) {
@@ -313,7 +313,7 @@ public final class MathExpressionBuilder {
for (Expression exp : exps) {
Object o = exp.evaluate(exchange, Object.class);
// this may be an object that we can iterate
- Iterable<?> it = org.apache.camel.support.ObjectHelper.createIterable(o);
+ Iterable<?> it = ObjectHelper.createIterable(o);
for (Object i : it) {
Long val = exchange.getContext().getTypeConverter().tryConvertTo(Long.class, exchange, i);
if (val != null) {
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
index c199f275b586..ddfd3f7c4b0d 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
@@ -44,9 +44,6 @@ public class SimpleLanguage extends LanguageSupport implements StaticService {
private static final Logger LOG = LoggerFactory.getLogger(SimpleLanguage.class);
- // singleton for expressions without a result type
- private static final SimpleLanguage SIMPLE = new SimpleLanguage();
-
// a special prefix to avoid cache clash
private static final String CACHE_KEY_PREFIX = "@SIMPLE@";
@@ -87,9 +84,7 @@ public class SimpleLanguage extends LanguageSupport implements StaticService {
@Override
public void start() {
- if (getCamelContext() != null) {
- SIMPLE.setCamelContext(getCamelContext());
- }
+ // noop
}
@Override
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/StringExpressionBuilder.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/StringExpressionBuilder.java
index e6bbf4d0bed6..12ea1031c213 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/StringExpressionBuilder.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/StringExpressionBuilder.java
@@ -302,7 +302,10 @@ public final class StringExpressionBuilder {
@Override
public String toString() {
- return "pad(" + exp + "," + length + ")";
+ if (separator != null) {
+ return "pad(" + expression + "," + length + "," + separator + ")";
+ }
+ return "pad(" + expression + "," + length + ")";
}
};
}
@@ -310,16 +313,16 @@ public final class StringExpressionBuilder {
/**
* String concats the two expressions.
*/
- public static Expression concatExpression(final String right, final String left, String separator) {
+ public static Expression concatExpression(final String first, final String second, String separator) {
return new ExpressionAdapter() {
private Expression exp1;
private Expression exp2;
@Override
public void init(CamelContext context) {
- exp1 = context.resolveLanguage("simple").createExpression(right);
+ exp1 = context.resolveLanguage("simple").createExpression(first);
exp1.init(context);
- exp2 = context.resolveLanguage("simple").createExpression(left);
+ exp2 = context.resolveLanguage("simple").createExpression(second);
exp2.init(context);
}
@@ -336,7 +339,10 @@ public final class StringExpressionBuilder {
@Override
public String toString() {
- return "concat(" + right + "," + left + ")";
+ if (separator != null) {
+ return "concat(" + first + "," + second + "," + separator + ")";
+ }
+ return "concat(" + first + "," + second + ")";
}
};
}
@@ -539,9 +545,6 @@ public final class StringExpressionBuilder {
};
}
- /**
- * Normalizes the whitespaces in the given expressions (uses message body if expression is null)
- */
/**
* Returns an expression that escapes special characters in the given expression (or message body if <tt>null</tt>)
* according to the escape kind.
@@ -584,6 +587,9 @@ public final class StringExpressionBuilder {
};
}
+ /**
+ * Normalizes the whitespaces in the given expressions (uses message body if expression is null)
+ */
public static Expression normalizeWhitespaceExpression(final String expression) {
return new ExpressionAdapter() {
private Expression exp;
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/LogicalExpression.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/LogicalExpression.java
index c59dcf233f60..f4e0c37ca1be 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/LogicalExpression.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/LogicalExpression.java
@@ -93,40 +93,22 @@ public class LogicalExpression extends BaseSimpleNode {
final Expression leftExp = left.createExpression(camelContext, expression);
final Expression rightExp = right.createExpression(camelContext, expression);
+ // build the predicate once, not for every message
+ final Predicate leftPredicate = ExpressionToPredicateAdapter.toPredicate(leftExp);
+ final Predicate rightPredicate = ExpressionToPredicateAdapter.toPredicate(rightExp);
if (operator == LogicalOperatorType.AND) {
- return createAndExpression(leftExp, rightExp);
+ return createExpression(PredicateBuilder.and(leftPredicate, rightPredicate));
} else if (operator == LogicalOperatorType.OR) {
- return createOrExpression(leftExp, rightExp);
+ return createExpression(PredicateBuilder.or(leftPredicate, rightPredicate));
}
throw new SimpleParserException("Unknown logical operator " + operator, token.getIndex());
}
- private Expression createAndExpression(final Expression leftExp, final Expression rightExp) {
+ private Expression createExpression(final Predicate predicate) {
return new Expression() {
@Override
public <T> T evaluate(Exchange exchange, Class<T> type) {
- Predicate predicate = ExpressionToPredicateAdapter.toPredicate(leftExp);
- predicate = PredicateBuilder.and(predicate, ExpressionToPredicateAdapter.toPredicate(rightExp));
-
- boolean answer = predicate.matches(exchange);
- return exchange.getContext().getTypeConverter().convertTo(type, answer);
- }
-
- @Override
- public String toString() {
- return left + " " + token.getText() + " " + right;
- }
- };
- }
-
- private Expression createOrExpression(final Expression leftExp, final Expression rightExp) {
- return new Expression() {
- @Override
- public <T> T evaluate(Exchange exchange, Class<T> type) {
- Predicate predicate = ExpressionToPredicateAdapter.toPredicate(leftExp);
- predicate = PredicateBuilder.or(predicate, ExpressionToPredicateAdapter.toPredicate(rightExp));
-
boolean answer = predicate.matches(exchange);
return exchange.getContext().getTypeConverter().convertTo(type, answer);
}
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 dc5204024177..00a839c12a32 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
@@ -61,7 +61,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
Expression answer = cacheExpression != null ? cacheExpression.get(function) : null;
if (answer == null) {
- answer = createSimpleExpression(camelContext, function, true);
+ answer = createSimpleExpression(camelContext, function);
if (answer != null) {
answer.init(camelContext);
}
@@ -74,7 +74,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
return answer;
}
- private Expression createSimpleExpression(CamelContext camelContext, String function, boolean strict) {
+ private Expression createSimpleExpression(CamelContext camelContext, String function) {
Class<?> type = null;
// is it a known result type (make it easy in simple to return the value as you need)
@@ -94,7 +94,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
type = String.class;
function = function.substring(7);
}
- Expression exp = doCreateSimpleExpression(camelContext, function, strict);
+ Expression exp = doCreateSimpleExpression(camelContext, function);
if (type != null) {
exp = ExpressionBuilder.convertToExpression(exp, type);
}
@@ -136,14 +136,12 @@ public class SimpleFunctionExpression extends LiteralExpression {
};
}
- private Expression doCreateSimpleExpression(CamelContext camelContext, String function, boolean strict) {
- if (strict) {
- // ${body != null && body.size() > 0}: the braces hold a predicate, which is what they hold in EL,
- // Groovy and a JavaScript template, so read it as one (CAMEL-24921)
- Expression predicate = createPredicateExpression(camelContext, function);
- if (predicate != null) {
- return predicate;
- }
+ private Expression doCreateSimpleExpression(CamelContext camelContext, String function) {
+ // ${body != null && body.size() > 0}: the braces hold a predicate, which is what they hold in EL,
+ // Groovy and a JavaScript template, so read it as one (CAMEL-24921)
+ Expression predicate = createPredicateExpression(camelContext, function);
+ if (predicate != null) {
+ return predicate;
}
// return the function directly if we can create function without analyzing the prefix
Expression answer = DIRECT_FACTORY.createFunction(camelContext, function, token.getIndex());
@@ -159,7 +157,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
// do not create file expressions but keep the function as-is as a constant value
fileExpression = ExpressionBuilder.constantExpression("${" + function + "}");
} else {
- fileExpression = createSimpleFileExpression(remainder, strict);
+ fileExpression = createSimpleFileExpression(remainder);
}
if (fileExpression != null) {
return fileExpression;
@@ -193,17 +191,13 @@ public class SimpleFunctionExpression extends LiteralExpression {
}
}
- if (strict) {
- String hint = SimpleSyntaxHints.unknownFunction(function);
- throw new SimpleParserException(
- "Unknown function: " + function + (hint != null ? " (" + hint + ")" : ""),
- token.getIndex());
- } else {
- return null;
- }
+ String hint = SimpleSyntaxHints.unknownFunction(function);
+ throw new SimpleParserException(
+ "Unknown function: " + function + (hint != null ? " (" + hint + ")" : ""),
+ token.getIndex());
}
- private Expression createSimpleFileExpression(String remainder, boolean strict) {
+ private Expression createSimpleFileExpression(String remainder) {
if (ObjectHelper.equal(remainder, "name")) {
return FileExpressionBuilder.fileNameExpression();
} else if (ObjectHelper.equal(remainder, "name.noext")) {
@@ -233,15 +227,12 @@ public class SimpleFunctionExpression extends LiteralExpression {
} else if (ObjectHelper.equal(remainder, "modified")) {
return FileExpressionBuilder.fileLastModifiedExpression();
}
- if (strict) {
- throw new SimpleParserException(
- "Unknown file language syntax: " + remainder + " (the file: functions describe the file being consumed:"
- + " ${file:name}, ${file:size}, ${file:parent}, ${file:absolute.path};"
- + " they do not read a file. To read a file into the body use the poll"
- + " EIP with a file: endpoint)",
- token.getIndex());
- }
- return null;
+ throw new SimpleParserException(
+ "Unknown file language syntax: " + remainder + " (the file: functions describe the file being consumed:"
+ + " ${file:name}, ${file:size}, ${file:parent}, ${file:absolute.path};"
+ + " they do not read a file. To read a file into the body use the poll"
+ + " EIP with a file: endpoint)",
+ token.getIndex());
}
@Deprecated(since = "4.21")
(camel) 01/11: CAMEL-24969: simple - range(max) starts at 0 as documented; CAMEL-24968: fix substring docs and catalog
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch fix/CAMEL-24962
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 2c518175f101ede3d52d0b99038816a59fe6a435
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 23 18:39:52 2026 +0200
CAMEL-24969: simple - range(max) starts at 0 as documented; CAMEL-24968: fix substring docs and catalog
range(max) now returns 0..max-1 (as Python, and as range(0,max)); it used to start at 1.
The substring catalog entry described positions and had wrong examples; the numbers
are how many characters to clip from each end.
Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
.../org/apache/camel/catalog/docs/simple-functions.adoc | 7 +++++--
.../resources/org/apache/camel/catalog/languages/simple.json | 2 +-
.../META-INF/org/apache/camel/language/simple/simple.json | 2 +-
.../main/docs/modules/languages/pages/simple-functions.adoc | 7 +++++--
.../org/apache/camel/language/simple/SimpleConstants.java | 12 ++++++------
.../language/simple/functions/CollectionFunctionFactory.java | 2 +-
.../java/org/apache/camel/language/simple/SimpleTest.java | 9 +++++++++
.../simple/functions/CollectionFunctionFactoryTest.java | 4 ++--
.../modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc | 4 ++++
9 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-functions.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-functions.adoc
index deeed77f9c76..525d77ecd2f1 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-functions.adoc
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-functions.adoc
@@ -526,8 +526,8 @@ The string functions is various functions to work with values that are String an
|`safeQuote()` | `String` | Returns the message body safely quoted if needed
|`safeQuote(exp)` | `String` | Returns the expression safely quoted if needed
|`substring(num1)` | `String` | Returns a substring of the message body. If the number is positive, then the returned string is clipped from the beginning. If the number is negative, then the returned string is clipped from the ending.
-|`substring(num1,num2)` | `String` | Returns a substring of the message body. `num1` clips from the beginning, `num2` clips from the ending. Negative values clip from the opposite end.
-|`substring(num1,num2,exp)` | `String` | Returns a substring of the given expression. `num1` clips from the beginning, `num2` clips from the ending. Negative values clip from the opposite end.
+|`substring(num1,num2)` | `String` | Returns a substring of the message body. `num1` is how many characters to clip from the beginning, and `num2` how many characters to clip from the ending. The sign of `num2` does not matter, so `-1` and `1` both clip one character.
+|`substring(num1,num2,exp)` | `String` | Returns a substring of the given expression. `num1` is how many characters to clip from the beginning, and `num2` how many characters to clip from the ending. The sign of `num2` does not matter, so `-1` and `1` both clip one character.
|`substringAfter(after)` | `String` | Returns a substring of the message body that comes after. Returns `null` if nothing comes after.
|`substringAfter(exp,after)` | `String` | Returns a substring of the expression that comes after. Returns `null` if nothing comes after.
|`substringBefore(before)` | `String` | Returns a substring of the message body that comes before. Returns `null` if nothing comes before.
@@ -600,6 +600,9 @@ The `substring`, `substringBefore`, and `substringAfter` functions are all simil
Suppose the message body contains `ABCDEFGHIJK` then `${substring(3)}` returns `DEFGHIJK`, and `${substring(-3)}` returns `ABCDEFGH`.
If you want to clip the first and last character you can use `${substring(1,-1)}` returning `BCDEFGHIJ`.
+The numbers are how many characters to clip, not positions as in a Python slice: `${substring(3,-2)}` returns `DEFGHI`
+(three characters clipped from the beginning and two from the end), and `${substring(1,0)}` returns `BCDEFGHIJK`.
+
[NOTE]
====
These `substring` functions are Camel functions with their own semantics (such as negative numbers clipping
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json
index 0ca682b5a72c..a1df2fe174f9 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json
@@ -159,7 +159,7 @@
"skip(num)": { "index": 130, "kind": "function", "displayName": "Skip First Items from the Message Body", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.Iterator", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The skip function iterates the message body and skips the first number of items. This can be used with the Splitter EIP to split a message body and skip the first N numbe [...]
"split(exp,separator)": { "index": 131, "kind": "function", "displayName": "Split String Values", "group": "collection", "label": "collection", "required": false, "javaType": "String[]", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Splits the message body\/expression as a String value using the separator into a String array", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": [...]
"stepId": { "index": 132, "kind": "function", "displayName": "Step Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the id of the current step the Exchange is being routed.", "ognl": false, "suffix": "}" },
- "substring(head,tail)": { "index": 133, "kind": "function", "displayName": "Substring", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression. If only one positive number, then the returned string is clipped from the beginning. If only one negative number, then the returned string is clipped from [...]
+ "substring(head,tail)": { "index": 133, "kind": "function", "displayName": "Substring", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression by clipping characters off its ends (not by positions). With one number, a positive number clips that many characters from the beginning, and a negative num [...]
"substringAfter(exp,before)": { "index": 134, "kind": "function", "displayName": "Substring After", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that comes after. Returns null if nothing comes after.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "requi [...]
"substringBefore(exp,before)": { "index": 135, "kind": "function", "displayName": "Substring Before", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that comes before. Returns null if nothing comes before.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "r [...]
"substringBetween(exp,after,before)": { "index": 136, "kind": "function", "displayName": "Substring Between", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that are between after and before. Returns null if nothing comes between.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", [...]
diff --git a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json
index 0ca682b5a72c..a1df2fe174f9 100644
--- a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json
+++ b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json
@@ -159,7 +159,7 @@
"skip(num)": { "index": 130, "kind": "function", "displayName": "Skip First Items from the Message Body", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.Iterator", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The skip function iterates the message body and skips the first number of items. This can be used with the Splitter EIP to split a message body and skip the first N numbe [...]
"split(exp,separator)": { "index": 131, "kind": "function", "displayName": "Split String Values", "group": "collection", "label": "collection", "required": false, "javaType": "String[]", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Splits the message body\/expression as a String value using the separator into a String array", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": [...]
"stepId": { "index": 132, "kind": "function", "displayName": "Step Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the id of the current step the Exchange is being routed.", "ognl": false, "suffix": "}" },
- "substring(head,tail)": { "index": 133, "kind": "function", "displayName": "Substring", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression. If only one positive number, then the returned string is clipped from the beginning. If only one negative number, then the returned string is clipped from [...]
+ "substring(head,tail)": { "index": 133, "kind": "function", "displayName": "Substring", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression by clipping characters off its ends (not by positions). With one number, a positive number clips that many characters from the beginning, and a negative num [...]
"substringAfter(exp,before)": { "index": 134, "kind": "function", "displayName": "Substring After", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that comes after. Returns null if nothing comes after.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "requi [...]
"substringBefore(exp,before)": { "index": 135, "kind": "function", "displayName": "Substring Before", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that comes before. Returns null if nothing comes before.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "r [...]
"substringBetween(exp,after,before)": { "index": 136, "kind": "function", "displayName": "Substring Between", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that are between after and before. Returns null if nothing comes between.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", [...]
diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-functions.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-functions.adoc
index deeed77f9c76..525d77ecd2f1 100644
--- a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-functions.adoc
+++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-functions.adoc
@@ -526,8 +526,8 @@ The string functions is various functions to work with values that are String an
|`safeQuote()` | `String` | Returns the message body safely quoted if needed
|`safeQuote(exp)` | `String` | Returns the expression safely quoted if needed
|`substring(num1)` | `String` | Returns a substring of the message body. If the number is positive, then the returned string is clipped from the beginning. If the number is negative, then the returned string is clipped from the ending.
-|`substring(num1,num2)` | `String` | Returns a substring of the message body. `num1` clips from the beginning, `num2` clips from the ending. Negative values clip from the opposite end.
-|`substring(num1,num2,exp)` | `String` | Returns a substring of the given expression. `num1` clips from the beginning, `num2` clips from the ending. Negative values clip from the opposite end.
+|`substring(num1,num2)` | `String` | Returns a substring of the message body. `num1` is how many characters to clip from the beginning, and `num2` how many characters to clip from the ending. The sign of `num2` does not matter, so `-1` and `1` both clip one character.
+|`substring(num1,num2,exp)` | `String` | Returns a substring of the given expression. `num1` is how many characters to clip from the beginning, and `num2` how many characters to clip from the ending. The sign of `num2` does not matter, so `-1` and `1` both clip one character.
|`substringAfter(after)` | `String` | Returns a substring of the message body that comes after. Returns `null` if nothing comes after.
|`substringAfter(exp,after)` | `String` | Returns a substring of the expression that comes after. Returns `null` if nothing comes after.
|`substringBefore(before)` | `String` | Returns a substring of the message body that comes before. Returns `null` if nothing comes before.
@@ -600,6 +600,9 @@ The `substring`, `substringBefore`, and `substringAfter` functions are all simil
Suppose the message body contains `ABCDEFGHIJK` then `${substring(3)}` returns `DEFGHIJK`, and `${substring(-3)}` returns `ABCDEFGH`.
If you want to clip the first and last character you can use `${substring(1,-1)}` returning `BCDEFGHIJ`.
+The numbers are how many characters to clip, not positions as in a Python slice: `${substring(3,-2)}` returns `DEFGHI`
+(three characters clipped from the beginning and two from the end), and `${substring(1,0)}` returns `BCDEFGHIJK`.
+
[NOTE]
====
These `substring` functions are Camel functions with their own semantics (such as negative numbers clipping
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java
index e5b61924a59a..992ea86f809e 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java
@@ -851,15 +851,15 @@ public final class SimpleConstants {
label = "core")
public static final String STEP_ID = "stepId";
- @Metadata(description = "Returns a substring of the message body/expression. If only one positive number, then the returned string is clipped from the beginning. If only one negative number, then the returned string is clipped from the beginning. Otherwise the returned string is clipped between the head and tail positions.",
+ @Metadata(description = "Returns a substring of the message body/expression by clipping characters off its ends (not by positions). With one number, a positive number clips that many characters from the beginning, and a negative number clips that many characters from the end. With two numbers, head is how many characters to clip from the beginning and tail how many to clip from the end; the sign of tail does not matter, so -1 and 1 both clip one character.",
label = "string", javaType = "String",
examples = {
- "${substring(0,5)} -> Hello // when body is 'Hello World'",
- "${substring(6)} -> World // from position 6 to end",
- "${substring(-5)} -> World // last 5 characters" },
+ "${substring(6)} -> World // when body is 'Hello World', clips the first 6 characters",
+ "${substring(-6)} -> Hello // clips the last 6 characters",
+ "${substring(1,-1)} -> ello Worl // clips the first and the last character" },
annotations = {
- "param=head:int:required::The start position (inclusive). Negative counts from end",
- "param=tail:int:optional::The end position (exclusive)" })
+ "param=head:int:required::How many characters to clip from the beginning. When it is the only argument, a negative value clips that many characters from the end instead",
+ "param=tail:int:optional::How many characters to clip from the end" })
public static final String SUBSTRING = "substring(head,tail)";
@Metadata(description = "Returns a substring of the message body/expression that comes after. Returns null if nothing comes after.",
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/CollectionFunctionFactory.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/CollectionFunctionFactory.java
index f671dc96eb65..aee3d6a1a7a9 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/CollectionFunctionFactory.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/CollectionFunctionFactory.java
@@ -107,7 +107,7 @@ public final class CollectionFunctionFactory implements SimpleLanguageFunctionFa
}
return CollectionExpressionBuilder.rangeExpression(tokens[0].trim(), tokens[1].trim());
} else {
- return CollectionExpressionBuilder.rangeExpression("1", values.trim());
+ return CollectionExpressionBuilder.rangeExpression("0", values.trim());
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index 97ce538fc685..165cc21096e4 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -1862,6 +1862,15 @@ public class SimpleTest extends LanguageTestSupport {
assertExpression("${substring(0,-99)}", "");
assertExpression("${substring(99,0)}", "");
assertExpression("${substring(0,0)}", "ABCDEFGHIJK");
+ // the sign of the tail does not matter
+ assertExpression("${substring(3,-2)}", "DEFGHI");
+ assertExpression("${substring(3,2)}", "DEFGHI");
+
+ // the examples in the simple catalog
+ exchange.getMessage().setBody("Hello World");
+ assertExpression("${substring(6)}", "World");
+ assertExpression("${substring(-6)}", "Hello");
+ assertExpression("${substring(1,-1)}", "ello Worl");
exchange.getMessage().setBody("Hello World");
exchange.getMessage().setHeader("foo", "1234567890");
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/functions/CollectionFunctionFactoryTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/functions/CollectionFunctionFactoryTest.java
index 3bf323a54c70..a1fbdb462d27 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/simple/functions/CollectionFunctionFactoryTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/functions/CollectionFunctionFactoryTest.java
@@ -66,9 +66,9 @@ public class CollectionFunctionFactoryTest extends AbstractSimpleFunctionFactory
@Test
@SuppressWarnings("unchecked")
public void testRangeMax() {
- // range(max) uses min=1, exclusive upper: range(3) -> [1,2]
+ // range(max) starts at 0, exclusive upper (as Python): range(3) -> [0,1,2]
List<Integer> result = evaluate("range(3)", List.class);
- assertEquals(List.of(1, 2), result);
+ assertEquals(List.of(0, 1, 2), result);
}
// --- shuffle toString ---
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
index 1cc7bcf85852..de0993249bb3 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc
@@ -37,6 +37,10 @@ body when the map has no `sku()` method, the same value `${body[sku]}` gives. A
`${body.size}` calls `size()` as before, and a name that is neither a method nor a key still fails. Only expressions
that used to throw can now return a value.
+The `range(max)` function now starts at 0, as documented and as `range` does in Python: `${range(5)}` returns
+`[0, 1, 2, 3, 4]` where it used to return `[1, 2, 3, 4]`. Routes that relied on the range starting at 1 must use
+`${range(1,5)}` instead. The two-argument form `range(min,max)` is unchanged.
+
=== Circuit Breaker EIP
The exchange property `CamelCircuitBreakerResponseRejected` is now also set inside the `onFallback`,
(camel) 03/11: CAMEL-24966: simple - fix numeric literals, elvis, ++/-- and null range/regex
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch fix/CAMEL-24962
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a80d45acd87e6b880598d9dc2736e84d068971de
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 23 18:43:11 2026 +0200
CAMEL-24966: simple - fix numeric literals, elvis, ++/-- and null range/regex
- a numeric literal evaluated as Long/int/Double is converted instead of cast (ClassCastException)
- negative literals below the int range parse as long
- elvis ?: treats any numeric zero as falsy and evaluates the left side once
- ++ and -- keep decimals (1.5++ is 2.5) and evaluate the left side once
- range and regex with a null right hand side do not match instead of a NullPointerException
Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
.../language/simple/ast/BinaryExpression.java | 12 +++-
.../language/simple/ast/NumericExpression.java | 8 +--
.../camel/language/simple/ast/OtherExpression.java | 10 ++-
.../camel/language/simple/ast/UnaryExpression.java | 63 +++++++------------
.../camel/language/simple/SimpleOperatorTest.java | 72 ++++++++++++++++++++++
5 files changed, 115 insertions(+), 50 deletions(-)
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/BinaryExpression.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/BinaryExpression.java
index 46ce040e1c1f..39f4c8886e52 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/BinaryExpression.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/BinaryExpression.java
@@ -192,7 +192,10 @@ public class BinaryExpression extends BaseSimpleNode {
@Override
public <T> T evaluate(Exchange exchange, Class<T> type) {
// reg ex should use String pattern, so we evaluate the right hand side as a String
- Predicate predicate = PredicateBuilder.regex(leftExp, rightExp.evaluate(exchange, String.class));
+ String pattern = rightExp.evaluate(exchange, String.class);
+ // no pattern (such as a missing header) matches nothing
+ Predicate predicate = pattern != null
+ ? PredicateBuilder.regex(leftExp, pattern) : PredicateBuilder.constant(false);
if (operator == BinaryOperatorType.NOT_REGEX) {
predicate = PredicateBuilder.not(predicate);
}
@@ -245,8 +248,11 @@ public class BinaryExpression extends BaseSimpleNode {
Predicate predicate;
String range = rightExp.evaluate(exchange, String.class);
- Matcher matcher = RANGE_PATTERN.matcher(range);
- if (matcher.matches()) {
+ Matcher matcher = range != null ? RANGE_PATTERN.matcher(range) : null;
+ if (range == null) {
+ // no range (such as a missing header) contains nothing
+ predicate = PredicateBuilder.constant(false);
+ } else if (matcher.matches()) {
// wrap as constant expression for the from and to values
Expression from = ExpressionBuilder.constantExpression(matcher.group(1));
Expression to = ExpressionBuilder.constantExpression(matcher.group(3));
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/NumericExpression.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/NumericExpression.java
index ac5cb062a88e..445abf97a0bb 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/NumericExpression.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/NumericExpression.java
@@ -40,8 +40,8 @@ public class NumericExpression extends BaseSimpleNode {
} else {
// its either a long or integer value (lets just avoid bytes)
long lon = Long.parseLong(text);
- if (lon < Integer.MAX_VALUE) {
- number = Integer.valueOf(text);
+ if (lon >= Integer.MIN_VALUE && lon <= Integer.MAX_VALUE) {
+ number = (int) lon;
} else {
number = lon;
}
@@ -68,9 +68,7 @@ public class NumericExpression extends BaseSimpleNode {
return new Expression() {
@Override
public <T> T evaluate(Exchange exchange, Class<T> type) {
- if (type == Object.class || type == int.class || type == Integer.class
- || type == long.class || type == Long.class
- || type == double.class || type == Double.class) {
+ if (type == Object.class || type.isInstance(number)) {
return type.cast(number);
}
return exchange.getContext().getTypeConverter().tryConvertTo(type, exchange, number);
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/OtherExpression.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/OtherExpression.java
index ca3d97449937..f5dd6a376787 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/OtherExpression.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/OtherExpression.java
@@ -95,11 +95,12 @@ public class OtherExpression extends BaseSimpleNode {
return new Expression() {
@Override
public <T> T evaluate(Exchange exchange, Class<T> type) {
+ // evaluate only once as the left hand side may have side effects
Object value = leftExp.evaluate(exchange, Object.class);
- if (value == null || Boolean.FALSE == value || ObjectHelper.isEmpty(value) || ObjectHelper.equal(0, value)) {
+ if (value == null || Boolean.FALSE == value || ObjectHelper.isEmpty(value) || isZero(value)) {
return rightExp.evaluate(exchange, type);
} else {
- return leftExp.evaluate(exchange, type);
+ return camelContext.getTypeConverter().convertTo(type, exchange, value);
}
}
@@ -109,4 +110,9 @@ public class OtherExpression extends BaseSimpleNode {
}
};
}
+
+ private static boolean isZero(Object value) {
+ // any kind of number such as 0, 0L, 0.0 or BigDecimal.ZERO
+ return value instanceof Number n && n.doubleValue() == 0;
+ }
}
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/UnaryExpression.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/UnaryExpression.java
index 6b50e5b97b7d..07fcd0fb1c60 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/UnaryExpression.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/UnaryExpression.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.language.simple.ast;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
import org.apache.camel.CamelContext;
import org.apache.camel.CamelExchangeException;
import org.apache.camel.Exchange;
@@ -73,65 +76,45 @@ public class UnaryExpression extends BaseSimpleNode {
final Expression leftExp = left.createExpression(camelContext, expression);
if (operator == UnaryOperatorType.INC) {
- return createIncExpression(camelContext, leftExp);
+ return createIncDecExpression(camelContext, leftExp, 1);
} else if (operator == UnaryOperatorType.DEC) {
- return createDecExpression(camelContext, leftExp);
+ return createIncDecExpression(camelContext, leftExp, -1);
}
throw new SimpleParserException("Unknown unary operator " + operator, token.getIndex());
}
- private Expression createIncExpression(CamelContext camelContext, final Expression leftExp) {
+ private Expression createIncDecExpression(CamelContext camelContext, final Expression leftExp, final int delta) {
return new Expression() {
@Override
public <T> T evaluate(Exchange exchange, Class<T> type) {
- Number num = leftExp.evaluate(exchange, Number.class);
+ // evaluate only once as the left hand side may have side effects
+ Object value = leftExp.evaluate(exchange, Object.class);
+ Number num = value instanceof Number n
+ ? n : camelContext.getTypeConverter().convertTo(Number.class, exchange, value);
if (num != null) {
- long val = num.longValue();
- val++;
-
- // convert value back to same type as input as we want to preserve type
- Object left = leftExp.evaluate(exchange, Object.class);
- try {
- left = camelContext.getTypeConverter().mandatoryConvertTo(left.getClass(), exchange, val);
- } catch (NoTypeConversionAvailableException e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ // keep decimals such as 1.5++ is 2.5
+ Number result;
+ if (num instanceof BigDecimal bd) {
+ result = bd.add(BigDecimal.valueOf(delta));
+ } else if (num instanceof BigInteger bi) {
+ result = bi.add(BigInteger.valueOf(delta));
+ } else if (num instanceof Double || num instanceof Float) {
+ result = num.doubleValue() + delta;
+ } else {
+ result = num.longValue() + delta;
}
- // and return the result
- return camelContext.getTypeConverter().convertTo(type, left);
- }
- // cannot convert the expression as a number
- Exception cause = new CamelExchangeException("Cannot evaluate " + leftExp + " as a number", exchange);
- throw RuntimeCamelException.wrapRuntimeCamelException(cause);
- }
-
- @Override
- public String toString() {
- return left + operator.toString();
- }
- };
- }
-
- private Expression createDecExpression(CamelContext camelContext, final Expression leftExp) {
- return new Expression() {
- @Override
- public <T> T evaluate(Exchange exchange, Class<T> type) {
- Number num = leftExp.evaluate(exchange, Number.class);
- if (num != null) {
- long val = num.longValue();
- val--;
-
// convert value back to same type as input as we want to preserve type
- Object left = leftExp.evaluate(exchange, Object.class);
+ Object answer;
try {
- left = camelContext.getTypeConverter().mandatoryConvertTo(left.getClass(), exchange, val);
+ answer = camelContext.getTypeConverter().mandatoryConvertTo(value.getClass(), exchange, result);
} catch (NoTypeConversionAvailableException e) {
throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
// and return the result
- return camelContext.getTypeConverter().convertTo(type, left);
+ return camelContext.getTypeConverter().convertTo(type, answer);
}
// cannot convert the expression as a number
Exception cause = new CamelExchangeException("Cannot evaluate " + leftExp + " as a number", exchange);
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleOperatorTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleOperatorTest.java
index a20eb732c9a2..4e1d666c33d8 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleOperatorTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleOperatorTest.java
@@ -16,7 +16,10 @@
*/
package org.apache.camel.language.simple;
+import java.math.BigDecimal;
+
import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
import org.apache.camel.LanguageTestSupport;
import org.apache.camel.Predicate;
import org.apache.camel.language.simple.types.SimpleIllegalSyntaxException;
@@ -1092,11 +1095,80 @@ public class SimpleOperatorTest extends LanguageTestSupport {
assertPredicate("${header.Account1} > 7", true);
}
+ @Test
+ public void testNumericLiteralAsOtherNumberType() {
+ // CAMEL-24966: a numeric literal evaluated as another number type is converted, not cast
+ exchange.getIn().setBody(5);
+ Expression exp = context.resolveLanguage("simple").createExpression("${body > 0 ? 1 : 0}");
+ assertEquals(1L, exp.evaluate(exchange, Long.class));
+ assertEquals(1, exp.evaluate(exchange, int.class));
+ assertEquals(1.0d, exp.evaluate(exchange, Double.class));
+ assertEquals("1", exp.evaluate(exchange, String.class));
+ }
+
+ @Test
+ public void testNegativeLongLiteral() {
+ exchange.getIn().setHeader("x", 5);
+ assertPredicate("${header.x} > -3000000000", true);
+ assertPredicate("${header.x} < -3000000000", false);
+ assertPredicate("${header.x} > -2147483648", true);
+ }
+
+ @Test
+ public void testElvisAnyZero() {
+ exchange.getIn().setHeader("count", 0L);
+ assertExpression("${header.count} ?: 'none'", "none");
+ exchange.getIn().setHeader("count", 0.0d);
+ assertExpression("${header.count} ?: 'none'", "none");
+ exchange.getIn().setHeader("count", BigDecimal.ZERO);
+ assertExpression("${header.count} ?: 'none'", "none");
+ exchange.getIn().setHeader("count", 3L);
+ assertExpression("${header.count} ?: 'none'", 3L);
+ }
+
+ @Test
+ public void testElvisEvaluatesLeftOnce() {
+ MyCounter counter = new MyCounter();
+ context.getRegistry().bind("counter", counter);
+ assertExpression("${bean:counter?method=next} ?: 'none'", 1);
+ assertEquals(1, counter.count);
+ }
+
+ @Test
+ public void testUnaryIncDecKeepsDecimals() {
+ exchange.getIn().setHeader("price", 1.5d);
+ assertExpression("${header.price}++", 2.5d);
+ assertExpression("${header.price}--", 0.5d);
+ exchange.getIn().setHeader("price", new BigDecimal("1.25"));
+ assertExpression("${header.price}++", new BigDecimal("2.25"));
+ exchange.getIn().setHeader("price", "1.5");
+ assertExpression("${header.price}++", "2.5");
+ exchange.getIn().setHeader("price", 7);
+ assertExpression("${header.price}--", 6);
+ }
+
+ @Test
+ public void testRegexAndRangeWithNullRightHandSide() {
+ exchange.getIn().setBody(5);
+ assertPredicate("${body} range ${header.none}", false);
+ assertPredicate("${body} !range ${header.none}", true);
+ assertPredicate("${body} regex ${header.none}", false);
+ assertPredicate("${body} !regex ${header.none}", true);
+ }
+
@Override
protected String getLanguageName() {
return "simple";
}
+ public static class MyCounter {
+ private int count;
+
+ public int next() {
+ return ++count;
+ }
+ }
+
public static class MyFileNameGenerator {
public String generateFilename(Exchange exchange) {
return "abc";
(camel) 08/11: CAMEL-24967: simple - fix how function names are matched and arguments are split
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch fix/CAMEL-24962
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 28e3825dc4c55d64c6b158ab5ec3cf304e25da73
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 23 19:09:18 2026 +0200
CAMEL-24967: simple - fix how function names are matched and arguments are split
- quotes inside a nested function argument are kept: ${size(${body.split(',')})}
- convertTo, headerAs and variableAs find the closing parenthesis of the argument list:
${convertTo(${header.foo.trim()},Integer)}
- a comma inside quotes is part of the value in concat, throwException and hash
- iif and replace with too few arguments report the valid syntax
- ${bean:type:com.foo.MyClass.myMethod} splits the method from the class name at the last dot
- a quoted key such as ${header['a.b']} is the name, not OGNL (also variable and exchangeProperty)
- a name glued to a function prefix is unknown: ${headerfoo}, ${uuidv7}, ${exceptionInfo}
(so custom functions with such names can be called)
- fix a SimpleTest typo that asserted ${variableAA(...)}
Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
.../language/simple/SimpleFunctionHelper.java | 45 +++++++-
.../simple/functions/BeanFunctionFactory.java | 11 ++
.../simple/functions/ExchangeFunctionFactory.java | 22 +++-
.../simple/functions/HeaderFunctionFactory.java | 11 +-
.../simple/functions/MathFunctionFactory.java | 6 +-
.../simple/functions/MiscFunctionFactory.java | 72 +++++++------
.../simple/functions/StringFunctionFactory.java | 57 +++++-----
.../simple/functions/VariableFunctionFactory.java | 11 +-
.../simple/SimpleFunctionArgumentsTest.java | 117 +++++++++++++++++++++
.../apache/camel/language/simple/SimpleTest.java | 2 +-
10 files changed, 279 insertions(+), 75 deletions(-)
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleFunctionHelper.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleFunctionHelper.java
index ab78e630b7ce..64f1336abe24 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleFunctionHelper.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleFunctionHelper.java
@@ -43,7 +43,7 @@ public final class SimpleFunctionHelper {
if (remainder == null) {
remainder = ifStartsWithReturnRemainder("header", function);
}
- return remainder;
+ return keyRemainder(remainder);
}
public static String parseVariable(String function) {
@@ -51,6 +51,49 @@ public final class SimpleFunctionHelper {
if (remainder == null) {
remainder = ifStartsWithReturnRemainder("variable", function);
}
+ return keyRemainder(remainder);
+ }
+
+ /**
+ * The remainder after a name such as header must start the key, so ${headerfoo} is not the header foo (and a
+ * custom function named such as headerCount can be called).
+ */
+ private static String keyRemainder(String remainder) {
+ if (remainder != null && !remainder.isEmpty()) {
+ char c = remainder.charAt(0);
+ if (c != '.' && c != ':' && c != '?' && c != '[') {
+ return null;
+ }
+ }
return remainder;
}
+
+ /**
+ * The index of the parenthesis that closes the argument list, where the text is what comes after the opening
+ * parenthesis. Parentheses inside nested functions and quotes are skipped, so the type in
+ * ${convertTo(${header.foo.trim()},Integer)} is found. Returns -1 if there is no closing parenthesis.
+ */
+ public static int indexOfClosingParenthesis(String text) {
+ int depth = 0;
+ boolean single = false;
+ boolean dubble = false;
+ for (int i = 0; i < text.length(); i++) {
+ char c = text.charAt(i);
+ if (c == '\'' && !dubble) {
+ single = !single;
+ } else if (c == '"' && !single) {
+ dubble = !dubble;
+ } else if (!single && !dubble) {
+ if (c == '(') {
+ depth++;
+ } else if (c == ')') {
+ if (depth == 0) {
+ return i;
+ }
+ depth--;
+ }
+ }
+ }
+ return -1;
+ }
}
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/BeanFunctionFactory.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/BeanFunctionFactory.java
index 0ed4f8e09f43..92e15b06e3ac 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/BeanFunctionFactory.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/BeanFunctionFactory.java
@@ -91,6 +91,17 @@ public final class BeanFunctionFactory implements SimpleLanguageFunctionFactory
if (doubleColonIndex > 0 && (!remainder.contains("(") || doubleColonIndex < beginOfParameterDeclaration)) {
ref = remainder.substring(0, doubleColonIndex);
method = remainder.substring(doubleColonIndex + 2);
+ } else if (remainder.startsWith("type:")) {
+ // type:com.foo.MyClass.myMethod: the class name has dots, so the method is the last part
+ // when it starts with a lower case letter, as Java method names do
+ String beforeParams = beginOfParameterDeclaration > 0
+ ? remainder.substring(0, beginOfParameterDeclaration) : remainder;
+ int idx = beforeParams.lastIndexOf('.');
+ if (idx > 0 && idx + 1 < beforeParams.length()
+ && Character.isLowerCase(beforeParams.charAt(idx + 1))) {
+ ref = remainder.substring(0, idx);
+ method = remainder.substring(idx + 1);
+ }
} else {
int idx = remainder.indexOf('.');
if (idx > 0) {
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/ExchangeFunctionFactory.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/ExchangeFunctionFactory.java
index 6b2cdd98bdcd..324cb1424b16 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/ExchangeFunctionFactory.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/ExchangeFunctionFactory.java
@@ -23,6 +23,7 @@ import org.apache.camel.language.simple.types.SimpleParserException;
import org.apache.camel.spi.SimpleLanguageFunctionFactory;
import org.apache.camel.support.builder.ExpressionBuilder;
import org.apache.camel.util.OgnlHelper;
+import org.apache.camel.util.StringHelper;
import static org.apache.camel.language.simple.SimpleFunctionHelper.ifStartsWithReturnRemainder;
@@ -38,7 +39,7 @@ public final class ExchangeFunctionFactory implements SimpleLanguageFunctionFact
public Expression createFunction(CamelContext camelContext, String function, int index) {
// camelContext OGNL
String remainder = ifStartsWithReturnRemainder("camelContext", function);
- if (remainder != null) {
+ if (remainder != null && startsOgnl(remainder)) {
boolean invalid = OgnlHelper.isInvalidValidOgnlExpression(remainder);
if (invalid) {
throw new SimpleParserException("Valid syntax: ${camelContext.OGNL} was: " + function, index);
@@ -48,7 +49,7 @@ public final class ExchangeFunctionFactory implements SimpleLanguageFunctionFact
// Exception OGNL — exchangeProperty/exchange checked separately, no prefix clash here
remainder = ifStartsWithReturnRemainder("exception", function);
- if (remainder != null) {
+ if (remainder != null && startsOgnl(remainder)) {
boolean invalid = OgnlHelper.isInvalidValidOgnlExpression(remainder);
if (invalid) {
throw new SimpleParserException("Valid syntax: ${exception.OGNL} was: " + function, index);
@@ -58,7 +59,7 @@ public final class ExchangeFunctionFactory implements SimpleLanguageFunctionFact
// exchangeProperty must be checked before exchange to avoid prefix clash
remainder = ifStartsWithReturnRemainder("exchangeProperty", function);
- if (remainder != null) {
+ if (remainder != null && (startsOgnl(remainder) || remainder.startsWith(":"))) {
// remove leading character (dot, colon or ?)
if (remainder.startsWith(".") || remainder.startsWith(":") || remainder.startsWith("?")) {
remainder = remainder.substring(1);
@@ -66,6 +67,11 @@ public final class ExchangeFunctionFactory implements SimpleLanguageFunctionFact
// remove starting and ending brackets
if (remainder.startsWith("[") && remainder.endsWith("]")) {
remainder = remainder.substring(1, remainder.length() - 1);
+ String unquoted = StringHelper.removeLeadingAndEndingQuotes(remainder);
+ if (!unquoted.equals(remainder)) {
+ // a quoted key such as ['a.b'] is the name, not an OGNL expression
+ return ExpressionBuilder.exchangePropertyExpression(unquoted);
+ }
}
boolean invalid = OgnlHelper.isInvalidValidOgnlExpression(remainder);
@@ -82,7 +88,7 @@ public final class ExchangeFunctionFactory implements SimpleLanguageFunctionFact
// exchange OGNL
remainder = ifStartsWithReturnRemainder("exchange", function);
- if (remainder != null && (remainder.startsWith(".") || remainder.startsWith("?") || remainder.startsWith("["))) {
+ if (remainder != null && startsOgnl(remainder)) {
// only ${exchange.OGNL}: ${exchangeCounter} is not an exchange OGNL but an unknown function
boolean invalid = OgnlHelper.isInvalidValidOgnlExpression(remainder);
if (invalid) {
@@ -93,4 +99,12 @@ public final class ExchangeFunctionFactory implements SimpleLanguageFunctionFact
return null;
}
+
+ /**
+ * Whether the remainder after the function name starts an OGNL expression, so ${exchangeCounter} or
+ * ${exceptionInfo} are not taken as ${exchange} or ${exception} with some OGNL glued on.
+ */
+ private static boolean startsOgnl(String remainder) {
+ return remainder.startsWith(".") || remainder.startsWith("?") || remainder.startsWith("[");
+ }
}
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/HeaderFunctionFactory.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/HeaderFunctionFactory.java
index 05b7f0ce5be1..2882dea4df8d 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/HeaderFunctionFactory.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/HeaderFunctionFactory.java
@@ -19,6 +19,7 @@ package org.apache.camel.language.simple.functions;
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
import org.apache.camel.language.simple.OgnlExpressionBuilder;
+import org.apache.camel.language.simple.SimpleFunctionHelper;
import org.apache.camel.language.simple.types.SimpleParserException;
import org.apache.camel.spi.SimpleLanguageFunctionFactory;
import org.apache.camel.support.builder.ExpressionBuilder;
@@ -40,13 +41,14 @@ public final class HeaderFunctionFactory implements SimpleLanguageFunctionFactor
// headerAs
String remainder = ifStartsWithReturnRemainder("headerAs(", function);
if (remainder != null) {
- String keyAndType = StringHelper.before(remainder, ")");
+ int end = SimpleFunctionHelper.indexOfClosingParenthesis(remainder);
+ String keyAndType = end >= 0 ? remainder.substring(0, end) : null;
if (keyAndType == null) {
throw new SimpleParserException("Valid syntax: ${headerAs(key, type)} was: " + function, index);
}
String key = StringHelper.before(keyAndType, ",");
String type = StringHelper.after(keyAndType, ",");
- remainder = StringHelper.after(remainder, ")");
+ remainder = remainder.substring(end + 1);
if (ObjectHelper.isEmpty(key) || ObjectHelper.isEmpty(type) || ObjectHelper.isNotEmpty(remainder)) {
throw new SimpleParserException("Valid syntax: ${headerAs(key, type)} was: " + function, index);
}
@@ -71,6 +73,11 @@ public final class HeaderFunctionFactory implements SimpleLanguageFunctionFactor
}
if (remainder.startsWith("[") && remainder.endsWith("]")) {
remainder = remainder.substring(1, remainder.length() - 1);
+ String unquoted = StringHelper.removeLeadingAndEndingQuotes(remainder);
+ if (!unquoted.equals(remainder)) {
+ // a quoted key such as ['a.b'] is the name, not an OGNL expression
+ return ExpressionBuilder.headerExpression(unquoted);
+ }
}
String key = StringHelper.removeLeadingAndEndingQuotes(remainder);
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/MathFunctionFactory.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/MathFunctionFactory.java
index 175b624c2b97..ff4c848cfa31 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/MathFunctionFactory.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/MathFunctionFactory.java
@@ -40,19 +40,19 @@ public final class MathFunctionFactory implements SimpleLanguageFunctionFactory
if (remainder != null) {
String value = StringHelper.beforeLast(remainder, ")");
return MathExpressionBuilder.absExpression(
- ObjectHelper.isNotEmpty(value) ? StringHelper.removeQuotes(value) : null);
+ ObjectHelper.isNotEmpty(value) ? StringHelper.removeLeadingAndEndingQuotes(value) : null);
}
remainder = ifStartsWithReturnRemainder("floor(", function);
if (remainder != null) {
String value = StringHelper.beforeLast(remainder, ")");
return MathExpressionBuilder.floorExpression(
- ObjectHelper.isNotEmpty(value) ? StringHelper.removeQuotes(value) : null);
+ ObjectHelper.isNotEmpty(value) ? StringHelper.removeLeadingAndEndingQuotes(value) : null);
}
remainder = ifStartsWithReturnRemainder("ceil(", function);
if (remainder != null) {
String value = StringHelper.beforeLast(remainder, ")");
return MathExpressionBuilder.ceilExpression(
- ObjectHelper.isNotEmpty(value) ? StringHelper.removeQuotes(value) : null);
+ ObjectHelper.isNotEmpty(value) ? StringHelper.removeLeadingAndEndingQuotes(value) : null);
}
remainder = ifStartsWithReturnRemainder("sum(", function);
if (remainder != null) {
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/MiscFunctionFactory.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/MiscFunctionFactory.java
index 05708f1528df..bfb7f8ec1f4b 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/MiscFunctionFactory.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/MiscFunctionFactory.java
@@ -19,6 +19,7 @@ package org.apache.camel.language.simple.functions;
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
import org.apache.camel.language.simple.MiscExpressionBuilder;
+import org.apache.camel.language.simple.SimpleFunctionHelper;
import org.apache.camel.language.simple.types.SimpleParserException;
import org.apache.camel.spi.SimpleLanguageFunctionFactory;
import org.apache.camel.util.ObjectHelper;
@@ -47,7 +48,7 @@ public final class MiscFunctionFactory implements SimpleLanguageFunctionFactory
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return MiscExpressionBuilder.isEmptyExpression(exp);
}
@@ -57,7 +58,7 @@ public final class MiscFunctionFactory implements SimpleLanguageFunctionFactory
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return MiscExpressionBuilder.isAlphaExpression(exp);
}
@@ -67,7 +68,7 @@ public final class MiscFunctionFactory implements SimpleLanguageFunctionFactory
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return MiscExpressionBuilder.isAlphaNumericExpression(exp);
}
@@ -77,7 +78,7 @@ public final class MiscFunctionFactory implements SimpleLanguageFunctionFactory
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return MiscExpressionBuilder.isNumericExpression(exp);
}
@@ -97,7 +98,7 @@ public final class MiscFunctionFactory implements SimpleLanguageFunctionFactory
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return MiscExpressionBuilder.kindOfTypeExpression(exp);
}
@@ -109,18 +110,17 @@ public final class MiscFunctionFactory implements SimpleLanguageFunctionFactory
String values = StringHelper.beforeLast(remainder, ")");
if (values == null || ObjectHelper.isEmpty(values)) {
throw new SimpleParserException(
- "Valid syntax: ${throwException(msg)} or ${throwException(type,msg)} was: " + function, index);
+ "Valid syntax: ${throwException(msg)} or ${throwException(msg,type)} was: " + function, index);
}
- if (values.contains(",")) {
- String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', true, true);
- if (tokens.length > 2) {
- throw new SimpleParserException(
- "Valid syntax: ${throwException(msg)} or ${throwException(type,msg)} was: " + function, index);
- }
- msg = StringHelper.removeQuotes(tokens[0]);
- type = StringHelper.removeQuotes(tokens[1]);
- } else {
- msg = StringHelper.removeQuotes(values.trim());
+ String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', true, true);
+ if (tokens.length > 2) {
+ throw new SimpleParserException(
+ "Valid syntax: ${throwException(msg)} or ${throwException(msg,type)} was: " + function, index);
+ }
+ // a comma inside a quoted message is part of the message
+ msg = StringHelper.removeLeadingAndEndingQuotes(tokens[0]);
+ if (tokens.length == 2) {
+ type = StringHelper.removeLeadingAndEndingQuotes(tokens[1]);
}
return MiscExpressionBuilder.throwExceptionExpression(msg, type);
}
@@ -135,14 +135,15 @@ public final class MiscFunctionFactory implements SimpleLanguageFunctionFactory
if (tokens.length != 2) {
throw new SimpleParserException("Valid syntax: ${assert(exp,msg)} was: " + function, index);
}
- return MiscExpressionBuilder.assertExpression(tokens[0], StringHelper.removeQuotes(tokens[1]));
+ return MiscExpressionBuilder.assertExpression(tokens[0], StringHelper.removeLeadingAndEndingQuotes(tokens[1]));
}
remainder = ifStartsWithReturnRemainder("convertTo(", function);
if (remainder != null) {
String exp = "${body}";
String type;
- String values = StringHelper.before(remainder, ")");
+ int end = SimpleFunctionHelper.indexOfClosingParenthesis(remainder);
+ String values = end >= 0 ? remainder.substring(0, end) : null;
if (values == null || ObjectHelper.isEmpty(values)) {
throw new SimpleParserException(
"Valid syntax: ${convertTo(type)} or ${convertTo(exp,type)} was: " + function, index);
@@ -153,12 +154,12 @@ public final class MiscFunctionFactory implements SimpleLanguageFunctionFactory
throw new SimpleParserException(
"Valid syntax: ${convertTo(type)} or ${convertTo(exp,type)} was: " + function, index);
}
- exp = StringHelper.removeQuotes(tokens[0]);
- type = StringHelper.removeQuotes(tokens[1]);
+ exp = StringHelper.removeLeadingAndEndingQuotes(tokens[0]);
+ type = StringHelper.removeLeadingAndEndingQuotes(tokens[1]);
} else {
- type = StringHelper.removeQuotes(values.trim());
+ type = StringHelper.removeLeadingAndEndingQuotes(values.trim());
}
- remainder = StringHelper.after(remainder, ")");
+ remainder = remainder.substring(end + 1);
if (ObjectHelper.isNotEmpty(remainder)) {
boolean invalid = OgnlHelper.isInvalidValidOgnlExpression(remainder);
if (invalid) {
@@ -172,7 +173,7 @@ public final class MiscFunctionFactory implements SimpleLanguageFunctionFactory
}
remainder = ifStartsWithReturnRemainder("messageHistory", function);
- if (remainder != null) {
+ if (remainder != null && remainder.startsWith("(")) {
boolean detailed;
String values = StringHelper.between(remainder, "(", ")");
if (values == null || ObjectHelper.isEmpty(values)) {
@@ -186,7 +187,8 @@ public final class MiscFunctionFactory implements SimpleLanguageFunctionFactory
}
remainder = ifStartsWithReturnRemainder("uuid", function);
- if (remainder != null) {
+ // ${uuid(kind)}, but ${uuidv7} is not the uuid function
+ if (remainder != null && remainder.startsWith("(")) {
String values = StringHelper.between(remainder, "(", ")");
return MiscExpressionBuilder.uuidExpression(values);
} else if (ObjectHelper.equal(function, "uuid")) {
@@ -200,15 +202,17 @@ public final class MiscFunctionFactory implements SimpleLanguageFunctionFactory
throw new SimpleParserException(
"Valid syntax: ${hash(value,algorithm)} or ${hash(value)} was: " + function, index);
}
- if (values.contains(",")) {
- String[] tokens = values.split(",", 2);
- if (tokens.length > 2) {
- throw new SimpleParserException(
- "Valid syntax: ${hash(value,algorithm)} or ${hash(value)} was: " + function, index);
- }
- return MiscExpressionBuilder.hashExpression(tokens[0].trim(), tokens[1].trim());
+ // a comma inside quotes is part of the value
+ String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', true, true);
+ if (tokens.length > 2) {
+ throw new SimpleParserException(
+ "Valid syntax: ${hash(value,algorithm)} or ${hash(value)} was: " + function, index);
+ }
+ String value = StringHelper.removeLeadingAndEndingQuotes(tokens[0].trim());
+ if (tokens.length == 2) {
+ return MiscExpressionBuilder.hashExpression(value, StringHelper.removeLeadingAndEndingQuotes(tokens[1].trim()));
} else {
- return MiscExpressionBuilder.hashExpression(values.trim(), "SHA-256");
+ return MiscExpressionBuilder.hashExpression(value, "SHA-256");
}
}
@@ -238,7 +242,7 @@ public final class MiscFunctionFactory implements SimpleLanguageFunctionFactory
"Valid syntax: ${iif(predicate,trueExpression,falseExpression)} was: " + function, index);
}
String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', true, true);
- if (tokens.length > 3) {
+ if (tokens.length != 3) {
throw new SimpleParserException(
"Valid syntax: ${iif(predicate,trueExpression,falseExpression)} was: " + function, index);
}
@@ -251,7 +255,7 @@ public final class MiscFunctionFactory implements SimpleLanguageFunctionFactory
if (ObjectHelper.isEmpty(value)) {
throw new SimpleParserException("Valid syntax: ${load(name)} but was: " + function, index);
}
- return MiscExpressionBuilder.loadExpression(StringHelper.removeQuotes(value));
+ return MiscExpressionBuilder.loadExpression(StringHelper.removeLeadingAndEndingQuotes(value));
}
return null;
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/StringFunctionFactory.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/StringFunctionFactory.java
index b19fdad17973..e32ed2227139 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/StringFunctionFactory.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/StringFunctionFactory.java
@@ -50,9 +50,9 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
"Valid syntax: ${replace(from,to)} or ${replace(from,to,expression)} was: " + function, index);
}
String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', false);
- if (tokens.length > 3) {
+ if (tokens.length < 2 || tokens.length > 3) {
throw new SimpleParserException(
- "Valid syntax: ${replace(from,to,expression)} was: " + function, index);
+ "Valid syntax: ${replace(from,to)} or ${replace(from,to,expression)} was: " + function, index);
}
String from = StringHelper.xmlDecode(tokens[0]);
String to = StringHelper.xmlDecode(tokens[1]);
@@ -196,7 +196,7 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return StringExpressionBuilder.trimExpression(exp);
}
@@ -216,7 +216,7 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return StringExpressionBuilder.capitalizeExpression(exp);
}
@@ -237,10 +237,10 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
throw new SimpleParserException(
"Valid syntax: ${pad(exp,len)} or ${pad(exp,len,separator)} was: " + function, index);
}
- exp = StringHelper.removeQuotes(tokens[0]);
- len = StringHelper.removeQuotes(tokens[1]);
+ exp = StringHelper.removeLeadingAndEndingQuotes(tokens[0]);
+ len = StringHelper.removeLeadingAndEndingQuotes(tokens[1]);
if (tokens.length == 3) {
- separator = StringHelper.removeQuotes(tokens[2]);
+ separator = StringHelper.removeLeadingAndEndingQuotes(tokens[2]);
}
return StringExpressionBuilder.padExpression(exp, len, separator);
}
@@ -257,21 +257,22 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
+ function,
index);
}
- if (values.contains(",")) {
- String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', true, true);
- if (tokens.length > 3) {
- throw new SimpleParserException(
- "Valid syntax: ${concat(exp)} or ${concat(exp,exp)} or ${concat(exp,exp,separator)} was: "
- + function,
- index);
- }
- exp1 = StringHelper.removeQuotes(tokens[0]);
- exp2 = StringHelper.removeQuotes(tokens[1]);
+ // a comma inside quotes is part of the value, such as ${concat('Hello, ')}
+ String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', true, true);
+ if (tokens.length > 3) {
+ throw new SimpleParserException(
+ "Valid syntax: ${concat(exp)} or ${concat(exp,exp)} or ${concat(exp,exp,separator)} was: "
+ + function,
+ index);
+ }
+ if (tokens.length >= 2) {
+ exp1 = StringHelper.removeLeadingAndEndingQuotes(tokens[0]);
+ exp2 = StringHelper.removeLeadingAndEndingQuotes(tokens[1]);
if (tokens.length == 3) {
- separator = StringHelper.removeQuotes(tokens[2]);
+ separator = StringHelper.removeLeadingAndEndingQuotes(tokens[2]);
}
} else {
- exp2 = StringHelper.removeQuotes(values.trim());
+ exp2 = StringHelper.removeLeadingAndEndingQuotes(tokens[0]);
}
return StringExpressionBuilder.concatExpression(exp1, exp2, separator);
}
@@ -281,7 +282,7 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return StringExpressionBuilder.quoteExpression(exp);
}
@@ -291,7 +292,7 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return StringExpressionBuilder.safeQuoteExpression(exp);
}
@@ -301,7 +302,7 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return StringExpressionBuilder.unquoteExpression(exp);
}
@@ -311,7 +312,7 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return StringExpressionBuilder.uppercaseExpression(exp);
}
@@ -321,7 +322,7 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return StringExpressionBuilder.lowercaseExpression(exp);
}
@@ -331,7 +332,7 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return StringExpressionBuilder.lengthExpression(exp);
}
@@ -341,7 +342,7 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return StringExpressionBuilder.sizeExpression(exp);
}
@@ -364,7 +365,7 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
index);
}
if (ObjectHelper.isNotEmpty(exp)) {
- exp = StringHelper.removeQuotes(exp.trim());
+ exp = StringHelper.removeLeadingAndEndingQuotes(exp.trim());
} else {
exp = null;
}
@@ -376,7 +377,7 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
String exp = null;
String value = StringHelper.beforeLast(remainder, ")");
if (ObjectHelper.isNotEmpty(value)) {
- exp = StringHelper.removeQuotes(value);
+ exp = StringHelper.removeLeadingAndEndingQuotes(value);
}
return StringExpressionBuilder.normalizeWhitespaceExpression(exp);
}
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/VariableFunctionFactory.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/VariableFunctionFactory.java
index 4b5b7c2f20e2..4d9b8671e277 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/VariableFunctionFactory.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/VariableFunctionFactory.java
@@ -19,6 +19,7 @@ package org.apache.camel.language.simple.functions;
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
import org.apache.camel.language.simple.OgnlExpressionBuilder;
+import org.apache.camel.language.simple.SimpleFunctionHelper;
import org.apache.camel.language.simple.types.SimpleParserException;
import org.apache.camel.spi.SimpleLanguageFunctionFactory;
import org.apache.camel.support.builder.ExpressionBuilder;
@@ -40,13 +41,14 @@ public final class VariableFunctionFactory implements SimpleLanguageFunctionFact
// variableAs
String remainder = ifStartsWithReturnRemainder("variableAs(", function);
if (remainder != null) {
- String keyAndType = StringHelper.before(remainder, ")");
+ int end = SimpleFunctionHelper.indexOfClosingParenthesis(remainder);
+ String keyAndType = end >= 0 ? remainder.substring(0, end) : null;
if (keyAndType == null) {
throw new SimpleParserException("Valid syntax: ${variableAs(key, type)} was: " + function, index);
}
String key = StringHelper.before(keyAndType, ",");
String type = StringHelper.after(keyAndType, ",");
- remainder = StringHelper.after(remainder, ")");
+ remainder = remainder.substring(end + 1);
if (ObjectHelper.isEmpty(key) || ObjectHelper.isEmpty(type) || ObjectHelper.isNotEmpty(remainder)) {
throw new SimpleParserException("Valid syntax: ${variableAs(key, type)} was: " + function, index);
}
@@ -71,6 +73,11 @@ public final class VariableFunctionFactory implements SimpleLanguageFunctionFact
}
if (remainder.startsWith("[") && remainder.endsWith("]")) {
remainder = remainder.substring(1, remainder.length() - 1);
+ String unquoted = StringHelper.removeLeadingAndEndingQuotes(remainder);
+ if (!unquoted.equals(remainder)) {
+ // a quoted key such as ['a.b'] is the name, not an OGNL expression
+ return ExpressionBuilder.variableExpression(unquoted);
+ }
}
String key = StringHelper.removeLeadingAndEndingQuotes(remainder);
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleFunctionArgumentsTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleFunctionArgumentsTest.java
new file mode 100644
index 000000000000..c14b50aa6a8a
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleFunctionArgumentsTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.camel.language.simple;
+
+import org.apache.camel.LanguageTestSupport;
+import org.apache.camel.language.simple.types.SimpleIllegalSyntaxException;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * CAMEL-24967: how the function names are matched and the arguments are split.
+ */
+public class SimpleFunctionArgumentsTest extends LanguageTestSupport {
+
+ @Override
+ protected String getLanguageName() {
+ return "simple";
+ }
+
+ @Test
+ public void testQuotesInsideANestedFunctionAreKept() {
+ exchange.getMessage().setBody("a,b,c");
+ assertExpression("${size(${body.split(',')})}", 3);
+ }
+
+ @Test
+ public void testConvertToWithParenthesesInTheExpression() {
+ exchange.getMessage().setHeader("foo", " 42 ");
+ assertExpression("${convertTo(${header.foo.trim()},Integer)}", 42);
+ }
+
+ @Test
+ public void testCommaInsideQuotes() {
+ exchange.getMessage().setBody("World");
+ // concat(exp) appends to the message body
+ assertExpression("${concat('Hello, ')}", "WorldHello, ");
+ Exception e = assertThrows(Exception.class,
+ () -> context.resolveLanguage("simple").createExpression("${throwException('Order failed, retry later')}")
+ .evaluate(exchange, Object.class));
+ assertEquals("Order failed, retry later", e.getMessage());
+ String hash = context.resolveLanguage("simple").createExpression("${hash('a,b')}").evaluate(exchange, String.class);
+ exchange.getMessage().setBody("a,b");
+ assertEquals(context.resolveLanguage("simple").createExpression("${hash(${body})}").evaluate(exchange, String.class),
+ hash);
+ }
+
+ @Test
+ public void testTooFewArguments() {
+ exchange.getMessage().setHeader("foo", 1);
+ // with a nested function the arguments are parsed when evaluated
+ Exception e = assertThrows(Exception.class,
+ () -> context.resolveLanguage("simple").createExpression("${iif(${header.foo} > 0,'yes')}")
+ .evaluate(exchange, Object.class));
+ assertTrue(e.getMessage().contains("Valid syntax: ${iif(predicate,trueExpression,falseExpression)}"), e.getMessage());
+ e = assertThrows(SimpleIllegalSyntaxException.class,
+ () -> context.resolveLanguage("simple").createExpression("${replace(a)}"));
+ assertTrue(e.getMessage().contains("Valid syntax: ${replace(from,to)}"), e.getMessage());
+ }
+
+ @Test
+ public void testBeanTypeWithPackage() {
+ assertExpression("${bean:type:java.lang.System.lineSeparator}", System.lineSeparator());
+ assertExpression("${bean:type:org.apache.camel.language.simple.SimpleFunctionArgumentsTest$MyStatic.hello}", "Hi");
+ }
+
+ @Test
+ public void testQuotedKeyIsNotOgnl() {
+ exchange.getMessage().setHeader("a", "xyz");
+ exchange.getMessage().setHeader("a.b", "yes");
+ assertExpression("${header['a.b']}", "yes");
+ exchange.getMessage().removeHeader("a.b");
+ assertExpression("${header['a.b']}", null);
+ exchange.setVariable("x.y", "var");
+ assertExpression("${variable['x.y']}", "var");
+ exchange.setProperty("p.q", "prop");
+ assertExpression("${exchangeProperty['p.q']}", "prop");
+ }
+
+ @Test
+ public void testNamesMustNotBeGluedToAPrefix() {
+ exchange.getMessage().setHeader("foo", "bar");
+ assertThrows(SimpleIllegalSyntaxException.class,
+ () -> context.resolveLanguage("simple").createExpression("${headerfoo}"));
+ assertThrows(SimpleIllegalSyntaxException.class,
+ () -> context.resolveLanguage("simple").createExpression("${uuidv7}"));
+ assertThrows(SimpleIllegalSyntaxException.class,
+ () -> context.resolveLanguage("simple").createExpression("${exceptionInfo}"));
+ // the proper forms still work
+ assertExpression("${header.foo}", "bar");
+ assertExpression("${header:foo}", "bar");
+ assertExpression("${header[foo]}", "bar");
+ assertExpression("${headers.foo}", "bar");
+ }
+
+ public static class MyStatic {
+ public static String hello() {
+ return "Hi";
+ }
+ }
+}
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index e693c5f6719b..67f3b96d87de 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -864,7 +864,7 @@ public class SimpleTest extends LanguageTestSupport {
// exchange scoped
assertExpression("${variableAs('cheese', 'String')}", "gauda");
assertExpression("${variableAs('foo', 'int')}", null);
- assertExpression("${variableAA('bar', 'int')}", null);
+ assertExpression("${variableAs('bar', 'int')}", null);
// global scoped
assertExpression("${variableAs('global:cheese', 'String')}", "gorgonzola");
(camel) 09/11: CAMEL-24970: simple - fix catalog entries, docs and syntax hints
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch fix/CAMEL-24962
in repository https://gitbox.apache.org/repos/asf/camel.git
commit c83b9f71c8def1764e3c924de17a6ba63a888319
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 23 19:13:16 2026 +0200
CAMEL-24970: simple - fix catalog entries, docs and syntax hints
- catalog: hostname and exception.stacktrace spelled as the functions are, setAttachment(key,exp),
not(exp), throwException(msg,type) as implemented, assert requires msg, uuid lists random,
add logExchange, bean: and date: examples use the colon form that parses
- ceil and floor return long; file:modified returns Long
- file language: fix the dagger typo in three descriptions, and the .noext.single description
- substringBetween error message named substringAfter
- syntax hints: the function list includes the current functions (average, uppercase, size, ...),
and upper/lower/avg/count suggest uppercase(), lowercase(), average(...), size()
Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
.../apache/camel/catalog/docs/file-language.adoc | 2 +-
.../camel/catalog/docs/simple-functions.adoc | 10 +-
.../org/apache/camel/catalog/languages/file.json | 8 +-
.../org/apache/camel/catalog/languages/simple.json | 175 +++++++++++----------
.../org/apache/camel/language/simple/file.json | 8 +-
.../org/apache/camel/language/simple/simple.json | 175 +++++++++++----------
.../modules/languages/pages/file-language.adoc | 2 +-
.../modules/languages/pages/simple-functions.adoc | 10 +-
.../camel/language/simple/FileConstants.java | 8 +-
.../camel/language/simple/SimpleConstants.java | 51 +++---
.../language/simple/SimpleFunctionHelper.java | 4 +-
.../camel/language/simple/SimpleSyntaxHints.java | 36 +++--
.../simple/functions/StringFunctionFactory.java | 4 +-
.../language/simple/SimpleSyntaxHintsTest.java | 5 +
14 files changed, 261 insertions(+), 237 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/file-language.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/file-language.adoc
index baf9228dd657..31f2ed00041c 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/file-language.adoc
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/file-language.adoc
@@ -83,7 +83,7 @@ this expression strips only the last part, and keeps the others.
|file:size |Long |yes |no |yes |no |refers to the file length returned as a Long type
-|file:modified |Date |yes |no |yes |no |Refers to the file last modified returned as a Date type
+|file:modified |Long |yes |no |yes |no |Refers to the file last modified returned as a Long (millis since epoch)
|date:_command:pattern_ |String |yes |yes |yes |yes |for date formatting using the `java.text.SimpleDateFormat` patterns. Is
an *extension* to the xref:simple-language.adoc[Simple] language. Additional
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-functions.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-functions.adoc
index 41d80e7bbcf8..a6a26ee3573a 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-functions.adoc
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-functions.adoc
@@ -96,7 +96,7 @@ to access Camel functionality and content of the message being routed.
|`setHeader(name,type,exp)` | `null` | Sets a message header with the given expression (optional converting to the given type).
|`setVariable(name,type,exp)` | `null` | Sets a variable with the given expression (optional converting to the given type).
|`stepId` | `String` | Returns the id of the current step the `Exchange` is being routed. Returns `null` if there are no steps.
-|`throwException(type,msg)` | `Exception` | Deliberately throws an error. Uses `IllegalArgumentException` by default if no type is specified (use fully qualified classname).
+|`throwException(msg,type)` | `Exception` | Deliberately throws an error. Uses `IllegalArgumentException` by default if no type is specified (use fully qualified classname).
|`type:name.field` | `Object` | To refer to a type or field by its fully qualified classname. For example: `type:org.apache.camel.Exchange.FILE_NAME`.
|`val(exp)` | `Object` | Returns the expression as a constant value.
|`variable.key` | `Object` | To look up the variable with the given key.
@@ -410,10 +410,10 @@ Various functions to work with numbers.
|`abs()` | `long` | Converts the message body to a long number and return the absolute value.
|`abs(exp)` | `Long` | Converts the message body (or expression) to a long number and return the absolute value.
|`average(val1,val2,...)` | `long` | Returns the average number from all the values (integral numbers only).
-|`ceil()` | `int` | Converts the message body to a floating number and return the ceil value (rounded up to nearest integer).
-|`ceil(exp)` | `int` | Converts the expression to a floating number and return the ceil value (rounded up to nearest integer).
-|`floor()` | `int` | Converts the message body to a floating number and return the floor value (rounded down to nearest integer).
-|`floor(exp)` | `int` | Converts the expression to a floating number and return the floor value (rounded down to nearest integer).
+|`ceil()` | `long` | Converts the message body to a floating number and return the ceil value (rounded up to nearest integer).
+|`ceil(exp)` | `long` | Converts the expression to a floating number and return the ceil value (rounded up to nearest integer).
+|`floor()` | `long` | Converts the message body to a floating number and return the floor value (rounded down to nearest integer).
+|`floor(exp)` | `long` | Converts the expression to a floating number and return the floor value (rounded down to nearest integer).
|`max(val1,val2,...)` | `long` | Returns the maximum number from all the values (integral numbers only).
|`min(val1,val2,...)` | `long` | Returns the minimum number from all the values (integral numbers only).
|`random(max)` | `int` | Returns a random `Integer` between 0 (included) and max (excluded).
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/file.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/file.json
index 0103a87254b5..90523bcc10d2 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/file.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/file.json
@@ -28,12 +28,12 @@
"functions": {
"file:name": { "index": 0, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (relative from starting directory)", "ognl": false, "suffix": "}" },
"file:name.noext": { "index": 1, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (relative from starting directory) without extension", "ognl": false, "suffix": "}" },
- "file:name.noext.single": { "index": 2, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (relative from starting directory) without extension. If the file name has multiple dots, then this expression strips and only returns the last part.", "ognl": false, "suffix": "}" },
+ "file:name.noext.single": { "index": 2, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (relative from starting directory) without extension. If the file name has multiple dots, then only the last extension is stripped (such as a.tar.gz becomes a.tar).", "ognl": false, "suffix": "}" },
"file:name.ext": { "index": 3, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file extension", "ognl": false, "suffix": "}" },
"file:name.ext.single": { "index": 4, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file extension. If the file extension has multiple dots, then this expression strips and only returns the last part.", "ognl": false, "suffix": "}" },
- "file:onlyname": { "index": 5, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "\u2020he file name (without any leading paths)", "ognl": false, "suffix": "}" },
- "file:onlyname.noext": { "index": 6, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "\u2020he file name (without any leading paths) without extension", "ognl": false, "suffix": "}" },
- "file:onlyname.noext.single": { "index": 7, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "\u2020he file name (without any leading paths) without extension. If the file name has multiple dots, then this expression strips and only returns the last part.", "ognl": false, "suffix": "}" },
+ "file:onlyname": { "index": 5, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (without any leading paths)", "ognl": false, "suffix": "}" },
+ "file:onlyname.noext": { "index": 6, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (without any leading paths) without extension", "ognl": false, "suffix": "}" },
+ "file:onlyname.noext.single": { "index": 7, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (without any leading paths) without extension. If the file name has multiple dots, then only the last extension is stripped (such as a.tar.gz becomes a.tar).", "ognl": false, "suffix": "}" },
"file:parent": { "index": 8, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file parent directory (null if no parent directory)", "ognl": false, "suffix": "}" },
"file:path": { "index": 9, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file path", "ognl": false, "suffix": "}" },
"file:absolute": { "index": 10, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the file is regarded as absolute or relative", "ognl": false, "suffix": "}" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json
index dfc3d543b094..dfc7242ff7f6 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json
@@ -27,7 +27,7 @@
},
"functions": {
"abs(exp)": { "index": 0, "kind": "function", "displayName": "Absolute Number", "group": "number", "label": "number", "required": false, "javaType": "Long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body (or expression) to a long number and return the absolute value.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "d [...]
- "assert(exp,msg)": { "index": 1, "kind": "function", "displayName": "Assert", "group": "condition", "label": "condition", "required": false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the expression and throws an exception with the message if the condition is false", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": true, "descr [...]
+ "assert(exp,msg)": { "index": 1, "kind": "function", "displayName": "Assert", "group": "condition", "label": "condition", "required": false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the expression and throws an exception with the message if the condition is false", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": true, "descr [...]
"a2a:emit(message)": { "index": 2, "kind": "function", "displayName": "A2A Emit Progress", "group": "ai", "label": "a2a,ai", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Emits an A2A task progress update with WORKING state. Requires the camel-a2a component on the classpath and an active A2A task context.", "ognl": false, "suffix": "}", "params": [ { "name": "message", "javaTyp [...]
"a2a:emit(state,message)": { "index": 3, "kind": "function", "displayName": "A2A Emit Progress State", "group": "ai", "label": "a2a,ai", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Emits an A2A task progress update with the given task state. Requires the camel-a2a component on the classpath and an active A2A task context.", "ognl": false, "suffix": "}", "params": [ { "name": [...]
"a2a:text": { "index": 4, "kind": "function", "displayName": "A2A Text", "group": "ai", "label": "a2a,ai", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Extracts TextPart content from an A2A Task or Message in the message body.", "ognl": false, "suffix": "}", "examples": [ "${a2a:text}" ] },
@@ -63,7 +63,7 @@
"average(val...)": { "index": 34, "kind": "function", "displayName": "Average Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the average number from all the values (integral numbers only).", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "required": false, "defaultValue": "body", "description": [...]
"base64Decode(exp)": { "index": 35, "kind": "function", "displayName": "Base64 Decode", "group": "base64", "label": "base64", "required": false, "javaType": "byte[]", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Base64 decodes the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. Wh [...]
"base64Encode(exp)": { "index": 36, "kind": "function", "displayName": "Base64 Encode", "group": "base64", "label": "base64", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Base64 encodes the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. Wh [...]
- "bean(name.method)": { "index": 37, "kind": "function", "displayName": "Call Java Bean", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Calls a Java bean. The name of the bean can also refer to a class name using type prefix as follows `bean:type:com.foo.MyClass`. If no method name is given then Camel will automatic attempt to find the best meth [...]
+ "bean(name.method)": { "index": 37, "kind": "function", "displayName": "Call Java Bean", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Calls a Java bean. The name of the bean can also refer to a class name using type prefix as follows `bean:type:com.foo.MyClass`. If no method name is given then Camel will automatic attempt to find the best meth [...]
"body": { "index": 38, "kind": "function", "displayName": "Body", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message body", "ognl": true, "suffix": "}", "examples": [ "${body} -> Hello World \/\/ when body is the string 'Hello World'" ] },
"bodyAs(type)": { "index": 39, "kind": "function", "displayName": "Body As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body to the given type (classname).", "ognl": true, "suffix": "}", "params": [ { "name": "type", "javaType": "String", "required": true, "description": "The target type classname (e.g. String, int, byte [...]
"bodyOneLine": { "index": 40, "kind": "function", "displayName": "Body One Line", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to a String and removes all line-breaks, so the string is in one line.", "ognl": false, "suffix": "}", "examples": [ "${bodyOneLine} -> Hello World \/\/ when body is 'Hello\\nWorld'" ] },
@@ -71,13 +71,13 @@
"camelContext": { "index": 42, "kind": "function", "displayName": "Camel Context", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Camel Context", "ognl": true, "suffix": "}" },
"camelId": { "index": 43, "kind": "function", "displayName": "Camel Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the CamelContext", "ognl": false, "suffix": "}", "examples": [ "${camelId} -> camel-1" ] },
"capitalize(exp)": { "index": 44, "kind": "function", "displayName": "Capitalize String Values", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Capitalizes the message body\/expression as a String value (upper case every words)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue [...]
- "ceil(exp)": { "index": 45, "kind": "function", "displayName": "Ceil Number", "group": "number", "label": "number", "required": false, "javaType": "Integer", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body (or expression) to a floating number and return the ceil value (rounded up to nearest integer).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": [...]
+ "ceil(exp)": { "index": 45, "kind": "function", "displayName": "Ceil Number", "group": "number", "label": "number", "required": false, "javaType": "Long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body (or expression) to a floating number and return the ceil value (rounded up to nearest integer).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": fal [...]
"clearAttachments": { "index": 46, "kind": "function", "displayName": "Clear Attachments", "group": "attachment", "label": "attachment", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Removes all existing attachments on the message.", "ognl": false, "suffix": "}" },
"collate(num)": { "index": 47, "kind": "function", "displayName": "Group Message Body into Sub Lists", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.Iterator", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The collate function iterates the message body and groups the data into sub lists of specified size. This can be used with the Splitter EIP to split a message body and group [...]
"concat(exp,exp,separator)": { "index": 48, "kind": "function", "displayName": "Concat", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Performs a string concat using two expressions (message body as default) with optional separator", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": true, "descript [...]
"convertTo(exp,type)": { "index": 49, "kind": "function", "displayName": "Convert To", "group": "core", "label": "core", "required": false, "javaType": "", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body (or expression) to the specified type.", "ognl": true, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressio [...]
"contains(exp,text)": { "index": 50, "kind": "function", "displayName": "Contains", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns true if the message body (or expression) contains part of the text (ignore case)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue" [...]
- "date(command)": { "index": 51, "kind": "function", "displayName": "Parse Date", "group": "date", "label": "date", "required": false, "javaType": "java.util.Date", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates to a java.util.Date object. Supported commands are: `now` for current timestamp, `millis` for current timestamp in millis (unix epoch), `exchangeCreated` for the timestamp when the current exchange was [...]
+ "date(command)": { "index": 51, "kind": "function", "displayName": "Parse Date", "group": "date", "label": "date", "required": false, "javaType": "java.util.Date", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates to a java.util.Date object. Supported commands are: `now` for current timestamp, `millis` for current timestamp in millis (unix epoch), `exchangeCreated` for the timestamp when the current exchange was [...]
"date-with-timezone(command:timezone:pattern)": { "index": 52, "kind": "function", "displayName": "Date Formatter", "group": "date", "label": "date", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Formats the date to a String using the given date pattern, and with support for timezone. Supported commands are: `now` for current timestamp, `exchangeCreated` for the timestamp when [...]
"distinct(val...)": { "index": 53, "kind": "function", "displayName": "Distinct Values", "group": "collection", "label": "collection", "required": false, "javaType": "Set", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a set of all the values with duplicates removed", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": false, "defaultValue": "body", "description": "Valu [...]
"empty(type)": { "index": 54, "kind": "function", "displayName": "Create Empty Object", "group": "collection", "label": "collection", "required": false, "javaType": "Object", "prefix": "${", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "description": "Creates a new empty object (decided by type). Use `string` to create an empty String. Use `list` to create an empty `java.util.ArrayList`. Use `map` to create an empty `java.util.LinkedHashMap`. Use `s [...]
@@ -88,97 +88,98 @@
"exchangeProperty.name": { "index": 59, "kind": "function", "displayName": "Exchange Property", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exchange property with the given name", "ognl": true, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The exchange property name" } ], "examples": [...]
"exception": { "index": 60, "kind": "function", "displayName": "Exception", "group": "core", "label": "core", "required": false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exception object on the exchange (also from caught exceptions), is null if no exception present.", "ognl": true, "suffix": "}" },
"exception.message": { "index": 61, "kind": "function", "displayName": "Exception Message", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exception message (also from caught exceptions), is null if no exception present.", "ognl": false, "suffix": "}", "examples": [ "${exception.message} -> Connection refused" ] },
- "exception.stackTrace": { "index": 62, "kind": "function", "displayName": "Exception Stacktrace", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exception stacktrace (also from caught exceptions), is null if no exception present.", "ognl": false, "suffix": "}" },
+ "exception.stacktrace": { "index": 62, "kind": "function", "displayName": "Exception Stacktrace", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exception stacktrace (also from caught exceptions), is null if no exception present.", "ognl": false, "suffix": "}" },
"filter(exp,fun)": { "index": 63, "kind": "function", "displayName": "Filter Elements", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a List containing the values that satisfy the predicate function (returning true)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultVa [...]
"forEach(exp,fun)": { "index": 64, "kind": "function", "displayName": "For Each call Function", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a List containing the values returned by the function when applied to each value from the input expression", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Objec [...]
- "floor(exp)": { "index": 65, "kind": "function", "displayName": "Floor Number", "group": "number", "label": "number", "required": false, "javaType": "Integer", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body (or expression) to a floating number and return the floor value (rounded down to nearest integer).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "requir [...]
+ "floor(exp)": { "index": 65, "kind": "function", "displayName": "Floor Number", "group": "number", "label": "number", "required": false, "javaType": "Long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body (or expression) to a floating number and return the floor value (rounded down to nearest integer).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required" [...]
"fromRouteId": { "index": 66, "kind": "function", "displayName": "From Route Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The original route id where this exchange was created.", "ognl": false, "suffix": "}", "examples": [ "${fromRouteId} -> myRoute" ] },
"function(name,exp)": { "index": 67, "kind": "function", "displayName": "Invoke Custom Function", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Invokes a custom function with the given name using the message body (or expression) as input parameter.", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": t [...]
"hash(exp,algorithm)": { "index": 68, "kind": "function", "displayName": "Compute Hash Value", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a hashed value (string in hex decimal) of the message body\/expression using JDK MessageDigest. The algorithm can be SHA-256 (default) or SHA3-256.", "ognl": false, "suffix": "}", "params": [ { " [...]
"header.name": { "index": 69, "kind": "function", "displayName": "Header", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message header with the given name", "ognl": true, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The header name" } ], "examples": [ "${header.ContentType} -> applica [...]
"headerAs(key,type)": { "index": 70, "kind": "function", "displayName": "Header As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message header to the given type (classname).", "ognl": false, "suffix": "}", "params": [ { "name": "key", "javaType": "String", "required": true, "description": "The header name" }, { "name": "type", " [...]
"headers": { "index": 71, "kind": "function", "displayName": "Headers", "group": "core", "label": "core", "required": false, "javaType": "java.util.Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns all the message headers in a Map", "ognl": false, "suffix": "}", "examples": [ "${headers} -> {ContentType=application\/json, CamelFileName=data.txt}" ] },
- "hostName": { "index": 72, "kind": "function", "displayName": "Host Name", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the local hostname (may be empty if not possible to resolve).", "ognl": false, "suffix": "}", "examples": [ "${hostName} -> myserver.local" ] },
- "htmlClean(exp)": { "index": 73, "kind": "function", "displayName": "Html Clean", "group": "html", "label": "html", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Cleans the HTML to remove unsafe links and JavaScripts from the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", [...]
- "htmlDecode(exp)": { "index": 74, "kind": "function", "displayName": "Html Decode", "group": "html", "label": "html", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Decodes the HTML as plain text (removing all HTML tags) that is also suitable as input for AI and LLMs", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultVal [...]
- "htmlParse(exp)": { "index": 75, "kind": "function", "displayName": "Html Parse", "group": "html", "label": "html", "required": false, "javaType": "org.jsoup.nodes.Document", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Parses the HTML as a JSoup object from the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "d [...]
- "id": { "index": 76, "kind": "function", "displayName": "Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message id", "ognl": false, "suffix": "}" },
- "iif(predicate,trueExp,falseExp)": { "index": 77, "kind": "function", "displayName": "If Then Else", "group": "condition", "label": "condition", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the predicate and returns the value of trueExp or falseExp. This function is similar to the ternary operator in Java.", "ognl": false, "suffix": "}", "params": [ { "name": "predic [...]
- "isAlpha(exp)": { "index": 78, "kind": "function", "displayName": "Is Alphabetic Value", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is alphabetic value (A..Z). For more advanced checks use the `regex` operator.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object [...]
- "isAlphaNumeric(exp)": { "index": 79, "kind": "function", "displayName": "Is Alphabetic-Numeric Value", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is alphanumeric value (A..Z0-9). For more advanced checks use the `regex` operator.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", [...]
- "isEmpty(exp)": { "index": 80, "kind": "function", "displayName": "Is Empty", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is null or empty (list\/map types are tested if they have 0 elements).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": fals [...]
- "isNumeric(exp)": { "index": 81, "kind": "function", "displayName": "Is Numeric Value", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is numeric value (0..9). For more advanced checks use the `regex` operator.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", " [...]
- "jq(input,exp)": { "index": 82, "kind": "function", "displayName": "JQ", "group": "json", "label": "json", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with JSon data, then this allows using the JQ language, for example, to extract data from the message body (in JSon format). This requires having camel-jq JAR on the classpath. For input (optional), you can choose [...]
- "jsonpath(input,exp)": { "index": 83, "kind": "function", "displayName": "JSonPath", "group": "json", "label": "json", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with JSon data, then this allows using the JSonPath language, for example, to extract data from the message body (in JSon format). This requires having camel-jsonpath JAR on the classpath. For input (op [...]
- "join(separator,prefix,exp)": { "index": 84, "kind": "function", "displayName": "Join", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The join function iterates the message body\/expression and joins the data into a string. The separator is by default a comma. The prefix is optional. The join uses the message body as source by default. It i [...]
- "length(exp)": { "index": 85, "kind": "function", "displayName": "Length", "group": "core", "label": "core", "required": false, "javaType": "int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The payload length (number of bytes) of the message body (or expression).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressi [...]
- "list(val...)": { "index": 86, "kind": "function", "displayName": "Create List of values", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.ArrayList", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The list function creates an ArrayList with the given set of values.", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": true, "description": [...]
- "listAdd(source,exp)": { "index": 87, "kind": "function", "displayName": "List Add", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Adds the result of the expression to the message body (or expression) which is a list", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "defaultValue" [...]
- "listRemove(source,exp)": { "index": 88, "kind": "function", "displayName": "List Remove", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Removes the result of the expression from the message body (or expression) which is a list", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "de [...]
- "load(file)": { "index": 89, "kind": "function", "displayName": "Load", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Loads the content of the resource from classpath (cannot load from file-system to avoid dangerous situations).", "ognl": false, "suffix": "}", "params": [ { "name": "file", "javaType": "String", "required": true, "description": [...]
- "lowercase(exp)": { "index": 90, "kind": "function", "displayName": "Lowercase", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Lowercases the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. When omitted [...]
- "mandatoryBodyAs(type)": { "index": 91, "kind": "function", "displayName": "Mandatory Body As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body to the given type (classname). If the body is null then the function will fail with an exception", "ognl": true, "suffix": "}", "params": [ { "name": "type", "javaType": "String" [...]
- "map(key1,value1,...)": { "index": 92, "kind": "function", "displayName": "Create Map of pairs", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.LinkedHashMap", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The map function creates a LinkedHashMap with the given set of pairs.", "ognl": false, "suffix": "}", "params": [ { "name": "key1", "javaType": "Object", "required": true, "d [...]
- "mapAdd(source,key,exp)": { "index": 93, "kind": "function", "displayName": "Map Add", "group": "collection", "label": "collection", "required": false, "javaType": "Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Adds the result of the expression to the message body (or expression) which is a map", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "defaultValue" [...]
- "mapRemove(source,key)": { "index": 94, "kind": "function", "displayName": "Map Remove", "group": "collection", "label": "collection", "required": false, "javaType": "Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Removes the result of the expression from the message body (or expression) which is a map", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "defaul [...]
- "max(val...)": { "index": 95, "kind": "function", "displayName": "Maximum Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the maximum number from all the values (integral numbers only).", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "required": false, "defaultValue": "body", "description": "Val [...]
- "messageAs(type)": { "index": 96, "kind": "function", "displayName": "Message As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message to the given type (classname).", "ognl": true, "suffix": "}", "params": [ { "name": "type", "javaType": "String", "required": true, "description": "The target type classname" } ] },
- "messageHistory(boolean)": { "index": 97, "kind": "function", "displayName": "Print Message History", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message history of the current exchange (how it has been routed). This is similar to the route stack-trace message history the error handler logs in case of an unhandled exception. The boolean c [...]
- "messageTimestamp": { "index": 98, "kind": "function", "displayName": "Message Timestamp", "group": "core", "label": "core", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message timestamp (millis since epoc) that this message originates from. Some systems like JMS, Kafka, AWS have a timestamp on the event\/message that Camel received. This method returns the timestamp if a t [...]
- "min(val...)": { "index": 99, "kind": "function", "displayName": "Minimum Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the minimum number from all the values (integral numbers only).", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "required": false, "defaultValue": "body", "description": "Val [...]
- "newEmpty(type)": { "index": 100, "kind": "function", "displayName": "Create Empty Object", "group": "collection", "label": "collection", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Creates a new empty object (decided by type). Use `string` to create an empty String. Use `list` to create an empty `java.util.ArrayList`. Use `map` to create an empty `java.util.LinkedHashMap`. U [...]
- "normalizeWhitespace(exp)": { "index": 101, "kind": "function", "displayName": "Normalize Whitespace", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Normalizes the whitespace in the message body (or expression) by cleaning up excess whitespaces.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": f [...]
- "not": { "index": 102, "kind": "function", "displayName": "Not", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the predicate and returns the opposite.", "ognl": false, "suffix": "}" },
- "null": { "index": 103, "kind": "function", "displayName": "Null", "group": "other", "label": "other", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a null value", "ognl": false, "suffix": "}", "examples": [ "${null} -> null" ] },
- "originalBody": { "index": 104, "kind": "function", "displayName": "Original Body", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The original incoming body (only available if allowUseOriginalMessage=true).", "ognl": false, "suffix": "}" },
- "pad(exp,width,separator)": { "index": 105, "kind": "function", "displayName": "Pad String", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Pads the expression with extra padding if necessary, according to the total width. The separator is by default a space. A positive width pads to the right (after the value), and a negative width pads to [...]
- "pretty(exp)": { "index": 106, "kind": "function", "displayName": "Pretty Print", "group": "xml", "label": "json,xml", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to a String, and attempts to pretty print if JSon or XML, otherwise the expression is returned as the String value.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "O [...]
- "prettyBody": { "index": 107, "kind": "function", "displayName": "Pretty Body", "group": "xml", "label": "json,xml", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to a String, and attempts to pretty print if JSon or XML; otherwise the body is returned as the String value.", "ognl": false, "suffix": "}" },
- "sort(exp,reverse)": { "index": 108, "kind": "function", "displayName": "Sort", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sorts the message body or expression in natural order", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression [...]
- "toPrettyJson(exp)": { "index": 109, "kind": "function", "displayName": "To Pretty JSon", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to JSon String representation.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressio [...]
- "toPrettyJsonBody": { "index": 110, "kind": "function", "displayName": "To Pretty JSon Body", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to JSon String representation.", "ognl": false, "suffix": "}" },
- "toJson(exp)": { "index": 111, "kind": "function", "displayName": "To JSon", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to JSon String representation.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. When omitt [...]
- "toJsonBody": { "index": 112, "kind": "function", "displayName": "To JSon Body", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to JSon String representation.", "ognl": false, "suffix": "}" },
- "properties:key:default": { "index": 113, "kind": "function", "displayName": "Property Placeholder", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Lookup a property placeholder with the given key. If the key does not exist nor has a value, then an optional default value can be specified.", "ognl": false, "suffix": "}", "params": [ { "name": "ke [...]
- "propertiesExist:key": { "index": 114, "kind": "function", "displayName": "Property Placeholder Exists", "group": "core", "label": "core", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Checks whether a property placeholder with the given key exists or not. The result can be negated by prefixing the key with !", "ognl": false, "suffix": "}", "params": [ { "name": "key", "javaTy [...]
- "quote(exp)": { "index": 115, "kind": "function", "displayName": "Quote", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the message body (or expression) as a double quoted string", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressio [...]
- "random(min,max)": { "index": 116, "kind": "function", "displayName": "Random", "group": "number", "label": "number", "required": false, "javaType": "int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a random number between min and max (exclusive)", "ognl": false, "suffix": "}", "params": [ { "name": "min", "javaType": "int", "required": true, "description": "The minimum value (inclusive)" }, { "name": "max" [...]
- "range(min,max)": { "index": 117, "kind": "function", "displayName": "Range", "group": "number", "label": "number", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a list of increasing integers between the given interval (exclusive)", "ognl": false, "suffix": "}", "params": [ { "name": "min", "javaType": "int", "required": true, "description": "The start value (inclusive)" [...]
- "ref:name": { "index": 118, "kind": "function", "displayName": "Bean By Id", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To look up a bean from the Registry with the given name.", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The bean name in the registry" } ], "examples": [...]
- "replace(from,to,exp)": { "index": 119, "kind": "function", "displayName": "Replace String Values", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Replace all the string values in the message body\/expression. To make it easier to replace single and double quotes, then you can use XML escaped values `\\"` as double quote, `\\'` as [...]
- "reverse(val...)": { "index": 120, "kind": "function", "displayName": "Reverse Values", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a list of all the values, but in reverse order", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": false, "defaultValue": "body", "description": "Value [...]
- "routeGroup": { "index": 121, "kind": "function", "displayName": "Route Group", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The route group of the current route the Exchange is being routed. Not all routes have a group assigned, so this may be null.", "ognl": false, "suffix": "}" },
- "routeId": { "index": 122, "kind": "function", "displayName": "Route Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The route id of the current route the Exchange is being routed", "ognl": false, "suffix": "}", "examples": [ "${routeId} -> myRoute" ] },
- "safeQuote(exp)": { "index": 123, "kind": "function", "displayName": "Safe Quote", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the message body (or expression) safely quoted if needed", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The ex [...]
- "setVariable(key,exp)": { "index": 124, "kind": "function", "displayName": "Set Variable", "group": "attachment", "label": "attachment", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets an attachment with payload from the message body\/expression.", "ognl": false, "suffix": "}" },
- "setHeader(name,type,exp)": { "index": 125, "kind": "function", "displayName": "Set Header", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets a message header with the given expression (optional converting to the given type)", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "T [...]
- "setVariable(name,type,exp)": { "index": 126, "kind": "function", "displayName": "Set Variable", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets a variable with the given expression (optional converting to the given type)", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The [...]
- "shuffle(val...)": { "index": 127, "kind": "function", "displayName": "Shuffle Values", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a list of all the values shuffled in random order", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": false, "defaultValue": "body", "description": "Va [...]
- "simpleJsonpath(input,exp)": { "index": 128, "kind": "function", "displayName": "Simple JSonPath", "group": "json", "label": "json", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with JSon data, then this allows using the Simple JSonPath language, for example, to extract data from the message body (in JSon format). For input (optional), you can choose `header:key`, [...]
- "size(exp)": { "index": 129, "kind": "function", "displayName": "Size", "group": "collection", "label": "collection", "required": false, "javaType": "int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the number of elements in collection or array based payloads. If the value is null then 0 is returned, otherwise 1.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": [...]
- "skip(num)": { "index": 130, "kind": "function", "displayName": "Skip First Items from the Message Body", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.Iterator", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The skip function iterates the message body and skips the first number of items. This can be used with the Splitter EIP to split a message body and skip the first N numbe [...]
- "split(exp,separator)": { "index": 131, "kind": "function", "displayName": "Split String Values", "group": "collection", "label": "collection", "required": false, "javaType": "String[]", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Splits the message body\/expression as a String value using the separator into a String array", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": [...]
- "stepId": { "index": 132, "kind": "function", "displayName": "Step Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the id of the current step the Exchange is being routed.", "ognl": false, "suffix": "}" },
- "substring(head,tail)": { "index": 133, "kind": "function", "displayName": "Substring", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression by clipping characters off its ends (not by positions). With one number, a positive number clips that many characters from the beginning, and a negative num [...]
- "substringAfter(exp,before)": { "index": 134, "kind": "function", "displayName": "Substring After", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that comes after. Returns null if nothing comes after.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "requi [...]
- "substringBefore(exp,before)": { "index": 135, "kind": "function", "displayName": "Substring Before", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that comes before. Returns null if nothing comes before.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "r [...]
- "substringBetween(exp,after,before)": { "index": 136, "kind": "function", "displayName": "Substring Between", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that are between after and before. Returns null if nothing comes between.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", [...]
- "sum(val...)": { "index": 137, "kind": "function", "displayName": "Calculate Sum Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sums together all the values as integral numbers. This function can also be used to subtract by using negative numbers.", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "requir [...]
- "sys.name": { "index": 138, "kind": "function", "displayName": "JVM System Property", "group": "other", "label": "other", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JVM system property with the given name", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The system property name" } ], "examples": [ "${sy [...]
- "threadId": { "index": 139, "kind": "function", "displayName": "Thread Id", "group": "other", "label": "other", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the id of the current thread. Can be used for logging.", "ognl": false, "suffix": "}" },
- "threadName": { "index": 140, "kind": "function", "displayName": "Thread Name", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the name of the current thread. Can be used for logging.", "ognl": false, "suffix": "}" },
- "throwException(type,msg)": { "index": 141, "kind": "function", "displayName": "Throw Exception", "group": "core", "label": "core", "required": false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Deliberately throws an error. Uses IllegalArgumentException by default if no type is specified (use fully qualified classname).", "ognl": false, "suffix": "}", "params": [ { "name": "type", [...]
- "trim(exp)": { "index": 142, "kind": "function", "displayName": "Trim", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The trim function trims the message body (or expression) by removing all leading and trailing white spaces.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue" [...]
- "type:name.field": { "index": 143, "kind": "function", "displayName": "Java Field Value", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To refer to a type or field by its classname. To refer to a field, you can append .FIELD_NAME. For example, you can refer to the constant field from Exchange as: `org.apache.camel.Exchange.FILE_NAME`", "ognl": [...]
- "kindOfType(exp)": { "index": 144, "kind": "function", "displayName": "Kind of Type", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "What kind of type is the value (null,number,string,boolean,array,object)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": [...]
- "unquote(exp)": { "index": 145, "kind": "function", "displayName": "Unquote", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the message body (or expression) with any leading\/ending quotes removed", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "descriptio [...]
- "uppercase(exp)": { "index": 146, "kind": "function", "displayName": "Uppercase", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Uppercases the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. When omitted [...]
- "uuid(type)": { "index": 147, "kind": "function", "displayName": "Generate UUID", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a UUID using the Camel `UuidGenerator`. You can choose between `default`, `classic`, `short` and `simple` as the type. If no type is given, the default is used. It is also possible to use a custom `UuidGenera [...]
- "val(exp)": { "index": 148, "kind": "function", "displayName": "Value", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the expression as a constant value", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": true, "description": "The constant value expression" } ], "examples": [ "${val(42)} -> 42" [...]
- "variable.name": { "index": 149, "kind": "function", "displayName": "Variable", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The variable with the given name", "ognl": true, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The variable name" } ], "examples": [ "${variable.myVar} -> variable v [...]
- "variableAs(key,type)": { "index": 150, "kind": "function", "displayName": "Variable As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the variable to the given type (classname).", "ognl": false, "suffix": "}", "params": [ { "name": "key", "javaType": "String", "required": true, "description": "The variable name" }, { "name": "type", [...]
- "variables": { "index": 151, "kind": "function", "displayName": "Variables", "group": "core", "label": "core", "required": false, "javaType": "java.util.Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns all the variables from the current Exchange in a Map", "ognl": false, "suffix": "}", "examples": [ "${variables} -> {myVar=value1, count=5}" ] },
- "xpath(input,exp)": { "index": 152, "kind": "function", "displayName": "XPath", "group": "xml", "label": "xml", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with XML data, then this allows using the XPath language, for example, to extract data from the message body (in XML format). This requires having camel-xpath JAR on the classpath. For input (optional), you ca [...]
+ "hostname": { "index": 72, "kind": "function", "displayName": "Hostname", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the local hostname (may be empty if not possible to resolve).", "ognl": false, "suffix": "}", "examples": [ "${hostname} -> myserver.local" ] },
+ "logExchange": { "index": 73, "kind": "function", "displayName": "Log Exchange", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Dumps the exchange for logging purpose (uses `ExchangeFormatter` to format the output).", "ognl": false, "suffix": "}", "examples": [ "${logExchange} -> Exchange[Id: ..., Headers: {...}, Body: Hello]" ] },
+ "htmlClean(exp)": { "index": 74, "kind": "function", "displayName": "Html Clean", "group": "html", "label": "html", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Cleans the HTML to remove unsafe links and JavaScripts from the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", [...]
+ "htmlDecode(exp)": { "index": 75, "kind": "function", "displayName": "Html Decode", "group": "html", "label": "html", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Decodes the HTML as plain text (removing all HTML tags) that is also suitable as input for AI and LLMs", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultVal [...]
+ "htmlParse(exp)": { "index": 76, "kind": "function", "displayName": "Html Parse", "group": "html", "label": "html", "required": false, "javaType": "org.jsoup.nodes.Document", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Parses the HTML as a JSoup object from the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "d [...]
+ "id": { "index": 77, "kind": "function", "displayName": "Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message id", "ognl": false, "suffix": "}" },
+ "iif(predicate,trueExp,falseExp)": { "index": 78, "kind": "function", "displayName": "If Then Else", "group": "condition", "label": "condition", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the predicate and returns the value of trueExp or falseExp. This function is similar to the ternary operator in Java.", "ognl": false, "suffix": "}", "params": [ { "name": "predic [...]
+ "isAlpha(exp)": { "index": 79, "kind": "function", "displayName": "Is Alphabetic Value", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is alphabetic value (A..Z). For more advanced checks use the `regex` operator.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object [...]
+ "isAlphaNumeric(exp)": { "index": 80, "kind": "function", "displayName": "Is Alphabetic-Numeric Value", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is alphanumeric value (A..Z0-9). For more advanced checks use the `regex` operator.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", [...]
+ "isEmpty(exp)": { "index": 81, "kind": "function", "displayName": "Is Empty", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is null or empty (list\/map types are tested if they have 0 elements).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": fals [...]
+ "isNumeric(exp)": { "index": 82, "kind": "function", "displayName": "Is Numeric Value", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is numeric value (0..9). For more advanced checks use the `regex` operator.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", " [...]
+ "jq(input,exp)": { "index": 83, "kind": "function", "displayName": "JQ", "group": "json", "label": "json", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with JSon data, then this allows using the JQ language, for example, to extract data from the message body (in JSon format). This requires having camel-jq JAR on the classpath. For input (optional), you can choose [...]
+ "jsonpath(input,exp)": { "index": 84, "kind": "function", "displayName": "JSonPath", "group": "json", "label": "json", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with JSon data, then this allows using the JSonPath language, for example, to extract data from the message body (in JSon format). This requires having camel-jsonpath JAR on the classpath. For input (op [...]
+ "join(separator,prefix,exp)": { "index": 85, "kind": "function", "displayName": "Join", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The join function iterates the message body\/expression and joins the data into a string. The separator is by default a comma. The prefix is optional. The join uses the message body as source by default. It i [...]
+ "length(exp)": { "index": 86, "kind": "function", "displayName": "Length", "group": "core", "label": "core", "required": false, "javaType": "int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The payload length (number of bytes) of the message body (or expression).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressi [...]
+ "list(val...)": { "index": 87, "kind": "function", "displayName": "Create List of values", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.ArrayList", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The list function creates an ArrayList with the given set of values.", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": true, "description": [...]
+ "listAdd(source,exp)": { "index": 88, "kind": "function", "displayName": "List Add", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Adds the result of the expression to the message body (or expression) which is a list", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "defaultValue" [...]
+ "listRemove(source,exp)": { "index": 89, "kind": "function", "displayName": "List Remove", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Removes the result of the expression from the message body (or expression) which is a list", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "de [...]
+ "load(file)": { "index": 90, "kind": "function", "displayName": "Load", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Loads the content of the resource from classpath (cannot load from file-system to avoid dangerous situations).", "ognl": false, "suffix": "}", "params": [ { "name": "file", "javaType": "String", "required": true, "description": [...]
+ "lowercase(exp)": { "index": 91, "kind": "function", "displayName": "Lowercase", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Lowercases the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. When omitted [...]
+ "mandatoryBodyAs(type)": { "index": 92, "kind": "function", "displayName": "Mandatory Body As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body to the given type (classname). If the body is null then the function will fail with an exception", "ognl": true, "suffix": "}", "params": [ { "name": "type", "javaType": "String" [...]
+ "map(key1,value1,...)": { "index": 93, "kind": "function", "displayName": "Create Map of pairs", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.LinkedHashMap", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The map function creates a LinkedHashMap with the given set of pairs.", "ognl": false, "suffix": "}", "params": [ { "name": "key1", "javaType": "Object", "required": true, "d [...]
+ "mapAdd(source,key,exp)": { "index": 94, "kind": "function", "displayName": "Map Add", "group": "collection", "label": "collection", "required": false, "javaType": "Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Adds the result of the expression to the message body (or expression) which is a map", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "defaultValue" [...]
+ "mapRemove(source,key)": { "index": 95, "kind": "function", "displayName": "Map Remove", "group": "collection", "label": "collection", "required": false, "javaType": "Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Removes the result of the expression from the message body (or expression) which is a map", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "defaul [...]
+ "max(val...)": { "index": 96, "kind": "function", "displayName": "Maximum Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the maximum number from all the values (integral numbers only).", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "required": false, "defaultValue": "body", "description": "Val [...]
+ "messageAs(type)": { "index": 97, "kind": "function", "displayName": "Message As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message to the given type (classname).", "ognl": true, "suffix": "}", "params": [ { "name": "type", "javaType": "String", "required": true, "description": "The target type classname" } ] },
+ "messageHistory(boolean)": { "index": 98, "kind": "function", "displayName": "Print Message History", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message history of the current exchange (how it has been routed). This is similar to the route stack-trace message history the error handler logs in case of an unhandled exception. The boolean c [...]
+ "messageTimestamp": { "index": 99, "kind": "function", "displayName": "Message Timestamp", "group": "core", "label": "core", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message timestamp (millis since epoc) that this message originates from. Some systems like JMS, Kafka, AWS have a timestamp on the event\/message that Camel received. This method returns the timestamp if a t [...]
+ "min(val...)": { "index": 100, "kind": "function", "displayName": "Minimum Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the minimum number from all the values (integral numbers only).", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "required": false, "defaultValue": "body", "description": "Va [...]
+ "newEmpty(type)": { "index": 101, "kind": "function", "displayName": "Create Empty Object", "group": "collection", "label": "collection", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Creates a new empty object (decided by type). Use `string` to create an empty String. Use `list` to create an empty `java.util.ArrayList`. Use `map` to create an empty `java.util.LinkedHashMap`. U [...]
+ "normalizeWhitespace(exp)": { "index": 102, "kind": "function", "displayName": "Normalize Whitespace", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Normalizes the whitespace in the message body (or expression) by cleaning up excess whitespaces.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": f [...]
+ "not(exp)": { "index": 103, "kind": "function", "displayName": "Not", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the predicate and returns the opposite.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The predicate. When omitted [...]
+ "null": { "index": 104, "kind": "function", "displayName": "Null", "group": "other", "label": "other", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a null value", "ognl": false, "suffix": "}", "examples": [ "${null} -> null" ] },
+ "originalBody": { "index": 105, "kind": "function", "displayName": "Original Body", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The original incoming body (only available if allowUseOriginalMessage=true).", "ognl": false, "suffix": "}" },
+ "pad(exp,width,separator)": { "index": 106, "kind": "function", "displayName": "Pad String", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Pads the expression with extra padding if necessary, according to the total width. The separator is by default a space. A positive width pads to the right (after the value), and a negative width pads to [...]
+ "pretty(exp)": { "index": 107, "kind": "function", "displayName": "Pretty Print", "group": "xml", "label": "json,xml", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to a String, and attempts to pretty print if JSon or XML, otherwise the expression is returned as the String value.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "O [...]
+ "prettyBody": { "index": 108, "kind": "function", "displayName": "Pretty Body", "group": "xml", "label": "json,xml", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to a String, and attempts to pretty print if JSon or XML; otherwise the body is returned as the String value.", "ognl": false, "suffix": "}" },
+ "sort(exp,reverse)": { "index": 109, "kind": "function", "displayName": "Sort", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sorts the message body or expression in natural order", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression [...]
+ "toPrettyJson(exp)": { "index": 110, "kind": "function", "displayName": "To Pretty JSon", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to JSon String representation.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressio [...]
+ "toPrettyJsonBody": { "index": 111, "kind": "function", "displayName": "To Pretty JSon Body", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to JSon String representation.", "ognl": false, "suffix": "}" },
+ "toJson(exp)": { "index": 112, "kind": "function", "displayName": "To JSon", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to JSon String representation.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. When omitt [...]
+ "toJsonBody": { "index": 113, "kind": "function", "displayName": "To JSon Body", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to JSon String representation.", "ognl": false, "suffix": "}" },
+ "properties:key:default": { "index": 114, "kind": "function", "displayName": "Property Placeholder", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Lookup a property placeholder with the given key. If the key does not exist nor has a value, then an optional default value can be specified.", "ognl": false, "suffix": "}", "params": [ { "name": "ke [...]
+ "propertiesExist:key": { "index": 115, "kind": "function", "displayName": "Property Placeholder Exists", "group": "core", "label": "core", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Checks whether a property placeholder with the given key exists or not. The result can be negated by prefixing the key with !", "ognl": false, "suffix": "}", "params": [ { "name": "key", "javaTy [...]
+ "quote(exp)": { "index": 116, "kind": "function", "displayName": "Quote", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the message body (or expression) as a double quoted string", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressio [...]
+ "random(min,max)": { "index": 117, "kind": "function", "displayName": "Random", "group": "number", "label": "number", "required": false, "javaType": "int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a random number between min and max (exclusive)", "ognl": false, "suffix": "}", "params": [ { "name": "min", "javaType": "int", "required": true, "description": "The minimum value (inclusive)" }, { "name": "max" [...]
+ "range(min,max)": { "index": 118, "kind": "function", "displayName": "Range", "group": "number", "label": "number", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a list of increasing integers between the given interval (exclusive)", "ognl": false, "suffix": "}", "params": [ { "name": "min", "javaType": "int", "required": true, "description": "The start value (inclusive)" [...]
+ "ref:name": { "index": 119, "kind": "function", "displayName": "Bean By Id", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To look up a bean from the Registry with the given name.", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The bean name in the registry" } ], "examples": [...]
+ "replace(from,to,exp)": { "index": 120, "kind": "function", "displayName": "Replace String Values", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Replace all the string values in the message body\/expression. To make it easier to replace single and double quotes, then you can use XML escaped values `\\"` as double quote, `\\'` as [...]
+ "reverse(val...)": { "index": 121, "kind": "function", "displayName": "Reverse Values", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a list of all the values, but in reverse order", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": false, "defaultValue": "body", "description": "Value [...]
+ "routeGroup": { "index": 122, "kind": "function", "displayName": "Route Group", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The route group of the current route the Exchange is being routed. Not all routes have a group assigned, so this may be null.", "ognl": false, "suffix": "}" },
+ "routeId": { "index": 123, "kind": "function", "displayName": "Route Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The route id of the current route the Exchange is being routed", "ognl": false, "suffix": "}", "examples": [ "${routeId} -> myRoute" ] },
+ "safeQuote(exp)": { "index": 124, "kind": "function", "displayName": "Safe Quote", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the message body (or expression) safely quoted if needed", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The ex [...]
+ "setAttachment(key,exp)": { "index": 125, "kind": "function", "displayName": "Set Attachment", "group": "attachment", "label": "attachment", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets an attachment with payload from the message body\/expression.", "ognl": false, "suffix": "}" },
+ "setHeader(name,type,exp)": { "index": 126, "kind": "function", "displayName": "Set Header", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets a message header with the given expression (optional converting to the given type)", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "T [...]
+ "setVariable(name,type,exp)": { "index": 127, "kind": "function", "displayName": "Set Variable", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets a variable with the given expression (optional converting to the given type)", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The [...]
+ "shuffle(val...)": { "index": 128, "kind": "function", "displayName": "Shuffle Values", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a list of all the values shuffled in random order", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": false, "defaultValue": "body", "description": "Va [...]
+ "simpleJsonpath(input,exp)": { "index": 129, "kind": "function", "displayName": "Simple JSonPath", "group": "json", "label": "json", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with JSon data, then this allows using the Simple JSonPath language, for example, to extract data from the message body (in JSon format). For input (optional), you can choose `header:key`, [...]
+ "size(exp)": { "index": 130, "kind": "function", "displayName": "Size", "group": "collection", "label": "collection", "required": false, "javaType": "int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the number of elements in collection or array based payloads. If the value is null then 0 is returned, otherwise 1.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": [...]
+ "skip(num)": { "index": 131, "kind": "function", "displayName": "Skip First Items from the Message Body", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.Iterator", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The skip function iterates the message body and skips the first number of items. This can be used with the Splitter EIP to split a message body and skip the first N numbe [...]
+ "split(exp,separator)": { "index": 132, "kind": "function", "displayName": "Split String Values", "group": "collection", "label": "collection", "required": false, "javaType": "String[]", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Splits the message body\/expression as a String value using the separator into a String array", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": [...]
+ "stepId": { "index": 133, "kind": "function", "displayName": "Step Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the id of the current step the Exchange is being routed.", "ognl": false, "suffix": "}" },
+ "substring(head,tail)": { "index": 134, "kind": "function", "displayName": "Substring", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression by clipping characters off its ends (not by positions). With one number, a positive number clips that many characters from the beginning, and a negative num [...]
+ "substringAfter(exp,before)": { "index": 135, "kind": "function", "displayName": "Substring After", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that comes after. Returns null if nothing comes after.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "requi [...]
+ "substringBefore(exp,before)": { "index": 136, "kind": "function", "displayName": "Substring Before", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that comes before. Returns null if nothing comes before.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "r [...]
+ "substringBetween(exp,after,before)": { "index": 137, "kind": "function", "displayName": "Substring Between", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that are between after and before. Returns null if nothing comes between.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", [...]
+ "sum(val...)": { "index": 138, "kind": "function", "displayName": "Calculate Sum Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sums together all the values as integral numbers. This function can also be used to subtract by using negative numbers.", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "requir [...]
+ "sys.name": { "index": 139, "kind": "function", "displayName": "JVM System Property", "group": "other", "label": "other", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JVM system property with the given name", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The system property name" } ], "examples": [ "${sy [...]
+ "threadId": { "index": 140, "kind": "function", "displayName": "Thread Id", "group": "other", "label": "other", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the id of the current thread. Can be used for logging.", "ognl": false, "suffix": "}" },
+ "threadName": { "index": 141, "kind": "function", "displayName": "Thread Name", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the name of the current thread. Can be used for logging.", "ognl": false, "suffix": "}" },
+ "throwException(msg,type)": { "index": 142, "kind": "function", "displayName": "Throw Exception", "group": "core", "label": "core", "required": false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Deliberately throws an error. Uses IllegalArgumentException by default if no type is specified (use fully qualified classname).", "ognl": false, "suffix": "}", "params": [ { "name": "msg", [...]
+ "trim(exp)": { "index": 143, "kind": "function", "displayName": "Trim", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The trim function trims the message body (or expression) by removing all leading and trailing white spaces.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue" [...]
+ "type:name.field": { "index": 144, "kind": "function", "displayName": "Java Field Value", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To refer to a type or field by its classname. To refer to a field, you can append .FIELD_NAME. For example, you can refer to the constant field from Exchange as: `org.apache.camel.Exchange.FILE_NAME`", "ognl": [...]
+ "kindOfType(exp)": { "index": 145, "kind": "function", "displayName": "Kind of Type", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "What kind of type is the value (null,number,string,boolean,array,object)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": [...]
+ "unquote(exp)": { "index": 146, "kind": "function", "displayName": "Unquote", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the message body (or expression) with any leading\/ending quotes removed", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "descriptio [...]
+ "uppercase(exp)": { "index": 147, "kind": "function", "displayName": "Uppercase", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Uppercases the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. When omitted [...]
+ "uuid(type)": { "index": 148, "kind": "function", "displayName": "Generate UUID", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a UUID using the Camel `UuidGenerator`. You can choose between `default`, `classic`, `short`, `simple` and `random` as the type. If no type is given, the default is used. It is also possible to use a custom ` [...]
+ "val(exp)": { "index": 149, "kind": "function", "displayName": "Value", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the expression as a constant value", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": true, "description": "The constant value expression" } ], "examples": [ "${val(42)} -> 42" [...]
+ "variable.name": { "index": 150, "kind": "function", "displayName": "Variable", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The variable with the given name", "ognl": true, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The variable name" } ], "examples": [ "${variable.myVar} -> variable v [...]
+ "variableAs(key,type)": { "index": 151, "kind": "function", "displayName": "Variable As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the variable to the given type (classname).", "ognl": false, "suffix": "}", "params": [ { "name": "key", "javaType": "String", "required": true, "description": "The variable name" }, { "name": "type", [...]
+ "variables": { "index": 152, "kind": "function", "displayName": "Variables", "group": "core", "label": "core", "required": false, "javaType": "java.util.Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns all the variables from the current Exchange in a Map", "ognl": false, "suffix": "}", "examples": [ "${variables} -> {myVar=value1, count=5}" ] },
+ "xpath(input,exp)": { "index": 153, "kind": "function", "displayName": "XPath", "group": "xml", "label": "xml", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with XML data, then this allows using the XPath language, for example, to extract data from the message body (in XML format). This requires having camel-xpath JAR on the classpath. For input (optional), you ca [...]
},
"operators": {
"==": { "index": 0, "kind": "operator", "displayName": "Eq", "label": "binary", "required": false, "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Tests equality between left and right operand values. Camel will coerce the right operand type to match the left.", "operatorKind": "binary", "operatorSyntax": "LHS == RHS", "precedence": 10, "examples": [ "${header.foo} == 'bar'", "${header.count} == 5" ] },
diff --git a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/file.json b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/file.json
index 0103a87254b5..90523bcc10d2 100644
--- a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/file.json
+++ b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/file.json
@@ -28,12 +28,12 @@
"functions": {
"file:name": { "index": 0, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (relative from starting directory)", "ognl": false, "suffix": "}" },
"file:name.noext": { "index": 1, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (relative from starting directory) without extension", "ognl": false, "suffix": "}" },
- "file:name.noext.single": { "index": 2, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (relative from starting directory) without extension. If the file name has multiple dots, then this expression strips and only returns the last part.", "ognl": false, "suffix": "}" },
+ "file:name.noext.single": { "index": 2, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (relative from starting directory) without extension. If the file name has multiple dots, then only the last extension is stripped (such as a.tar.gz becomes a.tar).", "ognl": false, "suffix": "}" },
"file:name.ext": { "index": 3, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file extension", "ognl": false, "suffix": "}" },
"file:name.ext.single": { "index": 4, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file extension. If the file extension has multiple dots, then this expression strips and only returns the last part.", "ognl": false, "suffix": "}" },
- "file:onlyname": { "index": 5, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "\u2020he file name (without any leading paths)", "ognl": false, "suffix": "}" },
- "file:onlyname.noext": { "index": 6, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "\u2020he file name (without any leading paths) without extension", "ognl": false, "suffix": "}" },
- "file:onlyname.noext.single": { "index": 7, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "\u2020he file name (without any leading paths) without extension. If the file name has multiple dots, then this expression strips and only returns the last part.", "ognl": false, "suffix": "}" },
+ "file:onlyname": { "index": 5, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (without any leading paths)", "ognl": false, "suffix": "}" },
+ "file:onlyname.noext": { "index": 6, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (without any leading paths) without extension", "ognl": false, "suffix": "}" },
+ "file:onlyname.noext.single": { "index": 7, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file name (without any leading paths) without extension. If the file name has multiple dots, then only the last extension is stripped (such as a.tar.gz becomes a.tar).", "ognl": false, "suffix": "}" },
"file:parent": { "index": 8, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file parent directory (null if no parent directory)", "ognl": false, "suffix": "}" },
"file:path": { "index": 9, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The file path", "ognl": false, "suffix": "}" },
"file:absolute": { "index": 10, "kind": "function", "displayName": "File", "group": "file", "label": "file", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the file is regarded as absolute or relative", "ognl": false, "suffix": "}" },
diff --git a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json
index dfc3d543b094..dfc7242ff7f6 100644
--- a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json
+++ b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json
@@ -27,7 +27,7 @@
},
"functions": {
"abs(exp)": { "index": 0, "kind": "function", "displayName": "Absolute Number", "group": "number", "label": "number", "required": false, "javaType": "Long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body (or expression) to a long number and return the absolute value.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "d [...]
- "assert(exp,msg)": { "index": 1, "kind": "function", "displayName": "Assert", "group": "condition", "label": "condition", "required": false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the expression and throws an exception with the message if the condition is false", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": true, "descr [...]
+ "assert(exp,msg)": { "index": 1, "kind": "function", "displayName": "Assert", "group": "condition", "label": "condition", "required": false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the expression and throws an exception with the message if the condition is false", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": true, "descr [...]
"a2a:emit(message)": { "index": 2, "kind": "function", "displayName": "A2A Emit Progress", "group": "ai", "label": "a2a,ai", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Emits an A2A task progress update with WORKING state. Requires the camel-a2a component on the classpath and an active A2A task context.", "ognl": false, "suffix": "}", "params": [ { "name": "message", "javaTyp [...]
"a2a:emit(state,message)": { "index": 3, "kind": "function", "displayName": "A2A Emit Progress State", "group": "ai", "label": "a2a,ai", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Emits an A2A task progress update with the given task state. Requires the camel-a2a component on the classpath and an active A2A task context.", "ognl": false, "suffix": "}", "params": [ { "name": [...]
"a2a:text": { "index": 4, "kind": "function", "displayName": "A2A Text", "group": "ai", "label": "a2a,ai", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Extracts TextPart content from an A2A Task or Message in the message body.", "ognl": false, "suffix": "}", "examples": [ "${a2a:text}" ] },
@@ -63,7 +63,7 @@
"average(val...)": { "index": 34, "kind": "function", "displayName": "Average Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the average number from all the values (integral numbers only).", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "required": false, "defaultValue": "body", "description": [...]
"base64Decode(exp)": { "index": 35, "kind": "function", "displayName": "Base64 Decode", "group": "base64", "label": "base64", "required": false, "javaType": "byte[]", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Base64 decodes the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. Wh [...]
"base64Encode(exp)": { "index": 36, "kind": "function", "displayName": "Base64 Encode", "group": "base64", "label": "base64", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Base64 encodes the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. Wh [...]
- "bean(name.method)": { "index": 37, "kind": "function", "displayName": "Call Java Bean", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Calls a Java bean. The name of the bean can also refer to a class name using type prefix as follows `bean:type:com.foo.MyClass`. If no method name is given then Camel will automatic attempt to find the best meth [...]
+ "bean(name.method)": { "index": 37, "kind": "function", "displayName": "Call Java Bean", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Calls a Java bean. The name of the bean can also refer to a class name using type prefix as follows `bean:type:com.foo.MyClass`. If no method name is given then Camel will automatic attempt to find the best meth [...]
"body": { "index": 38, "kind": "function", "displayName": "Body", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message body", "ognl": true, "suffix": "}", "examples": [ "${body} -> Hello World \/\/ when body is the string 'Hello World'" ] },
"bodyAs(type)": { "index": 39, "kind": "function", "displayName": "Body As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body to the given type (classname).", "ognl": true, "suffix": "}", "params": [ { "name": "type", "javaType": "String", "required": true, "description": "The target type classname (e.g. String, int, byte [...]
"bodyOneLine": { "index": 40, "kind": "function", "displayName": "Body One Line", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to a String and removes all line-breaks, so the string is in one line.", "ognl": false, "suffix": "}", "examples": [ "${bodyOneLine} -> Hello World \/\/ when body is 'Hello\\nWorld'" ] },
@@ -71,13 +71,13 @@
"camelContext": { "index": 42, "kind": "function", "displayName": "Camel Context", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Camel Context", "ognl": true, "suffix": "}" },
"camelId": { "index": 43, "kind": "function", "displayName": "Camel Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the CamelContext", "ognl": false, "suffix": "}", "examples": [ "${camelId} -> camel-1" ] },
"capitalize(exp)": { "index": 44, "kind": "function", "displayName": "Capitalize String Values", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Capitalizes the message body\/expression as a String value (upper case every words)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue [...]
- "ceil(exp)": { "index": 45, "kind": "function", "displayName": "Ceil Number", "group": "number", "label": "number", "required": false, "javaType": "Integer", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body (or expression) to a floating number and return the ceil value (rounded up to nearest integer).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": [...]
+ "ceil(exp)": { "index": 45, "kind": "function", "displayName": "Ceil Number", "group": "number", "label": "number", "required": false, "javaType": "Long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body (or expression) to a floating number and return the ceil value (rounded up to nearest integer).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": fal [...]
"clearAttachments": { "index": 46, "kind": "function", "displayName": "Clear Attachments", "group": "attachment", "label": "attachment", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Removes all existing attachments on the message.", "ognl": false, "suffix": "}" },
"collate(num)": { "index": 47, "kind": "function", "displayName": "Group Message Body into Sub Lists", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.Iterator", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The collate function iterates the message body and groups the data into sub lists of specified size. This can be used with the Splitter EIP to split a message body and group [...]
"concat(exp,exp,separator)": { "index": 48, "kind": "function", "displayName": "Concat", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Performs a string concat using two expressions (message body as default) with optional separator", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": true, "descript [...]
"convertTo(exp,type)": { "index": 49, "kind": "function", "displayName": "Convert To", "group": "core", "label": "core", "required": false, "javaType": "", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body (or expression) to the specified type.", "ognl": true, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressio [...]
"contains(exp,text)": { "index": 50, "kind": "function", "displayName": "Contains", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns true if the message body (or expression) contains part of the text (ignore case)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue" [...]
- "date(command)": { "index": 51, "kind": "function", "displayName": "Parse Date", "group": "date", "label": "date", "required": false, "javaType": "java.util.Date", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates to a java.util.Date object. Supported commands are: `now` for current timestamp, `millis` for current timestamp in millis (unix epoch), `exchangeCreated` for the timestamp when the current exchange was [...]
+ "date(command)": { "index": 51, "kind": "function", "displayName": "Parse Date", "group": "date", "label": "date", "required": false, "javaType": "java.util.Date", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates to a java.util.Date object. Supported commands are: `now` for current timestamp, `millis` for current timestamp in millis (unix epoch), `exchangeCreated` for the timestamp when the current exchange was [...]
"date-with-timezone(command:timezone:pattern)": { "index": 52, "kind": "function", "displayName": "Date Formatter", "group": "date", "label": "date", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Formats the date to a String using the given date pattern, and with support for timezone. Supported commands are: `now` for current timestamp, `exchangeCreated` for the timestamp when [...]
"distinct(val...)": { "index": 53, "kind": "function", "displayName": "Distinct Values", "group": "collection", "label": "collection", "required": false, "javaType": "Set", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a set of all the values with duplicates removed", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": false, "defaultValue": "body", "description": "Valu [...]
"empty(type)": { "index": 54, "kind": "function", "displayName": "Create Empty Object", "group": "collection", "label": "collection", "required": false, "javaType": "Object", "prefix": "${", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "description": "Creates a new empty object (decided by type). Use `string` to create an empty String. Use `list` to create an empty `java.util.ArrayList`. Use `map` to create an empty `java.util.LinkedHashMap`. Use `s [...]
@@ -88,97 +88,98 @@
"exchangeProperty.name": { "index": 59, "kind": "function", "displayName": "Exchange Property", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exchange property with the given name", "ognl": true, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The exchange property name" } ], "examples": [...]
"exception": { "index": 60, "kind": "function", "displayName": "Exception", "group": "core", "label": "core", "required": false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exception object on the exchange (also from caught exceptions), is null if no exception present.", "ognl": true, "suffix": "}" },
"exception.message": { "index": 61, "kind": "function", "displayName": "Exception Message", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exception message (also from caught exceptions), is null if no exception present.", "ognl": false, "suffix": "}", "examples": [ "${exception.message} -> Connection refused" ] },
- "exception.stackTrace": { "index": 62, "kind": "function", "displayName": "Exception Stacktrace", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exception stacktrace (also from caught exceptions), is null if no exception present.", "ognl": false, "suffix": "}" },
+ "exception.stacktrace": { "index": 62, "kind": "function", "displayName": "Exception Stacktrace", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The exception stacktrace (also from caught exceptions), is null if no exception present.", "ognl": false, "suffix": "}" },
"filter(exp,fun)": { "index": 63, "kind": "function", "displayName": "Filter Elements", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a List containing the values that satisfy the predicate function (returning true)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultVa [...]
"forEach(exp,fun)": { "index": 64, "kind": "function", "displayName": "For Each call Function", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a List containing the values returned by the function when applied to each value from the input expression", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Objec [...]
- "floor(exp)": { "index": 65, "kind": "function", "displayName": "Floor Number", "group": "number", "label": "number", "required": false, "javaType": "Integer", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body (or expression) to a floating number and return the floor value (rounded down to nearest integer).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "requir [...]
+ "floor(exp)": { "index": 65, "kind": "function", "displayName": "Floor Number", "group": "number", "label": "number", "required": false, "javaType": "Long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body (or expression) to a floating number and return the floor value (rounded down to nearest integer).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required" [...]
"fromRouteId": { "index": 66, "kind": "function", "displayName": "From Route Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The original route id where this exchange was created.", "ognl": false, "suffix": "}", "examples": [ "${fromRouteId} -> myRoute" ] },
"function(name,exp)": { "index": 67, "kind": "function", "displayName": "Invoke Custom Function", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Invokes a custom function with the given name using the message body (or expression) as input parameter.", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": t [...]
"hash(exp,algorithm)": { "index": 68, "kind": "function", "displayName": "Compute Hash Value", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a hashed value (string in hex decimal) of the message body\/expression using JDK MessageDigest. The algorithm can be SHA-256 (default) or SHA3-256.", "ognl": false, "suffix": "}", "params": [ { " [...]
"header.name": { "index": 69, "kind": "function", "displayName": "Header", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message header with the given name", "ognl": true, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The header name" } ], "examples": [ "${header.ContentType} -> applica [...]
"headerAs(key,type)": { "index": 70, "kind": "function", "displayName": "Header As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message header to the given type (classname).", "ognl": false, "suffix": "}", "params": [ { "name": "key", "javaType": "String", "required": true, "description": "The header name" }, { "name": "type", " [...]
"headers": { "index": 71, "kind": "function", "displayName": "Headers", "group": "core", "label": "core", "required": false, "javaType": "java.util.Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns all the message headers in a Map", "ognl": false, "suffix": "}", "examples": [ "${headers} -> {ContentType=application\/json, CamelFileName=data.txt}" ] },
- "hostName": { "index": 72, "kind": "function", "displayName": "Host Name", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the local hostname (may be empty if not possible to resolve).", "ognl": false, "suffix": "}", "examples": [ "${hostName} -> myserver.local" ] },
- "htmlClean(exp)": { "index": 73, "kind": "function", "displayName": "Html Clean", "group": "html", "label": "html", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Cleans the HTML to remove unsafe links and JavaScripts from the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", [...]
- "htmlDecode(exp)": { "index": 74, "kind": "function", "displayName": "Html Decode", "group": "html", "label": "html", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Decodes the HTML as plain text (removing all HTML tags) that is also suitable as input for AI and LLMs", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultVal [...]
- "htmlParse(exp)": { "index": 75, "kind": "function", "displayName": "Html Parse", "group": "html", "label": "html", "required": false, "javaType": "org.jsoup.nodes.Document", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Parses the HTML as a JSoup object from the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "d [...]
- "id": { "index": 76, "kind": "function", "displayName": "Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message id", "ognl": false, "suffix": "}" },
- "iif(predicate,trueExp,falseExp)": { "index": 77, "kind": "function", "displayName": "If Then Else", "group": "condition", "label": "condition", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the predicate and returns the value of trueExp or falseExp. This function is similar to the ternary operator in Java.", "ognl": false, "suffix": "}", "params": [ { "name": "predic [...]
- "isAlpha(exp)": { "index": 78, "kind": "function", "displayName": "Is Alphabetic Value", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is alphabetic value (A..Z). For more advanced checks use the `regex` operator.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object [...]
- "isAlphaNumeric(exp)": { "index": 79, "kind": "function", "displayName": "Is Alphabetic-Numeric Value", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is alphanumeric value (A..Z0-9). For more advanced checks use the `regex` operator.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", [...]
- "isEmpty(exp)": { "index": 80, "kind": "function", "displayName": "Is Empty", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is null or empty (list\/map types are tested if they have 0 elements).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": fals [...]
- "isNumeric(exp)": { "index": 81, "kind": "function", "displayName": "Is Numeric Value", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is numeric value (0..9). For more advanced checks use the `regex` operator.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", " [...]
- "jq(input,exp)": { "index": 82, "kind": "function", "displayName": "JQ", "group": "json", "label": "json", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with JSon data, then this allows using the JQ language, for example, to extract data from the message body (in JSon format). This requires having camel-jq JAR on the classpath. For input (optional), you can choose [...]
- "jsonpath(input,exp)": { "index": 83, "kind": "function", "displayName": "JSonPath", "group": "json", "label": "json", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with JSon data, then this allows using the JSonPath language, for example, to extract data from the message body (in JSon format). This requires having camel-jsonpath JAR on the classpath. For input (op [...]
- "join(separator,prefix,exp)": { "index": 84, "kind": "function", "displayName": "Join", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The join function iterates the message body\/expression and joins the data into a string. The separator is by default a comma. The prefix is optional. The join uses the message body as source by default. It i [...]
- "length(exp)": { "index": 85, "kind": "function", "displayName": "Length", "group": "core", "label": "core", "required": false, "javaType": "int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The payload length (number of bytes) of the message body (or expression).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressi [...]
- "list(val...)": { "index": 86, "kind": "function", "displayName": "Create List of values", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.ArrayList", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The list function creates an ArrayList with the given set of values.", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": true, "description": [...]
- "listAdd(source,exp)": { "index": 87, "kind": "function", "displayName": "List Add", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Adds the result of the expression to the message body (or expression) which is a list", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "defaultValue" [...]
- "listRemove(source,exp)": { "index": 88, "kind": "function", "displayName": "List Remove", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Removes the result of the expression from the message body (or expression) which is a list", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "de [...]
- "load(file)": { "index": 89, "kind": "function", "displayName": "Load", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Loads the content of the resource from classpath (cannot load from file-system to avoid dangerous situations).", "ognl": false, "suffix": "}", "params": [ { "name": "file", "javaType": "String", "required": true, "description": [...]
- "lowercase(exp)": { "index": 90, "kind": "function", "displayName": "Lowercase", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Lowercases the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. When omitted [...]
- "mandatoryBodyAs(type)": { "index": 91, "kind": "function", "displayName": "Mandatory Body As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body to the given type (classname). If the body is null then the function will fail with an exception", "ognl": true, "suffix": "}", "params": [ { "name": "type", "javaType": "String" [...]
- "map(key1,value1,...)": { "index": 92, "kind": "function", "displayName": "Create Map of pairs", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.LinkedHashMap", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The map function creates a LinkedHashMap with the given set of pairs.", "ognl": false, "suffix": "}", "params": [ { "name": "key1", "javaType": "Object", "required": true, "d [...]
- "mapAdd(source,key,exp)": { "index": 93, "kind": "function", "displayName": "Map Add", "group": "collection", "label": "collection", "required": false, "javaType": "Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Adds the result of the expression to the message body (or expression) which is a map", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "defaultValue" [...]
- "mapRemove(source,key)": { "index": 94, "kind": "function", "displayName": "Map Remove", "group": "collection", "label": "collection", "required": false, "javaType": "Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Removes the result of the expression from the message body (or expression) which is a map", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "defaul [...]
- "max(val...)": { "index": 95, "kind": "function", "displayName": "Maximum Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the maximum number from all the values (integral numbers only).", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "required": false, "defaultValue": "body", "description": "Val [...]
- "messageAs(type)": { "index": 96, "kind": "function", "displayName": "Message As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message to the given type (classname).", "ognl": true, "suffix": "}", "params": [ { "name": "type", "javaType": "String", "required": true, "description": "The target type classname" } ] },
- "messageHistory(boolean)": { "index": 97, "kind": "function", "displayName": "Print Message History", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message history of the current exchange (how it has been routed). This is similar to the route stack-trace message history the error handler logs in case of an unhandled exception. The boolean c [...]
- "messageTimestamp": { "index": 98, "kind": "function", "displayName": "Message Timestamp", "group": "core", "label": "core", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message timestamp (millis since epoc) that this message originates from. Some systems like JMS, Kafka, AWS have a timestamp on the event\/message that Camel received. This method returns the timestamp if a t [...]
- "min(val...)": { "index": 99, "kind": "function", "displayName": "Minimum Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the minimum number from all the values (integral numbers only).", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "required": false, "defaultValue": "body", "description": "Val [...]
- "newEmpty(type)": { "index": 100, "kind": "function", "displayName": "Create Empty Object", "group": "collection", "label": "collection", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Creates a new empty object (decided by type). Use `string` to create an empty String. Use `list` to create an empty `java.util.ArrayList`. Use `map` to create an empty `java.util.LinkedHashMap`. U [...]
- "normalizeWhitespace(exp)": { "index": 101, "kind": "function", "displayName": "Normalize Whitespace", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Normalizes the whitespace in the message body (or expression) by cleaning up excess whitespaces.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": f [...]
- "not": { "index": 102, "kind": "function", "displayName": "Not", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the predicate and returns the opposite.", "ognl": false, "suffix": "}" },
- "null": { "index": 103, "kind": "function", "displayName": "Null", "group": "other", "label": "other", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a null value", "ognl": false, "suffix": "}", "examples": [ "${null} -> null" ] },
- "originalBody": { "index": 104, "kind": "function", "displayName": "Original Body", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The original incoming body (only available if allowUseOriginalMessage=true).", "ognl": false, "suffix": "}" },
- "pad(exp,width,separator)": { "index": 105, "kind": "function", "displayName": "Pad String", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Pads the expression with extra padding if necessary, according to the total width. The separator is by default a space. A positive width pads to the right (after the value), and a negative width pads to [...]
- "pretty(exp)": { "index": 106, "kind": "function", "displayName": "Pretty Print", "group": "xml", "label": "json,xml", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to a String, and attempts to pretty print if JSon or XML, otherwise the expression is returned as the String value.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "O [...]
- "prettyBody": { "index": 107, "kind": "function", "displayName": "Pretty Body", "group": "xml", "label": "json,xml", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to a String, and attempts to pretty print if JSon or XML; otherwise the body is returned as the String value.", "ognl": false, "suffix": "}" },
- "sort(exp,reverse)": { "index": 108, "kind": "function", "displayName": "Sort", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sorts the message body or expression in natural order", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression [...]
- "toPrettyJson(exp)": { "index": 109, "kind": "function", "displayName": "To Pretty JSon", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to JSon String representation.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressio [...]
- "toPrettyJsonBody": { "index": 110, "kind": "function", "displayName": "To Pretty JSon Body", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to JSon String representation.", "ognl": false, "suffix": "}" },
- "toJson(exp)": { "index": 111, "kind": "function", "displayName": "To JSon", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to JSon String representation.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. When omitt [...]
- "toJsonBody": { "index": 112, "kind": "function", "displayName": "To JSon Body", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to JSon String representation.", "ognl": false, "suffix": "}" },
- "properties:key:default": { "index": 113, "kind": "function", "displayName": "Property Placeholder", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Lookup a property placeholder with the given key. If the key does not exist nor has a value, then an optional default value can be specified.", "ognl": false, "suffix": "}", "params": [ { "name": "ke [...]
- "propertiesExist:key": { "index": 114, "kind": "function", "displayName": "Property Placeholder Exists", "group": "core", "label": "core", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Checks whether a property placeholder with the given key exists or not. The result can be negated by prefixing the key with !", "ognl": false, "suffix": "}", "params": [ { "name": "key", "javaTy [...]
- "quote(exp)": { "index": 115, "kind": "function", "displayName": "Quote", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the message body (or expression) as a double quoted string", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressio [...]
- "random(min,max)": { "index": 116, "kind": "function", "displayName": "Random", "group": "number", "label": "number", "required": false, "javaType": "int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a random number between min and max (exclusive)", "ognl": false, "suffix": "}", "params": [ { "name": "min", "javaType": "int", "required": true, "description": "The minimum value (inclusive)" }, { "name": "max" [...]
- "range(min,max)": { "index": 117, "kind": "function", "displayName": "Range", "group": "number", "label": "number", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a list of increasing integers between the given interval (exclusive)", "ognl": false, "suffix": "}", "params": [ { "name": "min", "javaType": "int", "required": true, "description": "The start value (inclusive)" [...]
- "ref:name": { "index": 118, "kind": "function", "displayName": "Bean By Id", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To look up a bean from the Registry with the given name.", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The bean name in the registry" } ], "examples": [...]
- "replace(from,to,exp)": { "index": 119, "kind": "function", "displayName": "Replace String Values", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Replace all the string values in the message body\/expression. To make it easier to replace single and double quotes, then you can use XML escaped values `\\"` as double quote, `\\'` as [...]
- "reverse(val...)": { "index": 120, "kind": "function", "displayName": "Reverse Values", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a list of all the values, but in reverse order", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": false, "defaultValue": "body", "description": "Value [...]
- "routeGroup": { "index": 121, "kind": "function", "displayName": "Route Group", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The route group of the current route the Exchange is being routed. Not all routes have a group assigned, so this may be null.", "ognl": false, "suffix": "}" },
- "routeId": { "index": 122, "kind": "function", "displayName": "Route Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The route id of the current route the Exchange is being routed", "ognl": false, "suffix": "}", "examples": [ "${routeId} -> myRoute" ] },
- "safeQuote(exp)": { "index": 123, "kind": "function", "displayName": "Safe Quote", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the message body (or expression) safely quoted if needed", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The ex [...]
- "setVariable(key,exp)": { "index": 124, "kind": "function", "displayName": "Set Variable", "group": "attachment", "label": "attachment", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets an attachment with payload from the message body\/expression.", "ognl": false, "suffix": "}" },
- "setHeader(name,type,exp)": { "index": 125, "kind": "function", "displayName": "Set Header", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets a message header with the given expression (optional converting to the given type)", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "T [...]
- "setVariable(name,type,exp)": { "index": 126, "kind": "function", "displayName": "Set Variable", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets a variable with the given expression (optional converting to the given type)", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The [...]
- "shuffle(val...)": { "index": 127, "kind": "function", "displayName": "Shuffle Values", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a list of all the values shuffled in random order", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": false, "defaultValue": "body", "description": "Va [...]
- "simpleJsonpath(input,exp)": { "index": 128, "kind": "function", "displayName": "Simple JSonPath", "group": "json", "label": "json", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with JSon data, then this allows using the Simple JSonPath language, for example, to extract data from the message body (in JSon format). For input (optional), you can choose `header:key`, [...]
- "size(exp)": { "index": 129, "kind": "function", "displayName": "Size", "group": "collection", "label": "collection", "required": false, "javaType": "int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the number of elements in collection or array based payloads. If the value is null then 0 is returned, otherwise 1.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": [...]
- "skip(num)": { "index": 130, "kind": "function", "displayName": "Skip First Items from the Message Body", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.Iterator", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The skip function iterates the message body and skips the first number of items. This can be used with the Splitter EIP to split a message body and skip the first N numbe [...]
- "split(exp,separator)": { "index": 131, "kind": "function", "displayName": "Split String Values", "group": "collection", "label": "collection", "required": false, "javaType": "String[]", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Splits the message body\/expression as a String value using the separator into a String array", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": [...]
- "stepId": { "index": 132, "kind": "function", "displayName": "Step Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the id of the current step the Exchange is being routed.", "ognl": false, "suffix": "}" },
- "substring(head,tail)": { "index": 133, "kind": "function", "displayName": "Substring", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression by clipping characters off its ends (not by positions). With one number, a positive number clips that many characters from the beginning, and a negative num [...]
- "substringAfter(exp,before)": { "index": 134, "kind": "function", "displayName": "Substring After", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that comes after. Returns null if nothing comes after.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "requi [...]
- "substringBefore(exp,before)": { "index": 135, "kind": "function", "displayName": "Substring Before", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that comes before. Returns null if nothing comes before.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "r [...]
- "substringBetween(exp,after,before)": { "index": 136, "kind": "function", "displayName": "Substring Between", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that are between after and before. Returns null if nothing comes between.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", [...]
- "sum(val...)": { "index": 137, "kind": "function", "displayName": "Calculate Sum Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sums together all the values as integral numbers. This function can also be used to subtract by using negative numbers.", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "requir [...]
- "sys.name": { "index": 138, "kind": "function", "displayName": "JVM System Property", "group": "other", "label": "other", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JVM system property with the given name", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The system property name" } ], "examples": [ "${sy [...]
- "threadId": { "index": 139, "kind": "function", "displayName": "Thread Id", "group": "other", "label": "other", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the id of the current thread. Can be used for logging.", "ognl": false, "suffix": "}" },
- "threadName": { "index": 140, "kind": "function", "displayName": "Thread Name", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the name of the current thread. Can be used for logging.", "ognl": false, "suffix": "}" },
- "throwException(type,msg)": { "index": 141, "kind": "function", "displayName": "Throw Exception", "group": "core", "label": "core", "required": false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Deliberately throws an error. Uses IllegalArgumentException by default if no type is specified (use fully qualified classname).", "ognl": false, "suffix": "}", "params": [ { "name": "type", [...]
- "trim(exp)": { "index": 142, "kind": "function", "displayName": "Trim", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The trim function trims the message body (or expression) by removing all leading and trailing white spaces.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue" [...]
- "type:name.field": { "index": 143, "kind": "function", "displayName": "Java Field Value", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To refer to a type or field by its classname. To refer to a field, you can append .FIELD_NAME. For example, you can refer to the constant field from Exchange as: `org.apache.camel.Exchange.FILE_NAME`", "ognl": [...]
- "kindOfType(exp)": { "index": 144, "kind": "function", "displayName": "Kind of Type", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "What kind of type is the value (null,number,string,boolean,array,object)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": [...]
- "unquote(exp)": { "index": 145, "kind": "function", "displayName": "Unquote", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the message body (or expression) with any leading\/ending quotes removed", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "descriptio [...]
- "uppercase(exp)": { "index": 146, "kind": "function", "displayName": "Uppercase", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Uppercases the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. When omitted [...]
- "uuid(type)": { "index": 147, "kind": "function", "displayName": "Generate UUID", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a UUID using the Camel `UuidGenerator`. You can choose between `default`, `classic`, `short` and `simple` as the type. If no type is given, the default is used. It is also possible to use a custom `UuidGenera [...]
- "val(exp)": { "index": 148, "kind": "function", "displayName": "Value", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the expression as a constant value", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": true, "description": "The constant value expression" } ], "examples": [ "${val(42)} -> 42" [...]
- "variable.name": { "index": 149, "kind": "function", "displayName": "Variable", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The variable with the given name", "ognl": true, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The variable name" } ], "examples": [ "${variable.myVar} -> variable v [...]
- "variableAs(key,type)": { "index": 150, "kind": "function", "displayName": "Variable As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the variable to the given type (classname).", "ognl": false, "suffix": "}", "params": [ { "name": "key", "javaType": "String", "required": true, "description": "The variable name" }, { "name": "type", [...]
- "variables": { "index": 151, "kind": "function", "displayName": "Variables", "group": "core", "label": "core", "required": false, "javaType": "java.util.Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns all the variables from the current Exchange in a Map", "ognl": false, "suffix": "}", "examples": [ "${variables} -> {myVar=value1, count=5}" ] },
- "xpath(input,exp)": { "index": 152, "kind": "function", "displayName": "XPath", "group": "xml", "label": "xml", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with XML data, then this allows using the XPath language, for example, to extract data from the message body (in XML format). This requires having camel-xpath JAR on the classpath. For input (optional), you ca [...]
+ "hostname": { "index": 72, "kind": "function", "displayName": "Hostname", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the local hostname (may be empty if not possible to resolve).", "ognl": false, "suffix": "}", "examples": [ "${hostname} -> myserver.local" ] },
+ "logExchange": { "index": 73, "kind": "function", "displayName": "Log Exchange", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Dumps the exchange for logging purpose (uses `ExchangeFormatter` to format the output).", "ognl": false, "suffix": "}", "examples": [ "${logExchange} -> Exchange[Id: ..., Headers: {...}, Body: Hello]" ] },
+ "htmlClean(exp)": { "index": 74, "kind": "function", "displayName": "Html Clean", "group": "html", "label": "html", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Cleans the HTML to remove unsafe links and JavaScripts from the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", [...]
+ "htmlDecode(exp)": { "index": 75, "kind": "function", "displayName": "Html Decode", "group": "html", "label": "html", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Decodes the HTML as plain text (removing all HTML tags) that is also suitable as input for AI and LLMs", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultVal [...]
+ "htmlParse(exp)": { "index": 76, "kind": "function", "displayName": "Html Parse", "group": "html", "label": "html", "required": false, "javaType": "org.jsoup.nodes.Document", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Parses the HTML as a JSoup object from the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "d [...]
+ "id": { "index": 77, "kind": "function", "displayName": "Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message id", "ognl": false, "suffix": "}" },
+ "iif(predicate,trueExp,falseExp)": { "index": 78, "kind": "function", "displayName": "If Then Else", "group": "condition", "label": "condition", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the predicate and returns the value of trueExp or falseExp. This function is similar to the ternary operator in Java.", "ognl": false, "suffix": "}", "params": [ { "name": "predic [...]
+ "isAlpha(exp)": { "index": 79, "kind": "function", "displayName": "Is Alphabetic Value", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is alphabetic value (A..Z). For more advanced checks use the `regex` operator.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object [...]
+ "isAlphaNumeric(exp)": { "index": 80, "kind": "function", "displayName": "Is Alphabetic-Numeric Value", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is alphanumeric value (A..Z0-9). For more advanced checks use the `regex` operator.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", [...]
+ "isEmpty(exp)": { "index": 81, "kind": "function", "displayName": "Is Empty", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is null or empty (list\/map types are tested if they have 0 elements).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": fals [...]
+ "isNumeric(exp)": { "index": 82, "kind": "function", "displayName": "Is Numeric Value", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Whether the message body (or expression) is numeric value (0..9). For more advanced checks use the `regex` operator.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", " [...]
+ "jq(input,exp)": { "index": 83, "kind": "function", "displayName": "JQ", "group": "json", "label": "json", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with JSon data, then this allows using the JQ language, for example, to extract data from the message body (in JSon format). This requires having camel-jq JAR on the classpath. For input (optional), you can choose [...]
+ "jsonpath(input,exp)": { "index": 84, "kind": "function", "displayName": "JSonPath", "group": "json", "label": "json", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with JSon data, then this allows using the JSonPath language, for example, to extract data from the message body (in JSon format). This requires having camel-jsonpath JAR on the classpath. For input (op [...]
+ "join(separator,prefix,exp)": { "index": 85, "kind": "function", "displayName": "Join", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The join function iterates the message body\/expression and joins the data into a string. The separator is by default a comma. The prefix is optional. The join uses the message body as source by default. It i [...]
+ "length(exp)": { "index": 86, "kind": "function", "displayName": "Length", "group": "core", "label": "core", "required": false, "javaType": "int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The payload length (number of bytes) of the message body (or expression).", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressi [...]
+ "list(val...)": { "index": 87, "kind": "function", "displayName": "Create List of values", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.ArrayList", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The list function creates an ArrayList with the given set of values.", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": true, "description": [...]
+ "listAdd(source,exp)": { "index": 88, "kind": "function", "displayName": "List Add", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Adds the result of the expression to the message body (or expression) which is a list", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "defaultValue" [...]
+ "listRemove(source,exp)": { "index": 89, "kind": "function", "displayName": "List Remove", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Removes the result of the expression from the message body (or expression) which is a list", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "de [...]
+ "load(file)": { "index": 90, "kind": "function", "displayName": "Load", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Loads the content of the resource from classpath (cannot load from file-system to avoid dangerous situations).", "ognl": false, "suffix": "}", "params": [ { "name": "file", "javaType": "String", "required": true, "description": [...]
+ "lowercase(exp)": { "index": 91, "kind": "function", "displayName": "Lowercase", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Lowercases the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. When omitted [...]
+ "mandatoryBodyAs(type)": { "index": 92, "kind": "function", "displayName": "Mandatory Body As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message body to the given type (classname). If the body is null then the function will fail with an exception", "ognl": true, "suffix": "}", "params": [ { "name": "type", "javaType": "String" [...]
+ "map(key1,value1,...)": { "index": 93, "kind": "function", "displayName": "Create Map of pairs", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.LinkedHashMap", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The map function creates a LinkedHashMap with the given set of pairs.", "ognl": false, "suffix": "}", "params": [ { "name": "key1", "javaType": "Object", "required": true, "d [...]
+ "mapAdd(source,key,exp)": { "index": 94, "kind": "function", "displayName": "Map Add", "group": "collection", "label": "collection", "required": false, "javaType": "Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Adds the result of the expression to the message body (or expression) which is a map", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "defaultValue" [...]
+ "mapRemove(source,key)": { "index": 95, "kind": "function", "displayName": "Map Remove", "group": "collection", "label": "collection", "required": false, "javaType": "Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Removes the result of the expression from the message body (or expression) which is a map", "ognl": false, "suffix": "}", "params": [ { "name": "source", "javaType": "Object", "required": false, "defaul [...]
+ "max(val...)": { "index": 96, "kind": "function", "displayName": "Maximum Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the maximum number from all the values (integral numbers only).", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "required": false, "defaultValue": "body", "description": "Val [...]
+ "messageAs(type)": { "index": 97, "kind": "function", "displayName": "Message As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the message to the given type (classname).", "ognl": true, "suffix": "}", "params": [ { "name": "type", "javaType": "String", "required": true, "description": "The target type classname" } ] },
+ "messageHistory(boolean)": { "index": 98, "kind": "function", "displayName": "Print Message History", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message history of the current exchange (how it has been routed). This is similar to the route stack-trace message history the error handler logs in case of an unhandled exception. The boolean c [...]
+ "messageTimestamp": { "index": 99, "kind": "function", "displayName": "Message Timestamp", "group": "core", "label": "core", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The message timestamp (millis since epoc) that this message originates from. Some systems like JMS, Kafka, AWS have a timestamp on the event\/message that Camel received. This method returns the timestamp if a t [...]
+ "min(val...)": { "index": 100, "kind": "function", "displayName": "Minimum Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the minimum number from all the values (integral numbers only).", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "required": false, "defaultValue": "body", "description": "Va [...]
+ "newEmpty(type)": { "index": 101, "kind": "function", "displayName": "Create Empty Object", "group": "collection", "label": "collection", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Creates a new empty object (decided by type). Use `string` to create an empty String. Use `list` to create an empty `java.util.ArrayList`. Use `map` to create an empty `java.util.LinkedHashMap`. U [...]
+ "normalizeWhitespace(exp)": { "index": 102, "kind": "function", "displayName": "Normalize Whitespace", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Normalizes the whitespace in the message body (or expression) by cleaning up excess whitespaces.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": f [...]
+ "not(exp)": { "index": 103, "kind": "function", "displayName": "Not", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the predicate and returns the opposite.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The predicate. When omitted [...]
+ "null": { "index": 104, "kind": "function", "displayName": "Null", "group": "other", "label": "other", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a null value", "ognl": false, "suffix": "}", "examples": [ "${null} -> null" ] },
+ "originalBody": { "index": 105, "kind": "function", "displayName": "Original Body", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The original incoming body (only available if allowUseOriginalMessage=true).", "ognl": false, "suffix": "}" },
+ "pad(exp,width,separator)": { "index": 106, "kind": "function", "displayName": "Pad String", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Pads the expression with extra padding if necessary, according to the total width. The separator is by default a space. A positive width pads to the right (after the value), and a negative width pads to [...]
+ "pretty(exp)": { "index": 107, "kind": "function", "displayName": "Pretty Print", "group": "xml", "label": "json,xml", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to a String, and attempts to pretty print if JSon or XML, otherwise the expression is returned as the String value.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "O [...]
+ "prettyBody": { "index": 108, "kind": "function", "displayName": "Pretty Body", "group": "xml", "label": "json,xml", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to a String, and attempts to pretty print if JSon or XML; otherwise the body is returned as the String value.", "ognl": false, "suffix": "}" },
+ "sort(exp,reverse)": { "index": 109, "kind": "function", "displayName": "Sort", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sorts the message body or expression in natural order", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression [...]
+ "toPrettyJson(exp)": { "index": 110, "kind": "function", "displayName": "To Pretty JSon", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to JSon String representation.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressio [...]
+ "toPrettyJsonBody": { "index": 111, "kind": "function", "displayName": "To Pretty JSon Body", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to JSon String representation.", "ognl": false, "suffix": "}" },
+ "toJson(exp)": { "index": 112, "kind": "function", "displayName": "To JSon", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to JSon String representation.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. When omitt [...]
+ "toJsonBody": { "index": 113, "kind": "function", "displayName": "To JSon Body", "group": "json", "label": "json", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to JSon String representation.", "ognl": false, "suffix": "}" },
+ "properties:key:default": { "index": 114, "kind": "function", "displayName": "Property Placeholder", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Lookup a property placeholder with the given key. If the key does not exist nor has a value, then an optional default value can be specified.", "ognl": false, "suffix": "}", "params": [ { "name": "ke [...]
+ "propertiesExist:key": { "index": 115, "kind": "function", "displayName": "Property Placeholder Exists", "group": "core", "label": "core", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Checks whether a property placeholder with the given key exists or not. The result can be negated by prefixing the key with !", "ognl": false, "suffix": "}", "params": [ { "name": "key", "javaTy [...]
+ "quote(exp)": { "index": 116, "kind": "function", "displayName": "Quote", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the message body (or expression) as a double quoted string", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expressio [...]
+ "random(min,max)": { "index": 117, "kind": "function", "displayName": "Random", "group": "number", "label": "number", "required": false, "javaType": "int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a random number between min and max (exclusive)", "ognl": false, "suffix": "}", "params": [ { "name": "min", "javaType": "int", "required": true, "description": "The minimum value (inclusive)" }, { "name": "max" [...]
+ "range(min,max)": { "index": 118, "kind": "function", "displayName": "Range", "group": "number", "label": "number", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a list of increasing integers between the given interval (exclusive)", "ognl": false, "suffix": "}", "params": [ { "name": "min", "javaType": "int", "required": true, "description": "The start value (inclusive)" [...]
+ "ref:name": { "index": 119, "kind": "function", "displayName": "Bean By Id", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To look up a bean from the Registry with the given name.", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The bean name in the registry" } ], "examples": [...]
+ "replace(from,to,exp)": { "index": 120, "kind": "function", "displayName": "Replace String Values", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Replace all the string values in the message body\/expression. To make it easier to replace single and double quotes, then you can use XML escaped values `\\"` as double quote, `\\'` as [...]
+ "reverse(val...)": { "index": 121, "kind": "function", "displayName": "Reverse Values", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a list of all the values, but in reverse order", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": false, "defaultValue": "body", "description": "Value [...]
+ "routeGroup": { "index": 122, "kind": "function", "displayName": "Route Group", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The route group of the current route the Exchange is being routed. Not all routes have a group assigned, so this may be null.", "ognl": false, "suffix": "}" },
+ "routeId": { "index": 123, "kind": "function", "displayName": "Route Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The route id of the current route the Exchange is being routed", "ognl": false, "suffix": "}", "examples": [ "${routeId} -> myRoute" ] },
+ "safeQuote(exp)": { "index": 124, "kind": "function", "displayName": "Safe Quote", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the message body (or expression) safely quoted if needed", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The ex [...]
+ "setAttachment(key,exp)": { "index": 125, "kind": "function", "displayName": "Set Attachment", "group": "attachment", "label": "attachment", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets an attachment with payload from the message body\/expression.", "ognl": false, "suffix": "}" },
+ "setHeader(name,type,exp)": { "index": 126, "kind": "function", "displayName": "Set Header", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets a message header with the given expression (optional converting to the given type)", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "T [...]
+ "setVariable(name,type,exp)": { "index": 127, "kind": "function", "displayName": "Set Variable", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets a variable with the given expression (optional converting to the given type)", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The [...]
+ "shuffle(val...)": { "index": 128, "kind": "function", "displayName": "Shuffle Values", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a list of all the values shuffled in random order", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "Object", "required": false, "defaultValue": "body", "description": "Va [...]
+ "simpleJsonpath(input,exp)": { "index": 129, "kind": "function", "displayName": "Simple JSonPath", "group": "json", "label": "json", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with JSon data, then this allows using the Simple JSonPath language, for example, to extract data from the message body (in JSon format). For input (optional), you can choose `header:key`, [...]
+ "size(exp)": { "index": 130, "kind": "function", "displayName": "Size", "group": "collection", "label": "collection", "required": false, "javaType": "int", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the number of elements in collection or array based payloads. If the value is null then 0 is returned, otherwise 1.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": [...]
+ "skip(num)": { "index": 131, "kind": "function", "displayName": "Skip First Items from the Message Body", "group": "collection", "label": "collection", "required": false, "javaType": "java.util.Iterator", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The skip function iterates the message body and skips the first number of items. This can be used with the Splitter EIP to split a message body and skip the first N numbe [...]
+ "split(exp,separator)": { "index": 132, "kind": "function", "displayName": "Split String Values", "group": "collection", "label": "collection", "required": false, "javaType": "String[]", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Splits the message body\/expression as a String value using the separator into a String array", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": [...]
+ "stepId": { "index": 133, "kind": "function", "displayName": "Step Id", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the id of the current step the Exchange is being routed.", "ognl": false, "suffix": "}" },
+ "substring(head,tail)": { "index": 134, "kind": "function", "displayName": "Substring", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression by clipping characters off its ends (not by positions). With one number, a positive number clips that many characters from the beginning, and a negative num [...]
+ "substringAfter(exp,before)": { "index": 135, "kind": "function", "displayName": "Substring After", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that comes after. Returns null if nothing comes after.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "requi [...]
+ "substringBefore(exp,before)": { "index": 136, "kind": "function", "displayName": "Substring Before", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that comes before. Returns null if nothing comes before.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "r [...]
+ "substringBetween(exp,after,before)": { "index": 137, "kind": "function", "displayName": "Substring Between", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a substring of the message body\/expression that are between after and before. Returns null if nothing comes between.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", [...]
+ "sum(val...)": { "index": 138, "kind": "function", "displayName": "Calculate Sum Number", "group": "number", "label": "number", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sums together all the values as integral numbers. This function can also be used to subtract by using negative numbers.", "ognl": false, "suffix": "}", "params": [ { "name": "val", "javaType": "long", "requir [...]
+ "sys.name": { "index": 139, "kind": "function", "displayName": "JVM System Property", "group": "other", "label": "other", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JVM system property with the given name", "ognl": false, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The system property name" } ], "examples": [ "${sy [...]
+ "threadId": { "index": 140, "kind": "function", "displayName": "Thread Id", "group": "other", "label": "other", "required": false, "javaType": "long", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the id of the current thread. Can be used for logging.", "ognl": false, "suffix": "}" },
+ "threadName": { "index": 141, "kind": "function", "displayName": "Thread Name", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the name of the current thread. Can be used for logging.", "ognl": false, "suffix": "}" },
+ "throwException(msg,type)": { "index": 142, "kind": "function", "displayName": "Throw Exception", "group": "core", "label": "core", "required": false, "javaType": "java.lang.Exception", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Deliberately throws an error. Uses IllegalArgumentException by default if no type is specified (use fully qualified classname).", "ognl": false, "suffix": "}", "params": [ { "name": "msg", [...]
+ "trim(exp)": { "index": 143, "kind": "function", "displayName": "Trim", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The trim function trims the message body (or expression) by removing all leading and trailing white spaces.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue" [...]
+ "type:name.field": { "index": 144, "kind": "function", "displayName": "Java Field Value", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To refer to a type or field by its classname. To refer to a field, you can append .FIELD_NAME. For example, you can refer to the constant field from Exchange as: `org.apache.camel.Exchange.FILE_NAME`", "ognl": [...]
+ "kindOfType(exp)": { "index": 145, "kind": "function", "displayName": "Kind of Type", "group": "core", "label": "core", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "What kind of type is the value (null,number,string,boolean,array,object)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": [...]
+ "unquote(exp)": { "index": 146, "kind": "function", "displayName": "Unquote", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the message body (or expression) with any leading\/ending quotes removed", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "descriptio [...]
+ "uppercase(exp)": { "index": 147, "kind": "function", "displayName": "Uppercase", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Uppercases the message body (or expression)", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression. When omitted [...]
+ "uuid(type)": { "index": 148, "kind": "function", "displayName": "Generate UUID", "group": "other", "label": "other", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a UUID using the Camel `UuidGenerator`. You can choose between `default`, `classic`, `short`, `simple` and `random` as the type. If no type is given, the default is used. It is also possible to use a custom ` [...]
+ "val(exp)": { "index": 149, "kind": "function", "displayName": "Value", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns the expression as a constant value", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": true, "description": "The constant value expression" } ], "examples": [ "${val(42)} -> 42" [...]
+ "variable.name": { "index": 150, "kind": "function", "displayName": "Variable", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The variable with the given name", "ognl": true, "suffix": "}", "params": [ { "name": "name", "javaType": "String", "required": true, "description": "The variable name" } ], "examples": [ "${variable.myVar} -> variable v [...]
+ "variableAs(key,type)": { "index": 151, "kind": "function", "displayName": "Variable As", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the variable to the given type (classname).", "ognl": false, "suffix": "}", "params": [ { "name": "key", "javaType": "String", "required": true, "description": "The variable name" }, { "name": "type", [...]
+ "variables": { "index": 152, "kind": "function", "displayName": "Variables", "group": "core", "label": "core", "required": false, "javaType": "java.util.Map", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns all the variables from the current Exchange in a Map", "ognl": false, "suffix": "}", "examples": [ "${variables} -> {myVar=value1, count=5}" ] },
+ "xpath(input,exp)": { "index": 153, "kind": "function", "displayName": "XPath", "group": "xml", "label": "xml", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "When working with XML data, then this allows using the XPath language, for example, to extract data from the message body (in XML format). This requires having camel-xpath JAR on the classpath. For input (optional), you ca [...]
},
"operators": {
"==": { "index": 0, "kind": "operator", "displayName": "Eq", "label": "binary", "required": false, "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Tests equality between left and right operand values. Camel will coerce the right operand type to match the left.", "operatorKind": "binary", "operatorSyntax": "LHS == RHS", "precedence": 10, "examples": [ "${header.foo} == 'bar'", "${header.count} == 5" ] },
diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/file-language.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/file-language.adoc
index baf9228dd657..31f2ed00041c 100644
--- a/core/camel-core-languages/src/main/docs/modules/languages/pages/file-language.adoc
+++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/file-language.adoc
@@ -83,7 +83,7 @@ this expression strips only the last part, and keeps the others.
|file:size |Long |yes |no |yes |no |refers to the file length returned as a Long type
-|file:modified |Date |yes |no |yes |no |Refers to the file last modified returned as a Date type
+|file:modified |Long |yes |no |yes |no |Refers to the file last modified returned as a Long (millis since epoch)
|date:_command:pattern_ |String |yes |yes |yes |yes |for date formatting using the `java.text.SimpleDateFormat` patterns. Is
an *extension* to the xref:simple-language.adoc[Simple] language. Additional
diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-functions.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-functions.adoc
index 41d80e7bbcf8..a6a26ee3573a 100644
--- a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-functions.adoc
+++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-functions.adoc
@@ -96,7 +96,7 @@ to access Camel functionality and content of the message being routed.
|`setHeader(name,type,exp)` | `null` | Sets a message header with the given expression (optional converting to the given type).
|`setVariable(name,type,exp)` | `null` | Sets a variable with the given expression (optional converting to the given type).
|`stepId` | `String` | Returns the id of the current step the `Exchange` is being routed. Returns `null` if there are no steps.
-|`throwException(type,msg)` | `Exception` | Deliberately throws an error. Uses `IllegalArgumentException` by default if no type is specified (use fully qualified classname).
+|`throwException(msg,type)` | `Exception` | Deliberately throws an error. Uses `IllegalArgumentException` by default if no type is specified (use fully qualified classname).
|`type:name.field` | `Object` | To refer to a type or field by its fully qualified classname. For example: `type:org.apache.camel.Exchange.FILE_NAME`.
|`val(exp)` | `Object` | Returns the expression as a constant value.
|`variable.key` | `Object` | To look up the variable with the given key.
@@ -410,10 +410,10 @@ Various functions to work with numbers.
|`abs()` | `long` | Converts the message body to a long number and return the absolute value.
|`abs(exp)` | `Long` | Converts the message body (or expression) to a long number and return the absolute value.
|`average(val1,val2,...)` | `long` | Returns the average number from all the values (integral numbers only).
-|`ceil()` | `int` | Converts the message body to a floating number and return the ceil value (rounded up to nearest integer).
-|`ceil(exp)` | `int` | Converts the expression to a floating number and return the ceil value (rounded up to nearest integer).
-|`floor()` | `int` | Converts the message body to a floating number and return the floor value (rounded down to nearest integer).
-|`floor(exp)` | `int` | Converts the expression to a floating number and return the floor value (rounded down to nearest integer).
+|`ceil()` | `long` | Converts the message body to a floating number and return the ceil value (rounded up to nearest integer).
+|`ceil(exp)` | `long` | Converts the expression to a floating number and return the ceil value (rounded up to nearest integer).
+|`floor()` | `long` | Converts the message body to a floating number and return the floor value (rounded down to nearest integer).
+|`floor(exp)` | `long` | Converts the expression to a floating number and return the floor value (rounded down to nearest integer).
|`max(val1,val2,...)` | `long` | Returns the maximum number from all the values (integral numbers only).
|`min(val1,val2,...)` | `long` | Returns the minimum number from all the values (integral numbers only).
|`random(max)` | `int` | Returns a random `Integer` between 0 (included) and max (excluded).
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/FileConstants.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/FileConstants.java
index 8e39221b8c4e..abd381db07e5 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/FileConstants.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/FileConstants.java
@@ -26,7 +26,7 @@ public final class FileConstants {
@Metadata(description = "The file name (relative from starting directory) without extension", javaType = "String",
label = "file")
public static final String FILE_NO_EXT = "file:name.noext";
- @Metadata(description = "The file name (relative from starting directory) without extension. If the file name has multiple dots, then this expression strips and only returns the last part.",
+ @Metadata(description = "The file name (relative from starting directory) without extension. If the file name has multiple dots, then only the last extension is stripped (such as a.tar.gz becomes a.tar).",
javaType = "String", label = "file")
public static final String FILE_NO_EXT_SINGLE = "file:name.noext.single";
@Metadata(description = "The file extension", javaType = "String", label = "file")
@@ -34,12 +34,12 @@ public final class FileConstants {
@Metadata(description = "The file extension. If the file extension has multiple dots, then this expression strips and only returns the last part.",
javaType = "String", label = "file")
public static final String FILE_EXT_SINGLE = "file:name.ext.single";
- @Metadata(description = "†he file name (without any leading paths)", javaType = "String", label = "file")
+ @Metadata(description = "The file name (without any leading paths)", javaType = "String", label = "file")
public static final String FILE_ONLY_NAME = "file:onlyname";
- @Metadata(description = "†he file name (without any leading paths) without extension", javaType = "String",
+ @Metadata(description = "The file name (without any leading paths) without extension", javaType = "String",
label = "file")
public static final String FILE_ONLY_NAME_NO_EXT = "file:onlyname.noext";
- @Metadata(description = "†he file name (without any leading paths) without extension. If the file name has multiple dots, then this expression strips and only returns the last part.",
+ @Metadata(description = "The file name (without any leading paths) without extension. If the file name has multiple dots, then only the last extension is stripped (such as a.tar.gz becomes a.tar).",
javaType = "String", label = "file")
public static final String FILE_ONLY_NAME_NO_EXT_SINGLE = "file:onlyname.noext.single";
@Metadata(description = "The file parent directory (null if no parent directory)", javaType = "String", label = "file")
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java
index 7e676b064f05..a48050560700 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java
@@ -32,7 +32,7 @@ public final class SimpleConstants {
examples = { "${assert(${body} == 'Hello', 'Must be Hello')}" },
annotations = {
"param=exp:Object:required::The predicate expression to evaluate",
- "param=msg:String:optional::The error message if the assertion fails" })
+ "param=msg:String:required::The error message if the assertion fails" })
public static final String ASSERT = "assert(exp,msg)";
@Metadata(description = "Emits an A2A task progress update with WORKING state. Requires the camel-a2a component on the classpath and an active A2A task context.",
@@ -209,9 +209,9 @@ public final class SimpleConstants {
@Metadata(description = "Calls a Java bean. The name of the bean can also refer to a class name using type prefix as follows `bean:type:com.foo.MyClass`. If no method name is given then Camel will automatic attempt to find the best method to use.",
label = "core", javaType = "Object", displayName = "Call Java Bean",
examples = {
- "${bean(myBean)} -> result // calls best matching method",
- "${bean(myBean.myMethod)} -> result // calls specific method",
- "${bean(type:com.foo.MyClass.myMethod)} -> result // calls static method by classname" },
+ "${bean:myBean} -> result // calls best matching method",
+ "${bean:myBean.myMethod} -> result // calls specific method",
+ "${bean:type:com.foo.MyClass.myMethod} -> result // calls static method by classname" },
annotations = {
"param=name:String:required::The bean name (or type:classname)",
"param=method:String:optional::The method name to invoke" })
@@ -252,7 +252,7 @@ public final class SimpleConstants {
public static final String CAPITALIZE = "capitalize(exp)";
@Metadata(description = "Converts the message body (or expression) to a floating number and return the ceil value (rounded up to nearest integer).",
- label = "number", javaType = "Integer", displayName = "Ceil Number",
+ label = "number", javaType = "Long", displayName = "Ceil Number",
examples = { "${ceil(2.3)} -> 3", "${ceil(5.0)} -> 5" },
annotations = { "param=exp:Object:optional:body:The expression. When omitted uses the message body" })
public static final String CEIL = "ceil(exp)";
@@ -301,10 +301,10 @@ public final class SimpleConstants {
@Metadata(description = "Evaluates to a java.util.Date object. Supported commands are: `now` for current timestamp, `millis` for current timestamp in millis (unix epoch), `exchangeCreated` for the timestamp when the current exchange was created, `header.xxx` to use the Long/Date object in the header with the key xxx. `variable.xxx` to use the Long/Date in the variable with the key xxx. `exchangeProperty.xxx` to use the Long/Date object in the exchange property with the key xxx. `file [...]
label = "date", javaType = "java.util.Date", displayName = "Parse Date",
examples = {
- "${date(now)} -> current Date object",
- "${date(now-24h)} -> Date 24 hours ago",
- "${date(exchangeCreated)} -> Date when exchange was created",
- "${date(header.myDate)} -> Date from header myDate" },
+ "${date:now} -> current Date object",
+ "${date:now-24h} -> Date 24 hours ago",
+ "${date:exchangeCreated} -> Date when exchange was created",
+ "${date:header.myDate} -> Date from header myDate" },
annotations = {
"param=command:String:required::The date command (now, millis, exchangeCreated, header.xxx, variable.xxx, file). Supports offsets like now-24h" })
public static final String DATE = "date(command)";
@@ -375,7 +375,7 @@ public final class SimpleConstants {
@Metadata(description = "The exception stacktrace (also from caught exceptions), is null if no exception present.",
javaType = "String", label = "core", displayName = "Exception Stacktrace")
- public static final String EXCEPTION_STACKTRACE = "exception.stackTrace";
+ public static final String EXCEPTION_STACKTRACE = "exception.stacktrace";
@Metadata(description = "Returns a List containing the values that satisfy the predicate function (returning true)",
label = "collection", javaType = "List", displayName = "Filter Elements",
@@ -393,7 +393,7 @@ public final class SimpleConstants {
public static final String FOR_EACH = "forEach(exp,fun)";
@Metadata(description = "Converts the message body (or expression) to a floating number and return the floor value (rounded down to nearest integer).",
- label = "number", javaType = "Integer", displayName = "Floor Number",
+ label = "number", javaType = "Long", displayName = "Floor Number",
examples = { "${floor(2.7)} -> 2", "${floor(5.0)} -> 5" },
annotations = { "param=exp:Object:optional:body:The expression. When omitted uses the message body" })
public static final String FLOOR = "floor(exp)";
@@ -438,8 +438,13 @@ public final class SimpleConstants {
@Metadata(description = "Returns the local hostname (may be empty if not possible to resolve).", javaType = "String",
label = "other",
- examples = { "${hostName} -> myserver.local" })
- public static final String HOST_NAME = "hostName";
+ examples = { "${hostname} -> myserver.local" })
+ public static final String HOST_NAME = "hostname";
+
+ @Metadata(description = "Dumps the exchange for logging purpose (uses `ExchangeFormatter` to format the output).",
+ javaType = "String", label = "core", displayName = "Log Exchange",
+ examples = { "${logExchange} -> Exchange[Id: ..., Headers: {...}, Body: Hello]" })
+ public static final String LOG_EXCHANGE = "logExchange";
@Metadata(description = "Cleans the HTML to remove unsafe links and JavaScripts from the message body (or expression)",
javaType = "String", label = "html",
@@ -645,8 +650,10 @@ public final class SimpleConstants {
annotations = { "param=exp:Object:optional:body:The expression. When omitted uses the message body" })
public static final String NORMALIZE_WHITESPACE = "normalizeWhitespace(exp)";
- @Metadata(description = "Evaluates the predicate and returns the opposite.", label = "condition", javaType = "boolean")
- public static final String NOT = "not";
+ @Metadata(description = "Evaluates the predicate and returns the opposite.", label = "condition", javaType = "boolean",
+ examples = { "${not(${header.count} > 5)} -> true // when count is 3" },
+ annotations = { "param=exp:Object:optional:body:The predicate. When omitted uses the message body" })
+ public static final String NOT = "not(exp)";
@Metadata(description = "Returns a null value", label = "other", javaType = "Object",
examples = { "${null} -> null" })
@@ -786,7 +793,7 @@ public final class SimpleConstants {
@Metadata(description = "Sets an attachment with payload from the message body/expression.",
label = "attachment", javaType = "Object")
- public static final String SET_ATTACHMENT = "setVariable(key,exp)";
+ public static final String SET_ATTACHMENT = "setAttachment(key,exp)";
@Metadata(description = "Sets a message header with the given expression (optional converting to the given type)",
label = "core", javaType = "Object",
@@ -912,11 +919,11 @@ public final class SimpleConstants {
javaType = "java.lang.Exception", label = "core",
examples = {
"${throwException('Something went wrong')} -> throws IllegalArgumentException",
- "${throwException(java.io.IOException,'File not found')} -> throws IOException" },
+ "${throwException('File not found',java.io.IOException)} -> throws IOException" },
annotations = {
- "param=type:String:optional:java.lang.IllegalArgumentException:The fully qualified exception classname",
- "param=msg:String:required::The error message" })
- public static final String THROW_EXCEPTION = "throwException(type,msg)";
+ "param=msg:String:required::The error message",
+ "param=type:String:optional:java.lang.IllegalArgumentException:The fully qualified exception classname" })
+ public static final String THROW_EXCEPTION = "throwException(msg,type)";
@Metadata(description = "The trim function trims the message body (or expression) by removing all leading and trailing white spaces.",
label = "string", javaType = "String", displayName = "Trim",
@@ -954,14 +961,14 @@ public final class SimpleConstants {
annotations = { "param=exp:Object:optional:body:The expression. When omitted uses the message body" })
public static final String UPPERCASE = "uppercase(exp)";
- @Metadata(description = "Returns a UUID using the Camel `UuidGenerator`. You can choose between `default`, `classic`, `short` and `simple` as the type. If no type is given, the default is used. It is also possible to use a custom `UuidGenerator` and bind the bean to the Registry with an id. For example `${uuid(myGenerator)}` where the ID is _myGenerator_.",
+ @Metadata(description = "Returns a UUID using the Camel `UuidGenerator`. You can choose between `default`, `classic`, `short`, `simple` and `random` as the type. If no type is given, the default is used. It is also possible to use a custom `UuidGenerator` and bind the bean to the Registry with an id. For example `${uuid(myGenerator)}` where the ID is _myGenerator_.",
label = "other", javaType = "String", displayName = "Generate UUID",
examples = {
"${uuid()} -> ID-myhost-1234567890-0-1 // default generator",
"${uuid(short)} -> a1b2c3d4 // short format",
"${uuid(simple)} -> 550e8400-e29b-41d4-a716-446655440000 // simple UUID" },
annotations = {
- "param=type:String:optional:default:The UUID type: default, classic, short, simple, or a custom generator bean name" })
+ "param=type:String:optional:default:The UUID type: default, classic, short, simple, random, or a custom generator bean name" })
public static final String UUID = "uuid(type)";
@Metadata(description = "Returns the expression as a constant value",
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleFunctionHelper.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleFunctionHelper.java
index 64f1336abe24..f01b84edfa48 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleFunctionHelper.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleFunctionHelper.java
@@ -55,8 +55,8 @@ public final class SimpleFunctionHelper {
}
/**
- * The remainder after a name such as header must start the key, so ${headerfoo} is not the header foo (and a
- * custom function named such as headerCount can be called).
+ * The remainder after a name such as header must start the key, so ${headerfoo} is not the header foo (and a custom
+ * function named such as headerCount can be called).
*/
private static String keyRemainder(String remainder) {
if (remainder != null && !remainder.isEmpty()) {
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleSyntaxHints.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleSyntaxHints.java
index f39dbb5c30be..9b80f36a0e8b 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleSyntaxHints.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleSyntaxHints.java
@@ -37,15 +37,21 @@ public final class SimpleSyntaxHints {
/** Function names a model is likely to write, for the did-you-mean suggestion. */
static final List<String> FUNCTIONS = List.of("body", "bodyAs", "mandatoryBodyAs", "bodyOneLine", "prettyBody",
"originalBody", "header", "headerAs", "headers", "exchangeProperty", "exchangePropertyAs",
- "exchangeProperties", "variable", "variableAs", "variables", "exception", "exchange", "camelContext",
+ "variable", "variableAs", "variables", "exception", "exchange", "camelContext",
"camelId", "routeId", "routeGroup", "stepId", "id", "messageTimestamp", "threadName", "threadId",
- "hostname", "date", "date-with-timezone", "random", "skip", "collate", "join", "sum", "avg", "min", "max",
- "replace", "substring", "substringBefore", "substringAfter", "substringBetween", "contains", "pad",
- "concat", "val", "length", "empty", "newEmpty", "iif", "hash", "convertTo", "throwException", "assert",
- "load", "uuid", "env", "sys", "ref", "bean", "properties", "propertiesExist", "type", "messageAs",
- "messageHistory", "pretty", "toJson", "toPrettyJson", "jq", "jsonpath", "xpath", "simpleJsonpath",
- "function", "list", "map", "range", "split", "sort", "forEach", "filter", "listAdd", "listRemove",
- "mapAdd", "mapRemove", "file", "null");
+ "hostname", "date", "date-with-timezone", "random", "skip", "collate", "join", "sum", "average", "min",
+ "max", "abs", "ceil", "floor", "replace", "substring", "substringBefore", "substringAfter",
+ "substringBetween", "contains", "pad", "concat", "val", "length", "size", "empty", "newEmpty", "iif",
+ "hash", "convertTo", "throwException", "assert", "load", "uuid", "env", "sys", "sysenv", "ref", "bean",
+ "properties", "propertiesExist", "type", "messageAs", "messageHistory", "logExchange", "pretty",
+ "toJson", "toPrettyJson", "jq", "jsonpath", "xpath", "simpleJsonpath", "function", "list", "map",
+ "range", "split", "sort", "distinct", "reverse", "shuffle", "forEach", "filter", "listAdd", "listRemove",
+ "mapAdd", "mapRemove", "setHeader", "setVariable", "uppercase", "lowercase", "trim", "capitalize",
+ "normalizeWhitespace", "quote", "unquote", "safeQuote", "escape", "isEmpty", "isAlpha", "isAlphaNumeric",
+ "isNumeric", "not", "kindOfType", "file", "null");
+
+ /** Functions that are called with parentheses, so a suggestion without arguments adds them. */
+ private static final Set<String> CALLED_WITH_PARENTHESES = Set.of("uppercase", "lowercase", "trim", "size", "average");
/**
* Functions that delegate to another language, all of them written {@code ${name(exp)}}. Unlike {@code bean:} or
@@ -64,14 +70,15 @@ public final class SimpleSyntaxHints {
Map.entry("var", "variable"),
Map.entry("prop", "exchangeProperty"),
Map.entry("json", "jsonpath"),
- Map.entry("upper", "bodyAs(String).toUpperCase()"),
- Map.entry("lower", "bodyAs(String).toLowerCase()"),
- Map.entry("trim", "bodyAs(String).trim()"),
+ Map.entry("upper", "uppercase"),
+ Map.entry("toUpperCase", "uppercase"),
+ Map.entry("lower", "lowercase"),
+ Map.entry("toLowerCase", "lowercase"),
Map.entry("padding", "pad"),
Map.entry("now", "date:now:yyyy-MM-dd'T'HH:mm:ss"),
Map.entry("timestamp", "messageTimestamp"),
- Map.entry("size", "length"),
- Map.entry("count", "length"));
+ Map.entry("avg", "average"),
+ Map.entry("count", "size"));
private static final String[] OPERATOR_WORDS = {
"==", "!=", ">=", "<=", ">", "<", "=~", "!=~", "~~", "!~~", "contains",
@@ -359,6 +366,9 @@ public final class SimpleSyntaxHints {
}
}
if (alias != null) {
+ if (rest.isEmpty() && CALLED_WITH_PARENTHESES.contains(alias)) {
+ rest = "()";
+ }
if (rest.startsWith(":") && QUERY_FUNCTIONS.contains(alias)) {
// ${json:$.status}: the alias resolves to jsonpath, so the argument moves into parentheses too
return parentheses(alias, rest.substring(1));
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/StringFunctionFactory.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/StringFunctionFactory.java
index e32ed2227139..2dea39bcd4fe 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/StringFunctionFactory.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/StringFunctionFactory.java
@@ -143,14 +143,14 @@ public final class StringFunctionFactory implements SimpleLanguageFunctionFactor
String values = StringHelper.beforeLast(remainder, ")");
if (values == null || ObjectHelper.isEmpty(values)) {
throw new SimpleParserException(
- "Valid syntax: ${substringBetween(after,before)} or ${substringAfter(exp,after,before)} was: "
+ "Valid syntax: ${substringBetween(after,before)} or ${substringBetween(exp,after,before)} was: "
+ function,
index);
}
String[] tokens = StringQuoteHelper.splitSafeQuote(values, ',', false);
if (tokens.length < 2 || tokens.length > 3) {
throw new SimpleParserException(
- "Valid syntax: ${substringBetween(after,before)} or ${substringAfter(exp,after,before)} was: "
+ "Valid syntax: ${substringBetween(after,before)} or ${substringBetween(exp,after,before)} was: "
+ function,
index);
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleSyntaxHintsTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleSyntaxHintsTest.java
index b67842929599..55de40810c70 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleSyntaxHintsTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleSyntaxHintsTest.java
@@ -96,6 +96,11 @@ public class SimpleSyntaxHintsTest extends ExchangeTestSupport {
assertThat(expressionError("${Body}")).contains("case sensitive: ${body}");
assertThat(expressionError("${ body }")).contains("remove the spaces: ${body}");
assertThat(expressionError("${bodyy}")).contains("did you mean ${body}?");
+ // CAMEL-24970: the suggestions name the simple functions
+ assertThat(expressionError("${upper}")).contains("did you mean ${uppercase()}?");
+ assertThat(expressionError("${avg(1,2)}")).contains("did you mean ${average(1,2)}?");
+ assertThat(expressionError("${uppercse()}")).contains("did you mean ${uppercase()}?");
+ assertThat(expressionError("${count}")).contains("did you mean ${size()}?");
}
@Test
(camel) 05/11: CAMEL-24968: simple - fix string, math, date and file function edge cases
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch fix/CAMEL-24962
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1746815b241fcb82f3968548584b4f7d7c08d113
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 23 18:53:41 2026 +0200
CAMEL-24968: simple - fix string, math, date and file function edge cases
- capitalize of an empty value, and capitalize all after any whitespace (camel-util)
- sum, max, min and average without arguments use the message body, as documented
- date:header.Last-Modified and date:header.my.date read the named header (an offset starts with a digit)
- date-with-timezone accepts a timezone with a colon, such as GMT+02:00
- safeQuote escapes quotes, backslashes and control characters so the result is valid JSON
- kindOfType: BigDecimal is a number, a Map is an object, any array is an array
- substring with a null number reports it; substringBefore/After/Between with no delimiter return null
- pad with a separator of several characters pads to the exact width; docs and catalog had the direction backwards
- size and length count any kind of array
- a leading dot is a hidden file, not an extension: .bashrc has no extension (camel-util FileUtil)
Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
.../org/apache/camel/language/simple/simple.json | 2 +-
.../modules/languages/pages/simple-functions.adoc | 7 +-
.../language/simple/DateExpressionBuilder.java | 9 +-
.../language/simple/MiscExpressionBuilder.java | 40 +++---
.../camel/language/simple/SimpleConstants.java | 10 +-
.../language/simple/StringExpressionBuilder.java | 93 ++++++-------
.../simple/functions/DateFunctionFactory.java | 10 ++
.../simple/functions/MathFunctionFactory.java | 3 +-
.../simple/SimpleStringMathDateFunctionsTest.java | 144 +++++++++++++++++++++
.../java/org/apache/camel/util/FileUtilTest.java | 11 ++
.../org/apache/camel/support/LanguageHelper.java | 9 +-
.../main/java/org/apache/camel/util/FileUtil.java | 10 +-
.../java/org/apache/camel/util/StringHelper.java | 10 +-
.../org/apache/camel/util/StringHelperTest.java | 5 +
14 files changed, 274 insertions(+), 89 deletions(-)
diff --git a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json
index a1df2fe174f9..dfc3d543b094 100644
--- a/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json
+++ b/core/camel-core-languages/src/generated/resources/META-INF/org/apache/camel/language/simple/simple.json
@@ -131,7 +131,7 @@
"not": { "index": 102, "kind": "function", "displayName": "Not", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the predicate and returns the opposite.", "ognl": false, "suffix": "}" },
"null": { "index": 103, "kind": "function", "displayName": "Null", "group": "other", "label": "other", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a null value", "ognl": false, "suffix": "}", "examples": [ "${null} -> null" ] },
"originalBody": { "index": 104, "kind": "function", "displayName": "Original Body", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The original incoming body (only available if allowUseOriginalMessage=true).", "ognl": false, "suffix": "}" },
- "pad(exp,width,separator)": { "index": 105, "kind": "function", "displayName": "Pad String", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Pads the expression with extra padding if necessary, according the the total width. The separator is by default a space. If the width is negative then padding to the right, otherwise to the left.", "ognl [...]
+ "pad(exp,width,separator)": { "index": 105, "kind": "function", "displayName": "Pad String", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Pads the expression with extra padding if necessary, according to the total width. The separator is by default a space. A positive width pads to the right (after the value), and a negative width pads to [...]
"pretty(exp)": { "index": 106, "kind": "function", "displayName": "Pretty Print", "group": "xml", "label": "json,xml", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to a String, and attempts to pretty print if JSon or XML, otherwise the expression is returned as the String value.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "O [...]
"prettyBody": { "index": 107, "kind": "function", "displayName": "Pretty Body", "group": "xml", "label": "json,xml", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to a String, and attempts to pretty print if JSon or XML; otherwise the body is returned as the String value.", "ognl": false, "suffix": "}" },
"sort(exp,reverse)": { "index": 108, "kind": "function", "displayName": "Sort", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sorts the message body or expression in natural order", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression [...]
diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-functions.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-functions.adoc
index 525d77ecd2f1..41d80e7bbcf8 100644
--- a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-functions.adoc
+++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-functions.adoc
@@ -520,7 +520,7 @@ The string functions is various functions to work with values that are String an
|`lowercase(exp)` | `String` | Lowercases the expression
|`normalizeWhitespace()` | `String` | Normalizes the whitespace in the message body by cleaning up excess whitespaces.
|`normalizeWhitespace(exp)` | `String` | Normalizes the whitespace in the expression by cleaning up excess whitespaces.
-|`pad(exp,width,separator)` | `String` | Pads the expression with extra padding if necessary, according the total width The separator is by default a space. If the width is negative then padding to the right, otherwise to the left.
+|`pad(exp,width,separator)` | `String` | Pads the expression with extra padding if necessary, according to the total width. The separator is by default a space. A positive width pads to the right (after the value), and a negative width pads to the left (before the value).
|`replace(from,to)` | `String` | Replace all the string values in the message body. To make it easier to replace single and double quotes, then you can use XML escaped values `\"` as double quote, `\'` as single quote, and `\∅` as empty value.
|`replace(from,to,exp)` | `String` | Replace all the string values in the given expression. To make it easier to replace single and double quotes, then you can use XML escaped values `\"` as double quote, `\'` as single quote, and `\∅` as empty value.
|`safeQuote()` | `String` | Returns the message body safely quoted if needed
@@ -636,13 +636,16 @@ If the value is currently in single quote, then this will be converted to double
If the message body contains `Hello World` then `${quote()}` returns `"Hello World"`.
And using `${quote('Hi from me')}` then `"Hi from me"` is returned.
+The `quote` function does not escape the value, so a value with double quotes or backslashes is not a valid JSON string;
+use `safeQuote` (or `escape(json)`) for JSON.
The `unquote` function removes any surrounding single or double quotes from a value.
If the body contains `'hello'` then `${unquote()}` returns `hello` (without the quotes).
The `safeQuote` function is quoting the value depending on the value type
(uses the same logic as `kindOfType` function). In essence values that are null, boolean or numbers are not quoted,
-while everything else is. The `safeQuote` function is useful when working with JSON data.
+while everything else is. When quoted, double quotes, backslashes and control characters in the value are escaped,
+so the result is a valid JSON string. The `safeQuote` function is useful when working with JSON data.
For example when doing JSON to JSON mapping you can extract values form the source document,
to be included in the output, but the values may or may not need to be quoted. Then you can use the `~>` chain operator
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/DateExpressionBuilder.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/DateExpressionBuilder.java
index fc9a006d0b81..407409fb1de2 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/DateExpressionBuilder.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/DateExpressionBuilder.java
@@ -18,6 +18,7 @@ package org.apache.camel.language.simple;
import java.util.Date;
import java.util.List;
+import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.camel.Exchange;
@@ -30,7 +31,9 @@ import org.apache.camel.support.LanguageHelper;
*/
public final class DateExpressionBuilder {
- private static final Pattern OFFSET_PATTERN = Pattern.compile("([+-])([^+-]+)");
+ // an offset starts with a digit, so a name such as header.Last-Modified is not an offset
+ private static final Pattern OFFSET_PATTERN = Pattern.compile("([+-])\\s*(\\d[^+-]*)");
+ private static final Pattern OFFSET_START = Pattern.compile("[+-]\\s*\\d");
private DateExpressionBuilder() {
}
@@ -46,7 +49,9 @@ public final class DateExpressionBuilder {
public static Expression dateExpression(
final String commandWithOffsets, final String timezone,
final String pattern) {
- final String command = commandWithOffsets.split("[+-]", 2)[0].trim();
+ final Matcher offsetStart = OFFSET_START.matcher(commandWithOffsets);
+ final String command
+ = (offsetStart.find() ? commandWithOffsets.substring(0, offsetStart.start()) : commandWithOffsets).trim();
final List<Long> offsets = LanguageHelper.captureOffsets(commandWithOffsets, OFFSET_PATTERN);
return new ExpressionAdapter() {
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MiscExpressionBuilder.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MiscExpressionBuilder.java
index f1a7c23e0a1d..5adb2c781128 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MiscExpressionBuilder.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MiscExpressionBuilder.java
@@ -454,22 +454,7 @@ public final class MiscExpressionBuilder {
} else {
value = exchange.getMessage().getBody();
}
- if (value != null) {
- Class<?> type = value.getClass();
- if (ObjectHelper.isNumericType(type)) {
- return "number";
- } else if (boolean.class == type || Boolean.class == type) {
- return "boolean";
- } else if (value instanceof CharSequence) {
- return "string";
- } else if (ObjectHelper.isPrimitiveArrayType(type) || value instanceof Collection
- || value instanceof Map<?, ?>) {
- return "array";
- } else {
- return "object";
- }
- }
- return "null";
+ return kindOfType(value);
}
@Override
@@ -1113,4 +1098,27 @@ public final class MiscExpressionBuilder {
}
};
}
+
+ /**
+ * What kind of type is the value in JSON terms (null, number, string, boolean, array or object)
+ */
+ static String kindOfType(Object value) {
+ if (value == null) {
+ return "null";
+ }
+ Class<?> type = value.getClass();
+ if (value instanceof Number) {
+ // also BigDecimal and BigInteger, such as numbers from a JSON document
+ return "number";
+ } else if (Boolean.class == type) {
+ return "boolean";
+ } else if (value instanceof CharSequence) {
+ return "string";
+ } else if (type.isArray() || value instanceof Collection) {
+ return "array";
+ } else {
+ // a Map is a JSON object
+ return "object";
+ }
+ }
}
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java
index 992ea86f809e..7e676b064f05 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleConstants.java
@@ -656,15 +656,15 @@ public final class SimpleConstants {
label = "core")
public static final String ORIGINAL_BODY = "originalBody";
- @Metadata(description = "Pads the expression with extra padding if necessary, according the the total width. The separator is by default a space. If the width is negative then padding to the right, otherwise to the left.",
+ @Metadata(description = "Pads the expression with extra padding if necessary, according to the total width. The separator is by default a space. A positive width pads to the right (after the value), and a negative width pads to the left (before the value).",
label = "string", javaType = "String", displayName = "Pad String",
examples = {
- "${pad('Hi',10)} -> Hi // left-padded with spaces to width 10",
- "${pad('Hi',-10)} -> Hi // right-padded with spaces",
- "${pad('42',5,'0')} -> 00042 // left-padded with zeros" },
+ "${pad('Hi',10)} -> Hi // padded to the right with spaces to width 10",
+ "${pad('Hi',-10)} -> Hi // padded to the left with spaces",
+ "${pad('42',-5,'0')} -> 00042 // padded to the left with zeros" },
annotations = {
"param=exp:Object:required::The expression to pad",
- "param=width:int:required::The target width. Negative for right-padding",
+ "param=width:int:required::The target width. Positive pads to the right, negative pads to the left",
"param=separator:String:optional: :The padding character (default is space)" })
public static final String PAD = "pad(exp,width,separator)";
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/StringExpressionBuilder.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/StringExpressionBuilder.java
index a14654126b55..2c66feb6d0eb 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/StringExpressionBuilder.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/StringExpressionBuilder.java
@@ -17,6 +17,7 @@
package org.apache.camel.language.simple;
import java.io.InputStream;
+import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Locale;
import java.util.Map;
@@ -66,30 +67,22 @@ public final class StringExpressionBuilder {
value = exchange.getMessage().getBody(Object.class);
}
if (value != null) {
- String type = kindOfType(value);
+ String type = MiscExpressionBuilder.kindOfType(value);
if ("string".equals(type) || "array".equals(type) || "object".equals(type)) {
String body = exchange.getContext().getTypeConverter().tryConvertTo(String.class, exchange, value);
- body = StringHelper.removeLeadingAndEndingQuotes(body);
- value = StringQuoteHelper.doubleQuote(body);
+ // a value that is already one quoted string is not quoted twice
+ if (isQuotedOnce(body, '"') || isQuotedOnce(body, '\'')) {
+ body = body.substring(1, body.length() - 1);
+ }
+ // escape quotes, backslashes and control characters so the result is a valid JSON string
+ value = "\"" + EscapeHelper.escape(EscapeHelper.Kind.JSON, body) + "\"";
}
}
return value;
}
- private String kindOfType(Object value) {
- Class<?> type = value.getClass();
- if (ObjectHelper.isNumericType(type)) {
- return "number";
- } else if (boolean.class == type || Boolean.class == type) {
- return "boolean";
- } else if (value instanceof CharSequence) {
- return "string";
- } else if (ObjectHelper.isPrimitiveArrayType(type) || value instanceof Collection
- || value instanceof Map<?, ?>) {
- return "array";
- } else {
- return "object";
- }
+ private static boolean isQuotedOnce(String text, char quote) {
+ return text.length() >= 2 && text.charAt(0) == quote && text.indexOf(quote, 1) == text.length() - 1;
}
@Override
@@ -296,14 +289,16 @@ public final class StringExpressionBuilder {
}
int max = Math.abs(width);
- while (max > answer.length()) {
- if (width > 0) {
- answer = answer + sep;
- } else {
- answer = sep + answer;
- }
+ if (max <= answer.length()) {
+ return answer;
+ }
+ // a separator of several characters is cut so the answer is exactly the width
+ StringBuilder padding = new StringBuilder(max);
+ while (padding.length() < max - answer.length()) {
+ padding.append(sep);
}
- return answer;
+ padding.setLength(max - answer.length());
+ return width > 0 ? answer + padding : padding + answer;
}
@Override
@@ -451,18 +446,9 @@ public final class StringExpressionBuilder {
body = exchange.getMessage().getBody();
}
if (body != null) {
- if (body instanceof byte[] arr) {
- return arr.length;
- } else if (body instanceof char[] arr) {
- return arr.length;
- } else if (body instanceof int[] arr) {
- return arr.length;
- } else if (body instanceof long[] arr) {
- return arr.length;
- } else if (body instanceof double[] arr) {
- return arr.length;
- } else if (body instanceof String[] arr) {
- return arr.length;
+ if (body.getClass().isArray()) {
+ // any kind of array such as byte[], Object[] or Integer[]
+ return Array.getLength(body);
} else if (body instanceof Collection<?> c) {
return c.size();
} else if (body instanceof Map<?, ?> m) {
@@ -509,18 +495,9 @@ public final class StringExpressionBuilder {
body = exchange.getMessage().getBody();
}
try {
- if (body instanceof byte[] arr) {
- return arr.length;
- } else if (body instanceof char[] arr) {
- return arr.length;
- } else if (body instanceof int[] arr) {
- return arr.length;
- } else if (body instanceof long[] arr) {
- return arr.length;
- } else if (body instanceof double[] arr) {
- return arr.length;
- } else if (body instanceof String[] arr) {
- return arr.length;
+ if (body != null && body.getClass().isArray()) {
+ // any kind of array such as byte[], Object[] or Integer[]
+ return Array.getLength(body);
} else if (body instanceof StreamCache sc) {
return (int) sc.length();
} else {
@@ -693,8 +670,12 @@ public final class StringExpressionBuilder {
@Override
public Object evaluate(Exchange exchange) {
- int num1 = exp1.evaluate(exchange, Integer.class);
- int num2 = exp2.evaluate(exchange, Integer.class);
+ Integer num1 = exp1.evaluate(exchange, Integer.class);
+ Integer num2 = exp2.evaluate(exchange, Integer.class);
+ if (num1 == null || num2 == null) {
+ throw new IllegalArgumentException(
+ "substring number expression evaluated to null: " + head + "," + tail);
+ }
if (num1 < 0 && num2 == 0) {
// if there is only one value and its negative then we want to clip from tail
num2 = num1;
@@ -735,6 +716,10 @@ public final class StringExpressionBuilder {
return null;
}
String bef = expBefore.evaluate(exchange, String.class);
+ if (bef == null) {
+ // no delimiter (such as a missing header) then nothing comes before
+ return null;
+ }
return StringHelper.before(body, bef);
}
@@ -768,6 +753,10 @@ public final class StringExpressionBuilder {
return null;
}
String aft = expAfter.evaluate(exchange, String.class);
+ if (aft == null) {
+ // no delimiter (such as a missing header) then nothing comes after
+ return null;
+ }
return StringHelper.after(body, aft);
}
@@ -807,6 +796,10 @@ public final class StringExpressionBuilder {
}
String aft = expAfter.evaluate(exchange, String.class);
String bef = expBefore.evaluate(exchange, String.class);
+ if (aft == null || bef == null) {
+ // no delimiter (such as a missing header) then nothing comes between
+ return null;
+ }
return StringHelper.between(body, aft, bef);
}
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/DateFunctionFactory.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/DateFunctionFactory.java
index 83ac233574ca..18ff73ab6b00 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/DateFunctionFactory.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/DateFunctionFactory.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.language.simple.functions;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
import org.apache.camel.language.simple.DateExpressionBuilder;
@@ -30,6 +33,8 @@ import static org.apache.camel.language.simple.SimpleFunctionHelper.ifStartsWith
*/
public final class DateFunctionFactory implements SimpleLanguageFunctionFactory {
+ private static final Pattern TIMEZONE_WITH_COLON = Pattern.compile("((?:GMT|UTC)?[+-]\\d{1,2}:\\d{2}):(.+)");
+
@Override
public Expression createFunction(CamelContext camelContext, String function, int index) {
String remainder = ifStartsWithReturnRemainder("date-with-timezone:", function);
@@ -39,6 +44,11 @@ public final class DateFunctionFactory implements SimpleLanguageFunctionFactory
throw new SimpleParserException(
"Valid syntax: ${date-with-timezone:command:timezone:pattern} was: " + function, index);
}
+ // a timezone with an offset holds a colon itself, such as GMT+02:00
+ Matcher offset = TIMEZONE_WITH_COLON.matcher(remainder.substring(parts[0].length() + 1));
+ if (offset.matches()) {
+ return DateExpressionBuilder.dateExpression(parts[0], offset.group(1), offset.group(2));
+ }
return DateExpressionBuilder.dateExpression(parts[0], parts[1], parts[2]);
}
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/MathFunctionFactory.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/MathFunctionFactory.java
index 3dc6e11cefe3..175b624c2b97 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/MathFunctionFactory.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/functions/MathFunctionFactory.java
@@ -79,7 +79,8 @@ public final class MathFunctionFactory implements SimpleLanguageFunctionFactory
if (ObjectHelper.isNotEmpty(values)) {
return StringQuoteHelper.splitSafeQuote(values, ',', true, false);
}
- return null;
+ // no values, such as ${sum()}, then use the message body
+ return new String[] { "${body}" };
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleStringMathDateFunctionsTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleStringMathDateFunctionsTest.java
new file mode 100644
index 000000000000..898044a229e1
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleStringMathDateFunctionsTest.java
@@ -0,0 +1,144 @@
+/*
+ * 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.camel.language.simple;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.LanguageTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * CAMEL-24968: edge cases of the string, math, date and file functions.
+ */
+public class SimpleStringMathDateFunctionsTest extends LanguageTestSupport {
+
+ @Override
+ protected String getLanguageName() {
+ return "simple";
+ }
+
+ @Test
+ public void testCapitalizeEmpty() {
+ exchange.getMessage().setBody("");
+ assertExpression("${capitalize()}", "");
+ }
+
+ @Test
+ public void testMathWithoutArgumentsUsesTheBody() {
+ exchange.getMessage().setBody(List.of(10, 20, 30));
+ assertExpression("${sum()}", 60L);
+ assertExpression("${max()}", 30L);
+ assertExpression("${min()}", 10L);
+ assertExpression("${average()}", 20L);
+ }
+
+ @Test
+ public void testDateHeaderWithDashOrDot() {
+ Date date = new Date(0);
+ exchange.getMessage().setHeader("Last-Modified", date);
+ exchange.getMessage().setHeader("X-Date", date);
+ exchange.getMessage().setHeader("my.date", date);
+ assertExpression("${date:header.Last-Modified}", date);
+ assertExpression("${date:header.X-Date}", date);
+ assertExpression("${date:header.my.date}", date);
+ // an offset still works after a name with a dash
+ assertExpression("${date:header.Last-Modified+1s}", new Date(1000));
+ assertExpression("${date:header.Last-Modified - 1s}", new Date(-1000));
+ }
+
+ @Test
+ public void testDateWithTimezoneOffset() {
+ exchange.getMessage().setHeader("d", new Date(0));
+ assertExpression("${date-with-timezone:header.d:GMT+02:00:HH:mm}", "02:00");
+ assertExpression("${date-with-timezone:header.d:UTC:HH:mm}", "00:00");
+ }
+
+ @Test
+ public void testSafeQuoteIsValidJson() {
+ exchange.getMessage().setBody("He said \"hi\"");
+ assertExpression("${safeQuote()}", "\"He said \\\"hi\\\"\"");
+ exchange.getMessage().setBody("C:\\temp");
+ assertExpression("${safeQuote()}", "\"C:\\\\temp\"");
+ // already quoted once is not quoted twice
+ exchange.getMessage().setBody("\"Hello\"");
+ assertExpression("${safeQuote()}", "\"Hello\"");
+ // numbers are not quoted, also BigDecimal as from a JSON document
+ exchange.getMessage().setBody(new BigDecimal("12.50"));
+ assertExpression("${safeQuote()}", new BigDecimal("12.50"));
+ }
+
+ @Test
+ public void testKindOfType() {
+ exchange.getMessage().setBody(new BigDecimal("1.5"));
+ assertExpression("${kindOfType()}", "number");
+ exchange.getMessage().setBody(Map.of("a", 1));
+ assertExpression("${kindOfType()}", "object");
+ exchange.getMessage().setBody(new String[] { "a" });
+ assertExpression("${kindOfType()}", "array");
+ }
+
+ @Test
+ public void testSubstringWithNullArguments() {
+ exchange.getMessage().setBody("abc");
+ Exception e = assertThrows(Exception.class, () -> evaluate("${substring(${header.none})}"));
+ assertTrue(e.getMessage().contains("substring number expression evaluated to null"), e.getMessage());
+ // no delimiter then nothing comes before/after/between
+ assertExpression("${substringBefore(${header.none})}", null);
+ assertExpression("${substringAfter(${header.none})}", null);
+ assertExpression("${substringBetween(${header.none},'c')}", null);
+ }
+
+ @Test
+ public void testPadWithSeveralCharacters() {
+ assertExpression("${pad('foo',6,'ab')}", "fooaba");
+ assertExpression("${pad('foo',-6,'ab')}", "abafoo");
+ assertExpression("${pad('42',-5,'0')}", "00042");
+ assertExpression("${pad('Hi',4)}", "Hi ");
+ }
+
+ @Test
+ public void testSizeAndLengthOfAnyArray() {
+ exchange.getMessage().setBody(new Integer[] { 1, 2, 3 });
+ assertExpression("${size()}", 3);
+ assertExpression("${length()}", 3);
+ exchange.getMessage().setBody(new Object[] { "a", "b" });
+ assertExpression("${size()}", 2);
+ exchange.getMessage().setBody(new boolean[] { true });
+ assertExpression("${size()}", 1);
+ }
+
+ @Test
+ public void testHiddenFileName() {
+ exchange.getMessage().setHeader(Exchange.FILE_NAME, ".bashrc");
+ assertExpression("${file:name.noext}", ".bashrc");
+ assertExpression("${file:ext}", null);
+ exchange.getMessage().setHeader(Exchange.FILE_NAME, ".route.yaml");
+ assertExpression("${file:name.noext}", ".route");
+ assertExpression("${file:ext}", "yaml");
+ }
+
+ private Object evaluate(String text) {
+ return context.resolveLanguage("simple").createExpression(text).evaluate(exchange, Object.class);
+ }
+}
diff --git a/core/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java b/core/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
index 2077cfde05c6..2d9bfedebc43 100644
--- a/core/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
@@ -125,6 +125,11 @@ public class FileUtilTest extends TestSupport {
assertEquals("foo", FileUtil.stripExt("foo"));
assertEquals("foo", FileUtil.stripExt("foo.xml"));
assertEquals("/foo/bar", FileUtil.stripExt("/foo/bar.xml"));
+ // hidden files
+ assertEquals(".bashrc", FileUtil.stripExt(".bashrc"));
+ assertEquals("/home/.bashrc", FileUtil.stripExt("/home/.bashrc"));
+ assertEquals(".route", FileUtil.stripExt(".route.yaml"));
+ assertEquals("/home/.route", FileUtil.stripExt("/home/.route.yaml"));
}
@Test
@@ -135,6 +140,12 @@ public class FileUtilTest extends TestSupport {
assertEquals("xml", FileUtil.onlyExt("/foo/bar.xml"));
assertEquals("tar.gz", FileUtil.onlyExt("/foo/bigfile.tar.gz"));
assertEquals("tar.gz", FileUtil.onlyExt("/foo.bar/bigfile.tar.gz"));
+ // hidden files
+ assertNull(FileUtil.onlyExt(".bashrc"));
+ assertNull(FileUtil.onlyExt("/home/.bashrc"));
+ assertNull(FileUtil.onlyExt(".bashrc", true));
+ assertEquals("yaml", FileUtil.onlyExt(".route.yaml"));
+ assertEquals("yaml", FileUtil.onlyExt(".route.yaml", true));
}
@Test
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/LanguageHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/LanguageHelper.java
index 9cd4e6706511..ea627dafa813 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/LanguageHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/LanguageHelper.java
@@ -244,20 +244,23 @@ public final class LanguageHelper {
public static Date dateFromExchangeProperty(
Exchange exchange, String command, BiFunction<Exchange, Object, Date> orElseFunction) {
- final String key = command.substring(command.lastIndexOf('.') + 1);
+ // the key may contain dots, such as header.my.date
+ final String key = command.substring(command.indexOf('.') + 1);
final Object obj = exchange.getProperty(key);
return toDate(exchange, orElseFunction, obj);
}
public static Date dateFromHeader(Exchange exchange, String command, BiFunction<Exchange, Object, Date> orElseFunction) {
- final String key = command.substring(command.lastIndexOf('.') + 1);
+ // the key may contain dots, such as header.my.date
+ final String key = command.substring(command.indexOf('.') + 1);
final Object obj = exchange.getMessage().getHeader(key);
return toDate(exchange, orElseFunction, obj);
}
public static Date dateFromVariable(Exchange exchange, String command, BiFunction<Exchange, Object, Date> orElseFunction) {
- final String key = command.substring(command.lastIndexOf('.') + 1);
+ // the key may contain dots, such as header.my.date
+ final String key = command.substring(command.indexOf('.') + 1);
final Object obj = exchange.getVariable(key);
return toDate(exchange, orElseFunction, obj);
}
diff --git a/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java b/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java
index 32162e6fc9f8..2f52477215c2 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java
@@ -201,13 +201,14 @@ public final class FileUtil {
if (pos > 0) {
String onlyName = name.substring(pos + 1);
- int pos2 = singleMode ? onlyName.lastIndexOf('.') : onlyName.indexOf('.');
+ // a leading dot is a hidden file (such as .bashrc), not an extension
+ int pos2 = singleMode ? onlyName.lastIndexOf('.') : onlyName.indexOf('.', 1);
if (pos2 > 0) {
return name.substring(0, pos + pos2 + 1);
}
} else {
// if single ext mode, then only return last extension
- int pos2 = singleMode ? name.lastIndexOf('.') : name.indexOf('.');
+ int pos2 = singleMode ? name.lastIndexOf('.') : name.indexOf('.', 1);
if (pos2 > 0) {
return name.substring(0, pos2);
}
@@ -228,8 +229,9 @@ public final class FileUtil {
// extension is the first dot, as a file may have double extension such as .tar.gz
// if single ext mode, then only return last extension
- int pos = singleMode ? name.lastIndexOf('.') : name.indexOf('.');
- if (pos != -1) {
+ // a leading dot is a hidden file (such as .bashrc), not an extension
+ int pos = singleMode ? name.lastIndexOf('.') : name.indexOf('.', 1);
+ if (pos > 0) {
return name.substring(pos + 1);
}
return null;
diff --git a/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java b/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java
index 7e37a000d964..06ec5a11697e 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/StringHelper.java
@@ -556,8 +556,8 @@ public final class StringHelper {
}
private static String doCapitalize(String ret, boolean all) {
- if (ret == null) {
- return null;
+ if (ret == null || ret.isEmpty()) {
+ return ret;
}
final char[] chars = ret.toCharArray();
@@ -566,10 +566,10 @@ public final class StringHelper {
// for which it does not return the capitalized value should not be used here (this is
// mostly used to capitalize setters/getters)
chars[0] = Character.toUpperCase(chars[0]);
- if (all && chars.length > 2) {
- for (int i = 2; i < chars.length; i++) {
+ if (all) {
+ for (int i = 1; i < chars.length; i++) {
char prev = chars[i - 1];
- if (prev == ' ') {
+ if (Character.isWhitespace(prev)) {
chars[i] = Character.toUpperCase(chars[i]);
}
}
diff --git a/core/camel-util/src/test/java/org/apache/camel/util/StringHelperTest.java b/core/camel-util/src/test/java/org/apache/camel/util/StringHelperTest.java
index c6bf59aaa6a5..18809ec57ac5 100644
--- a/core/camel-util/src/test/java/org/apache/camel/util/StringHelperTest.java
+++ b/core/camel-util/src/test/java/org/apache/camel/util/StringHelperTest.java
@@ -621,6 +621,11 @@ public class StringHelperTest {
public void testCapitalizeAll() {
assertNull(StringHelper.capitalizeAll(null));
assertEquals("Hello World How Are You", StringHelper.capitalizeAll("hello world how are you"));
+ assertEquals("", StringHelper.capitalizeAll(""));
+ assertEquals("", StringHelper.capitalize(""));
+ assertEquals(" Hello World", StringHelper.capitalizeAll(" hello world"));
+ assertEquals("A B", StringHelper.capitalizeAll("a b"));
+ assertEquals("Hello\tWorld\nAgain", StringHelper.capitalizeAll("hello\tworld\nagain"));
}
@Test
(camel) 06/11: CAMEL-24965: simple - fix init block comments, one-liners, CRLF, predicates and local functions
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch fix/CAMEL-24962
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 3bd9ca7e4aadb5b53dc9396d9e58afe5bc82e10a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 23 18:59:58 2026 +0200
CAMEL-24965: simple - fix init block comments, one-liners, CRLF, predicates and local functions
- a // comment in the init block is ignored, so a commented out assignment no longer runs
- several statements on one line work ($init{ $a := 1; $b := 2; }init$), and Windows line endings
- a predicate whose init block only defines functions ($f ~:= ...) parses, and $f() works in predicates
- a custom function from an init block is not shared through the cache with another expression
that defines a function with the same name
- $fn('x') in a chain keeps its argument
- errors in the init block point at the right place
- sync the catalog copies of the simple docs and metadata
Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
.../apache/camel/catalog/docs/simple-advanced.adoc | 2 +-
.../camel/catalog/docs/simple-functions.adoc | 7 +-
.../org/apache/camel/catalog/languages/simple.json | 2 +-
.../modules/languages/pages/simple-advanced.adoc | 2 +-
.../language/simple/MiscExpressionBuilder.java | 1 -
.../language/simple/SimpleExpressionParser.java | 26 +----
.../language/simple/SimpleInitBlockParser.java | 128 +++++++++++++++------
.../language/simple/SimplePredicateParser.java | 20 +---
.../language/simple/StringExpressionBuilder.java | 1 -
.../camel/language/simple/ast/ChainExpression.java | 2 +-
.../simple/ast/SimpleFunctionExpression.java | 4 +-
.../simple/SimpleInitBlockEdgeCasesTest.java | 111 ++++++++++++++++++
12 files changed, 220 insertions(+), 86 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-advanced.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-advanced.adoc
index daed623fcfef..1e22bcd72c3e 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-advanced.adoc
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-advanced.adoc
@@ -29,7 +29,7 @@ Notice how the block uses the `$init{` ... `}init$` markers to indicate the star
Inside the init block, then you can assign local variables in the syntax `$key := <statement>;` where you can then use simple language to compute
the value of the variable.
-IMPORTANT: Each statement must end with semicolon and new-line (`;\n`). You can only have 1 statement per line.
+IMPORTANT: Each statement must end with a semicolon (`;`). Statements are usually one per line, but several statements can also be on one line when separated by a space, such as `$init{ $a := 1; $b := 2; }init$`.
This makes the init block more similar to Java programming language,
and it was also necessary to make this work for the internal simple parser used by Camel.
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-functions.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-functions.adoc
index 525d77ecd2f1..41d80e7bbcf8 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-functions.adoc
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/simple-functions.adoc
@@ -520,7 +520,7 @@ The string functions is various functions to work with values that are String an
|`lowercase(exp)` | `String` | Lowercases the expression
|`normalizeWhitespace()` | `String` | Normalizes the whitespace in the message body by cleaning up excess whitespaces.
|`normalizeWhitespace(exp)` | `String` | Normalizes the whitespace in the expression by cleaning up excess whitespaces.
-|`pad(exp,width,separator)` | `String` | Pads the expression with extra padding if necessary, according the total width The separator is by default a space. If the width is negative then padding to the right, otherwise to the left.
+|`pad(exp,width,separator)` | `String` | Pads the expression with extra padding if necessary, according to the total width. The separator is by default a space. A positive width pads to the right (after the value), and a negative width pads to the left (before the value).
|`replace(from,to)` | `String` | Replace all the string values in the message body. To make it easier to replace single and double quotes, then you can use XML escaped values `\"` as double quote, `\'` as single quote, and `\∅` as empty value.
|`replace(from,to,exp)` | `String` | Replace all the string values in the given expression. To make it easier to replace single and double quotes, then you can use XML escaped values `\"` as double quote, `\'` as single quote, and `\∅` as empty value.
|`safeQuote()` | `String` | Returns the message body safely quoted if needed
@@ -636,13 +636,16 @@ If the value is currently in single quote, then this will be converted to double
If the message body contains `Hello World` then `${quote()}` returns `"Hello World"`.
And using `${quote('Hi from me')}` then `"Hi from me"` is returned.
+The `quote` function does not escape the value, so a value with double quotes or backslashes is not a valid JSON string;
+use `safeQuote` (or `escape(json)`) for JSON.
The `unquote` function removes any surrounding single or double quotes from a value.
If the body contains `'hello'` then `${unquote()}` returns `hello` (without the quotes).
The `safeQuote` function is quoting the value depending on the value type
(uses the same logic as `kindOfType` function). In essence values that are null, boolean or numbers are not quoted,
-while everything else is. The `safeQuote` function is useful when working with JSON data.
+while everything else is. When quoted, double quotes, backslashes and control characters in the value are escaped,
+so the result is a valid JSON string. The `safeQuote` function is useful when working with JSON data.
For example when doing JSON to JSON mapping you can extract values form the source document,
to be included in the output, but the values may or may not need to be quoted. Then you can use the `~>` chain operator
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json
index a1df2fe174f9..dfc3d543b094 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/languages/simple.json
@@ -131,7 +131,7 @@
"not": { "index": 102, "kind": "function", "displayName": "Not", "group": "condition", "label": "condition", "required": false, "javaType": "boolean", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Evaluates the predicate and returns the opposite.", "ognl": false, "suffix": "}" },
"null": { "index": 103, "kind": "function", "displayName": "Null", "group": "other", "label": "other", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Returns a null value", "ognl": false, "suffix": "}", "examples": [ "${null} -> null" ] },
"originalBody": { "index": 104, "kind": "function", "displayName": "Original Body", "group": "core", "label": "core", "required": false, "javaType": "Object", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The original incoming body (only available if allowUseOriginalMessage=true).", "ognl": false, "suffix": "}" },
- "pad(exp,width,separator)": { "index": 105, "kind": "function", "displayName": "Pad String", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Pads the expression with extra padding if necessary, according the the total width. The separator is by default a space. If the width is negative then padding to the right, otherwise to the left.", "ognl [...]
+ "pad(exp,width,separator)": { "index": 105, "kind": "function", "displayName": "Pad String", "group": "string", "label": "string", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Pads the expression with extra padding if necessary, according to the total width. The separator is by default a space. A positive width pads to the right (after the value), and a negative width pads to [...]
"pretty(exp)": { "index": 106, "kind": "function", "displayName": "Pretty Print", "group": "xml", "label": "json,xml", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the expression to a String, and attempts to pretty print if JSon or XML, otherwise the expression is returned as the String value.", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "O [...]
"prettyBody": { "index": 107, "kind": "function", "displayName": "Pretty Body", "group": "xml", "label": "json,xml", "required": false, "javaType": "String", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Converts the body to a String, and attempts to pretty print if JSon or XML; otherwise the body is returned as the String value.", "ognl": false, "suffix": "}" },
"sort(exp,reverse)": { "index": 108, "kind": "function", "displayName": "Sort", "group": "collection", "label": "collection", "required": false, "javaType": "List", "prefix": "${", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sorts the message body or expression in natural order", "ognl": false, "suffix": "}", "params": [ { "name": "exp", "javaType": "Object", "required": false, "defaultValue": "body", "description": "The expression [...]
diff --git a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-advanced.adoc b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-advanced.adoc
index daed623fcfef..1e22bcd72c3e 100644
--- a/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-advanced.adoc
+++ b/core/camel-core-languages/src/main/docs/modules/languages/pages/simple-advanced.adoc
@@ -29,7 +29,7 @@ Notice how the block uses the `$init{` ... `}init$` markers to indicate the star
Inside the init block, then you can assign local variables in the syntax `$key := <statement>;` where you can then use simple language to compute
the value of the variable.
-IMPORTANT: Each statement must end with semicolon and new-line (`;\n`). You can only have 1 statement per line.
+IMPORTANT: Each statement must end with a semicolon (`;`). Statements are usually one per line, but several statements can also be on one line when separated by a space, such as `$init{ $a := 1; $b := 2; }init$`.
This makes the init block more similar to Java programming language,
and it was also necessary to make this work for the internal simple parser used by Camel.
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MiscExpressionBuilder.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MiscExpressionBuilder.java
index 5adb2c781128..6e497e5dc05f 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MiscExpressionBuilder.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/MiscExpressionBuilder.java
@@ -27,7 +27,6 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
-import java.util.Map;
import java.util.Random;
import java.util.concurrent.atomic.AtomicReference;
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleExpressionParser.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleExpressionParser.java
index eacaf07a7e8e..93809e9e5f08 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleExpressionParser.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleExpressionParser.java
@@ -17,7 +17,6 @@
package org.apache.camel.language.simple;
import java.util.ArrayList;
-import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
@@ -81,31 +80,8 @@ public class SimpleExpressionParser extends BaseSimpleParser {
if (SimpleInitBlockTokenizer.hasInitBlock(expression)) {
SimpleInitBlockParser initParser
= new SimpleInitBlockParser(camelContext, expression, allowEscape, skipFileFunctions, cacheExpression);
- // the init block should be parsed in predicate mode as that is needed to fully parse with all the operators and functions
init = initParser.parseExpression();
- String part = StringHelper.after(expression, SimpleInitBlockTokenizer.INIT_END);
- if (part.startsWith("\n")) {
- // skip newline after ending init block
- part = part.substring(1);
- }
- this.expression = part;
- // use $$key as local variable in the expression afterwards.
- // Sort by descending length so a longer key (e.g. "$ab") is replaced before any
- // shorter prefix (e.g. "$a"), preventing "$ab" from becoming "${variable.a}b".
- List<String> sortedKeys = new ArrayList<>(initParser.getInitKeys());
- sortedKeys.sort(Comparator.comparingInt(String::length).reversed());
- for (String key : sortedKeys) {
- this.expression = this.expression.replace("$" + key, "${variable." + key + "}");
- }
- // use $$key() as local function in the expression afterwards
- List<String> sortedFunctions = new ArrayList<>(initParser.getInitFunctions());
- sortedFunctions.sort(Comparator.comparingInt(String::length).reversed());
- for (String key : sortedFunctions) {
- // no-arg functions
- this.expression = this.expression.replace("$" + key + "()", "${function(" + key + ")}");
- // arg functions
- this.expression = this.expression.replace("${" + key + "(", "${function(" + key + ",");
- }
+ this.expression = initParser.rewriteExpressionAfterInitBlock(expression);
}
// parse simple expression
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleInitBlockParser.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleInitBlockParser.java
index 8bbc06dfdeff..75a509ce4c19 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleInitBlockParser.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleInitBlockParser.java
@@ -17,6 +17,7 @@
package org.apache.camel.language.simple;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -30,6 +31,7 @@ import org.apache.camel.language.simple.ast.LiteralExpression;
import org.apache.camel.language.simple.ast.LiteralNode;
import org.apache.camel.language.simple.ast.SimpleNode;
import org.apache.camel.language.simple.types.InitOperatorType;
+import org.apache.camel.language.simple.types.SimpleParserException;
import org.apache.camel.language.simple.types.SimpleToken;
import org.apache.camel.language.simple.types.TokenType;
import org.apache.camel.util.StringHelper;
@@ -42,10 +44,93 @@ class SimpleInitBlockParser extends SimpleExpressionParser {
public SimpleInitBlockParser(CamelContext camelContext, String expression, boolean allowEscape, boolean skipFileFunctions,
Map<String, Expression> cacheExpression) {
super(camelContext,
- StringHelper.between(expression, SimpleInitBlockTokenizer.INIT_START, SimpleInitBlockTokenizer.INIT_END),
+ normalize(StringHelper.between(expression, SimpleInitBlockTokenizer.INIT_START,
+ SimpleInitBlockTokenizer.INIT_END)),
allowEscape, skipFileFunctions, cacheExpression, new SimpleInitBlockTokenizer());
}
+ /**
+ * Prepares the text of the init block for the tokenizer, keeping every character at its index so errors point at
+ * the right place.
+ * <ul>
+ * <li>a // comment (outside quotes and functions) is blanked out, so a commented out assignment does not run</li>
+ * <li>Windows line endings are turned into unix line endings</li>
+ * <li>a ; followed by a space ends the statement as a new line does, so one-liners such as {@code $init{ $a := 1;
+ * $b := 2; }init$} work</li>
+ * </ul>
+ */
+ static String normalize(String text) {
+ if (text == null) {
+ return null;
+ }
+ char[] chars = text.toCharArray();
+ boolean single = false;
+ boolean dubble = false;
+ int depth = 0;
+ for (int i = 0; i < chars.length; i++) {
+ char c = chars[i];
+ char next = i + 1 < chars.length ? chars[i + 1] : 0;
+ if (c == '\r' && next == '\n') {
+ // keep the new line right after the statement end (;)
+ chars[i] = '\n';
+ chars[i + 1] = ' ';
+ } else if (c == '\'' && !dubble) {
+ single = !single;
+ } else if (c == '"' && !single) {
+ dubble = !dubble;
+ } else if (single || dubble) {
+ continue;
+ } else if (c == '$' && next == '{') {
+ depth++;
+ } else if (c == '}' && depth > 0) {
+ depth--;
+ } else if (depth == 0 && c == '/' && next == '/') {
+ // blank out the comment until the end of the line
+ while (i < chars.length && chars[i] != '\n') {
+ chars[i++] = ' ';
+ }
+ } else if (depth == 0 && c == ';' && (next == ' ' || next == '\t')) {
+ chars[i + 1] = '\n';
+ }
+ }
+ String answer = new String(chars);
+ if (answer.stripTrailing().endsWith(";")) {
+ // the last statement ends without a new line
+ answer = answer.stripTrailing() + "\n";
+ }
+ return answer;
+ }
+
+ /**
+ * The expression after the init block, where the init variables ($key) and init functions ($key() and ${key(...)})
+ * are rewritten to ${variable.key} and ${function(key)}.
+ */
+ String rewriteExpressionAfterInitBlock(String expression) {
+ String answer = StringHelper.after(expression, SimpleInitBlockTokenizer.INIT_END);
+ if (answer.startsWith("\r\n")) {
+ // skip newline after ending init block
+ answer = answer.substring(2);
+ } else if (answer.startsWith("\n")) {
+ answer = answer.substring(1);
+ }
+ // Sort by descending length so a longer key (e.g. "$ab") is replaced before any
+ // shorter prefix (e.g. "$a"), preventing "$ab" from becoming "${variable.a}b".
+ List<String> sortedKeys = new ArrayList<>(initKeys);
+ sortedKeys.sort(Comparator.comparingInt(String::length).reversed());
+ for (String key : sortedKeys) {
+ answer = answer.replace("$" + key, "${variable." + key + "}");
+ }
+ List<String> sortedFunctions = new ArrayList<>(initFunctions);
+ sortedFunctions.sort(Comparator.comparingInt(String::length).reversed());
+ for (String key : sortedFunctions) {
+ // no-arg functions
+ answer = answer.replace("$" + key + "()", "${function(" + key + ")}");
+ // arg functions
+ answer = answer.replace("${" + key + "(", "${function(" + key + ",");
+ }
+ return answer;
+ }
+
public Set<String> getInitKeys() {
return initKeys;
}
@@ -60,9 +145,14 @@ class SimpleInitBlockParser extends SimpleExpressionParser {
@Override
public Expression parseExpression() {
- // parse init block
- parseInitTokens();
- return doParseInitExpression();
+ try {
+ // parse init block
+ parseInitTokens();
+ return doParseInitExpression();
+ } catch (SimpleParserException e) {
+ // the index is within the init block, so make it point into the whole expression
+ throw new SimpleParserException(e.getMessage(), e.getIndex() + SimpleInitBlockTokenizer.INIT_START.length());
+ }
}
protected List<SimpleNode> parseInitTokens() {
@@ -201,34 +291,4 @@ class SimpleInitBlockParser extends SimpleExpressionParser {
return text;
}
- @Deprecated
- protected void prepareInitBlocks() {
- List<SimpleNode> answer = new ArrayList<>();
- for (int i = 1; i < nodes.size() - 1; i++) {
- SimpleNode token = nodes.get(i);
- if (token instanceof InitBlockExpression ie) {
- SimpleNode prev = nodes.get(i - 1);
- SimpleNode next = nodes.get(i + 1);
- ie.acceptLeftNode(prev);
- ie.acceptRightNode(next);
- answer.add(ie);
-
- // remember which init variables we have created
- if (prev instanceof LiteralNode ln) {
- String key = StringHelper.after(ln.getText(), "$");
- if (key != null) {
- key = key.trim();
- if (ie.getOperator().equals(InitOperatorType.CHAIN_ASSIGNMENT)) {
- initFunctions.add(key);
- } else {
- initKeys.add(key);
- }
- }
- }
- }
- }
- nodes.clear();
- nodes.addAll(answer);
- }
-
}
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimplePredicateParser.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimplePredicateParser.java
index 6cea00cfba2b..c9bde8c99ae8 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimplePredicateParser.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimplePredicateParser.java
@@ -19,7 +19,6 @@ package org.apache.camel.language.simple;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Deque;
import java.util.Iterator;
import java.util.List;
@@ -58,7 +57,6 @@ import org.apache.camel.language.simple.types.SimpleToken;
import org.apache.camel.language.simple.types.TokenType;
import org.apache.camel.support.ExpressionToPredicateAdapter;
import org.apache.camel.support.builder.PredicateBuilder;
-import org.apache.camel.util.StringHelper;
/**
* A parser to parse simple language as a Camel {@link Predicate}
@@ -91,22 +89,8 @@ public class SimplePredicateParser extends BaseSimpleParser {
SimpleInitBlockParser initParser
= new SimpleInitBlockParser(camelContext, expression, allowEscape, skipFileFunctions, cacheExpression);
init = initParser.parseExpression();
- if (init != null) {
- String part = StringHelper.after(expression, SimpleInitBlockTokenizer.INIT_END);
- if (part.startsWith("\n")) {
- // skip newline after ending init block
- part = part.substring(1);
- }
- this.expression = part;
- // use $$key as local variable in the expression afterwards.
- // Sort by descending length so a longer key (e.g. "$ab") is replaced before any
- // shorter prefix (e.g. "$a"), preventing "$ab" from becoming "${variable.a}b".
- List<String> sortedKeys = new ArrayList<>(initParser.getInitKeys());
- sortedKeys.sort(Comparator.comparingInt(String::length).reversed());
- for (String key : sortedKeys) {
- this.expression = this.expression.replace("$" + key, "${variable." + key + "}");
- }
- }
+ // the init block may only define functions ($f ~:= ...) and then there is no init expression
+ this.expression = initParser.rewriteExpressionAfterInitBlock(expression);
}
parseTokens();
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/StringExpressionBuilder.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/StringExpressionBuilder.java
index 2c66feb6d0eb..e6bbf4d0bed6 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/StringExpressionBuilder.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/StringExpressionBuilder.java
@@ -31,7 +31,6 @@ import org.apache.camel.support.builder.ExpressionBuilder;
import org.apache.camel.support.builder.PredicateBuilder;
import org.apache.camel.util.EscapeHelper;
import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.StringHelper;
import org.apache.camel.util.StringQuoteHelper;
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/ChainExpression.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/ChainExpression.java
index b383d0772cd9..34847991d205 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/ChainExpression.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/ChainExpression.java
@@ -134,7 +134,7 @@ public class ChainExpression extends BaseSimpleNode {
if (PluginHelper.getSimpleFunctionRegistry(camelContext).getCustomFunctionNames().contains(key)) {
String changed = text.replace("$" + key + "()", "function(" + key + ")");
if (changed.equals(text)) {
- changed = text.replace("$" + key + "(", "function(" + key);
+ changed = text.replace("$" + key + "(", "function(" + key + ",");
}
le.replaceText(changed);
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 0b8f61958605..dc5204024177 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
@@ -65,7 +65,9 @@ public class SimpleFunctionExpression extends LiteralExpression {
if (answer != null) {
answer.init(camelContext);
}
- if (cacheExpression != null && answer != null) {
+ // a custom function from an init block ($f ~:= ...) is bound to the definition of that block,
+ // so it is not shared with another expression that defines a function with the same name
+ if (cacheExpression != null && answer != null && !function.startsWith("function(")) {
cacheExpression.put(function, answer);
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleInitBlockEdgeCasesTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleInitBlockEdgeCasesTest.java
new file mode 100644
index 000000000000..31f7fe420f56
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleInitBlockEdgeCasesTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.camel.language.simple;
+
+import org.apache.camel.LanguageTestSupport;
+import org.apache.camel.language.simple.types.SimpleIllegalSyntaxException;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+/**
+ * CAMEL-24965: edge cases of the init block.
+ */
+public class SimpleInitBlockEdgeCasesTest extends LanguageTestSupport {
+
+ @Override
+ protected String getLanguageName() {
+ return "simple";
+ }
+
+ @Test
+ public void testCommentedOutAssignmentDoesNotRun() {
+ assertExpression("""
+ $init{
+ // $foo := 'x';
+ $bar := 'y';
+ }init$
+ [${variable.foo}][$bar]""", "[][y]");
+ }
+
+ @Test
+ public void testCommentWithDollar() {
+ assertExpression("""
+ $init{
+ // costs $5
+ $bar := 'y'; // a trailing comment
+ }init$
+ [$bar]""", "[y]");
+ }
+
+ @Test
+ public void testCommentInsideQuotesIsText() {
+ assertExpression("""
+ $init{
+ $url := 'http://camel.apache.org';
+ }init$
+ $url""", "http://camel.apache.org");
+ }
+
+ @Test
+ public void testOneLiner() {
+ assertExpression("$init{ $minAge := 18; }init$[$minAge]", "[18]");
+ assertExpression("$init{ $a := 'x'; $b := 'y'; }init$[$a$b]", "[xy]");
+ // a ; inside a function or quotes is not the end of the statement
+ assertExpression("$init{ $a := 'x; y'; }init$[$a]", "[x; y]");
+ }
+
+ @Test
+ public void testWindowsLineEndings() {
+ assertExpression("$init{\r\n $a := 'x';\r\n $b := 'y';\r\n}init$\r\n[$a$b]", "[xy]");
+ }
+
+ @Test
+ public void testPredicateWithOnlyFunctions() {
+ exchange.getMessage().setBody(" A ");
+ assertPredicate("""
+ $init{
+ $clean ~:= ${trim()};
+ }init$
+ $clean() == 'A'""", true);
+ }
+
+ @Test
+ public void testCustomFunctionIsLocalToTheExpression() {
+ exchange.getMessage().setBody(" abc ");
+ assertExpression("""
+ $init{
+ $f ~:= ${trim()};
+ }init$
+ [$f()]""", "[abc]");
+ assertExpression("""
+ $init{
+ $f ~:= ${uppercase()};
+ }init$
+ [$f()]""", "[ ABC ]");
+ }
+
+ @Test
+ public void testErrorPointsIntoTheInitBlock() {
+ String text = "$init{\n $a = 5;\n}init$";
+ SimpleIllegalSyntaxException e = assertThrows(SimpleIllegalSyntaxException.class,
+ () -> context.resolveLanguage("simple").createExpression(text));
+ // the error is at the = which is not an init operator
+ assertEquals(text.indexOf('='), e.getIndex());
+ }
+}
(camel) 07/11: CAMEL-24964: simple - fix quotes, braces, chain and ternary edge cases in the parser
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch fix/CAMEL-24962
in repository https://gitbox.apache.org/repos/asf/camel.git
commit c6211c63109adac5fb4ddb44f4792a537f9d4765
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 23 19:04:07 2026 +0200
CAMEL-24964: simple - fix quotes, braces, chain and ternary edge cases in the parser
- a single quote inside double quotes in a function no longer breaks the predicate:
${body.replace("'", "")} == 'x' was true for any body
- a } inside double quotes no longer breaks what follows
- a chain followed by an operator with a number or null: ${body} ~> ${length()} > 5
- ~> needs a space on both sides, so A~>B and ${body.replace('~>', '-')} are text
- ${body == 'a > b'} compares with == (operators inside quotes are text)
- ${bean:svc?method=echo('10:30')} is not a ternary: ? and : need whitespace around them
- fix numericSupported typo in the binary operator grammar
Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
.../language/simple/SimplePredicateParser.java | 23 ++++--
.../camel/language/simple/SimpleSyntaxHints.java | 57 +++++++++++---
.../camel/language/simple/SimpleTokenizer.java | 4 +
.../language/simple/ast/SimpleFunctionStart.java | 9 ++-
.../language/simple/SimpleParserEdgeCasesTest.java | 89 ++++++++++++++++++++++
5 files changed, 162 insertions(+), 20 deletions(-)
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimplePredicateParser.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimplePredicateParser.java
index c9bde8c99ae8..3e28d2b9184c 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimplePredicateParser.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimplePredicateParser.java
@@ -389,19 +389,25 @@ public class SimplePredicateParser extends BaseSimpleParser {
tokens.removeIf(t -> t.getType().isIgnore());
// white space can be removed if its not part of a quoted text or within function(s)
- boolean quote = false;
+ // a single quote inside double quotes (and vice versa) is text, such as ${body.replace("'", "")}
+ boolean single = false;
+ boolean dubble = false;
int functionCount = 0;
Iterator<SimpleToken> it = tokens.iterator();
while (it.hasNext()) {
SimpleToken token = it.next();
- if (token.getType().isSingleQuote()) {
- quote = !quote;
- } else if (!quote) {
+ if (token.getType().isSingleQuote() && !dubble) {
+ single = !single;
+ } else if (token.getType().isDoubleQuote() && !single) {
+ dubble = !dubble;
+ } else if (!single && !dubble) {
if (token.getType().isFunctionStart()) {
functionCount++;
} else if (token.getType().isFunctionEnd()) {
- functionCount--;
+ if (functionCount > 0) {
+ functionCount--;
+ }
} else if (token.getType().isWhitespace() && functionCount == 0) {
it.remove();
}
@@ -702,7 +708,7 @@ public class SimplePredicateParser extends BaseSimpleParser {
literalSupported |= parameterType.isLiteralSupported();
literalWithFunctionsSupported |= parameterType.isLiteralWithFunctionSupport();
functionSupported |= parameterType.isFunctionSupport();
- nullSupported |= parameterType.isNumericValueSupported();
+ numericSupported |= parameterType.isNumericValueSupported();
booleanSupported |= parameterType.isBooleanValueSupported();
nullSupported |= parameterType.isNullValueSupported();
minusSupported |= parameterType.isMinusValueSupported();
@@ -809,9 +815,10 @@ public class SimplePredicateParser extends BaseSimpleParser {
|| booleanValue()
|| nullValue()) {
// then after the right hand side value, there should be a whitespace if there is more tokens
+ // (do not accept more, as the token after the whitespace, such as an operator, is parsed next)
nextToken();
if (!token.getType().isEol()) {
- expectAndAcceptMore(TokenType.whiteSpace);
+ expect(TokenType.whiteSpace);
}
} else {
throw new SimpleParserException(
@@ -870,6 +877,8 @@ public class SimplePredicateParser extends BaseSimpleParser {
}
protected boolean minusValue() {
+ // note: this skips the current token without checking it is a minus sign, which is lenient on purpose
+ // as routes may compare with unquoted text such as ${header.version} == v2
nextToken();
return accept(TokenType.numericValue);
// no other tokens to check so do not use nextToken
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleSyntaxHints.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleSyntaxHints.java
index a046b1294e53..f39dbb5c30be 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleSyntaxHints.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleSyntaxHints.java
@@ -204,26 +204,59 @@ public final class SimpleSyntaxHints {
/** Wraps the left hand side of one comparison with {@code ${ }} when it is a function reference. */
private static String wrapComparison(String text) {
+ // the first operator outside quotes, so ${body == 'a > b'} is compared with ==
+ String first = null;
+ int firstAt = -1;
for (String op : SPACED_OPERATORS) {
- int at = text.indexOf(op);
- if (at < 0 && text.endsWith(op.stripTrailing())) {
- // the operator ends the text: wrap what is there, so the parser says what is missing after it
- at = text.length() - op.stripTrailing().length();
+ int at = indexOutsideQuotes(text, op);
+ if (at > 0 && (firstAt < 0 || at < firstAt)) {
+ firstAt = at;
+ first = op;
}
- if (at > 0) {
- String left = text.substring(0, at).trim();
- String right = at + op.length() <= text.length() ? text.substring(at + op.length()).trim() : "";
- if (!left.startsWith("${") && !left.startsWith("'") && !left.startsWith("\"")
- && !isNumeric(left) && !"true".equalsIgnoreCase(left)
- && !"false".equalsIgnoreCase(left) && !"null".equalsIgnoreCase(left)) {
- left = "${" + left + "}";
+ }
+ if (first != null) {
+ return wrapComparison(text, first, firstAt);
+ }
+ for (String op : SPACED_OPERATORS) {
+ if (text.endsWith(op.stripTrailing())) {
+ // the operator ends the text: wrap what is there, so the parser says what is missing after it
+ int at = text.length() - op.stripTrailing().length();
+ if (at > 0) {
+ return wrapComparison(text, op, at);
}
- return left + op + right;
}
}
return text;
}
+ private static String wrapComparison(String text, String op, int at) {
+ String left = text.substring(0, at).trim();
+ String right = at + op.length() <= text.length() ? text.substring(at + op.length()).trim() : "";
+ if (!left.startsWith("${") && !left.startsWith("'") && !left.startsWith("\"")
+ && !isNumeric(left) && !"true".equalsIgnoreCase(left)
+ && !"false".equalsIgnoreCase(left) && !"null".equalsIgnoreCase(left)) {
+ left = "${" + left + "}";
+ }
+ return left + op + right;
+ }
+
+ /** The index of the text outside single and double quotes, or -1. */
+ private static int indexOutsideQuotes(String text, String find) {
+ boolean single = false;
+ boolean dubble = false;
+ for (int i = 0; i < text.length(); i++) {
+ char c = text.charAt(i);
+ if (c == '\'' && !dubble) {
+ single = !single;
+ } else if (c == '"' && !single) {
+ dubble = !dubble;
+ } else if (!single && !dubble && text.startsWith(find, i)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
private static boolean isNumeric(String text) {
if (text == null || text.isEmpty()) {
return false;
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleTokenizer.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleTokenizer.java
index 4b4ae0956b67..65ece116c6eb 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleTokenizer.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleTokenizer.java
@@ -291,6 +291,10 @@ public class SimpleTokenizer {
if (token.isTernary()) {
return evalTernary(token, text, expression, index);
}
+ if (token.isChain()) {
+ // like the other infix operators, so text such as A~>B is not a chain
+ return evalSurroundedBySpace(token, text, expression, index);
+ }
return text.startsWith(token.getValue());
}
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionStart.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionStart.java
index 54a320073a09..809398525d62 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionStart.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionStart.java
@@ -340,6 +340,11 @@ public class SimpleFunctionStart extends BaseSimpleNode implements BlockStart {
/**
* Find the index of the ternary operator character, skipping nested ${}, quotes, etc.
*/
+ private static boolean surroundedByWhitespace(String text, int index) {
+ return index > 0 && index < text.length() - 1
+ && Character.isWhitespace(text.charAt(index - 1)) && Character.isWhitespace(text.charAt(index + 1));
+ }
+
private int findTernaryOperator(String text, char operator) {
int depth = 0;
boolean inSingleQuote = false;
@@ -366,7 +371,9 @@ public class SimpleFunctionStart extends BaseSimpleNode implements BlockStart {
inDoubleQuote = true;
continue;
}
- if (c == operator && depth == 0) {
+ if (c == operator && depth == 0 && surroundedByWhitespace(text, i)) {
+ // like the tokenizer, the operator must have whitespace around it,
+ // so ${bean:svc?method=at(10:30)} is not a ternary
return i;
}
} else if (inSingleQuote && c == '\'') {
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleParserEdgeCasesTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleParserEdgeCasesTest.java
new file mode 100644
index 000000000000..9621bc9cdf3a
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleParserEdgeCasesTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.camel.language.simple;
+
+import org.apache.camel.LanguageTestSupport;
+import org.junit.jupiter.api.Test;
+
+/**
+ * CAMEL-24964: edge cases of the tokenizer and the predicate parser.
+ */
+public class SimpleParserEdgeCasesTest extends LanguageTestSupport {
+
+ @Override
+ protected String getLanguageName() {
+ return "simple";
+ }
+
+ @Test
+ public void testSingleQuoteInsideDoubleQuotesInFunction() {
+ exchange.getMessage().setBody("a'b'c");
+ assertPredicate("${body.replace(\"'\", \"\")} == 'abc'", true);
+ assertPredicate("${body.replace(\"'\", \"\")} == 'x'", false);
+ }
+
+ @Test
+ public void testBraceInsideDoubleQuotes() {
+ exchange.getMessage().setBody("a}b");
+ exchange.getMessage().setHeader("foo", "y");
+ assertPredicate("${body} contains \"}\" && ${header.foo} == 'y'", true);
+ assertPredicate("${body} contains \"}\" && ${header.foo} == 'z'", false);
+ }
+
+ @Test
+ public void testChainFollowedByNumberOrNull() {
+ exchange.getMessage().setBody("abcdef");
+ assertPredicate("${body} ~> ${length()} > 5", true);
+ assertPredicate("${body} ~> ${length()} > 10", false);
+ assertPredicate("${body} ~> ${length()} == null", false);
+ assertPredicate("${body} ~> ${length()} > -5", true);
+ }
+
+ @Test
+ public void testChainNeedsSpaces() {
+ assertExpression("Move A~>B", "Move A~>B");
+ exchange.getMessage().setBody("a~>b");
+ assertExpression("${body.replace('~>', '-')}", "a-b");
+ }
+
+ @Test
+ public void testOperatorInsideQuotesInBraces() {
+ exchange.getMessage().setBody("a > b");
+ assertPredicate("${body == 'a > b'}", true);
+ exchange.getMessage().setBody("x == y");
+ assertPredicate("${body startsWith 'x == y'}", true);
+ }
+
+ @Test
+ public void testUnquotedTextWithDigitIsLenient() {
+ // kept working as routes may compare with unquoted text such as v2
+ exchange.getMessage().setHeader("version", "v2");
+ assertPredicate("${header.version} == v2", true);
+ }
+
+ @Test
+ public void testColonWithoutSpacesIsNotATernary() {
+ context.getRegistry().bind("svc", new MyService());
+ assertExpression("${bean:svc?method=echo('10:30')}", "10:30");
+ }
+
+ public static class MyService {
+ public String echo(String s) {
+ return s;
+ }
+ }
+}
(camel) 02/11: CAMEL-24963: simple - an operator word in a property default or a bracket key is text, not a predicate
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch fix/CAMEL-24962
in repository https://gitbox.apache.org/repos/asf/camel.git
commit da044e3bbaa0dd8a4703c3a92b752665b3540e41
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 23 18:41:22 2026 +0200
CAMEL-24963: simple - an operator word in a property default or a bracket key is text, not a predicate
Regression from CAMEL-24921: ${properties:msg:value is not set} was read as an 'is' predicate.
Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
.../org/apache/camel/language/simple/SimpleSyntaxHints.java | 12 +++++++++---
.../camel/language/simple/SimplePredicateInBracesTest.java | 12 ++++++++++++
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleSyntaxHints.java b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleSyntaxHints.java
index 171a3258aa09..a046b1294e53 100644
--- a/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleSyntaxHints.java
+++ b/core/camel-core-languages/src/main/java/org/apache/camel/language/simple/SimpleSyntaxHints.java
@@ -259,14 +259,20 @@ public final class SimpleSyntaxHints {
}
int open = 0;
for (int i = 0; i < head.length(); i++) {
- if (head.charAt(i) == '(') {
+ char c = head.charAt(i);
+ if (c == '(' || c == '[') {
open++;
- } else if (head.charAt(i) == ')') {
+ } else if (c == ')' || c == ']') {
open--;
}
}
if (open > 0) {
- // the operator is inside an argument list that may hold a predicate (iif, filter, forEach)
+ // the operator is inside an argument list that may hold a predicate (iif, filter, forEach),
+ // or inside a key such as ${header[order in progress]}
+ return null;
+ }
+ if (head.startsWith("properties:") && head.indexOf(':', 11) > 0) {
+ // the operator word is in the default value: ${properties:msg:value is not set}
return null;
}
return "${" + head + "}" + function.substring(best);
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimplePredicateInBracesTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimplePredicateInBracesTest.java
index bdd7d9d67491..970adaa9eb77 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimplePredicateInBracesTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimplePredicateInBracesTest.java
@@ -81,6 +81,18 @@ public class SimplePredicateInBracesTest extends LanguageTestSupport {
assertExpression("${date:now:yyyy-MM-dd}".substring(0, 10) + "}", null, true);
}
+ @Test
+ public void testAnOperatorWordInAValueIsNotAPredicate() {
+ // CAMEL-24963: the operator word is in a property default or a bracket key, which is text, not an operator
+ assertExpression("${properties:msg:value is not set}", "value is not set");
+ assertExpression("${properties:msg:a == b}", "a == b");
+ exchange.getIn().setHeader("order in progress", "yes");
+ assertExpression("${header[order in progress]}", "yes");
+ // a closed bracket key can still be compared
+ exchange.getIn().setHeader("n", 5);
+ assertPredicate("${header[n] == 5}", true);
+ }
+
@Test
public void testTheTernaryStillWins() {
exchange.getIn().setHeader("n", 5);