This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch mock in repository https://gitbox.apache.org/repos/asf/camel.git
commit 75254855b3d09af3847f92774c8ffb9d3b9417a5 Author: Claus Ibsen <[email protected]> AuthorDate: Tue Apr 16 11:08:06 2019 +0200 Move mock component out of camel-core. Work in progress. --- .../java/org/apache/camel/builder/ExpressionBuilder.java | 4 ++-- .../java/org/apache/camel/support/LanguageSupport.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java index cda166d..5901824 100644 --- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java +++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java @@ -45,7 +45,6 @@ import org.apache.camel.NoSuchLanguageException; import org.apache.camel.NoTypeConversionAvailableException; import org.apache.camel.RuntimeCamelException; import org.apache.camel.RuntimeExchangeException; -import org.apache.camel.language.simple.SimpleLanguage; import org.apache.camel.model.language.MethodCallExpression; import org.apache.camel.spi.ExchangeFormatter; import org.apache.camel.spi.Language; @@ -57,6 +56,7 @@ import org.apache.camel.support.ExchangeHelper; import org.apache.camel.support.ExpressionAdapter; import org.apache.camel.support.GroupIterator; import org.apache.camel.support.GroupTokenIterator; +import org.apache.camel.support.LanguageSupport; import org.apache.camel.support.MessageHelper; import org.apache.camel.support.processor.DefaultExchangeFormatter; import org.apache.camel.util.FileUtil; @@ -1970,7 +1970,7 @@ public final class ExpressionBuilder { public static Expression simpleExpression(final String expression) { return new ExpressionAdapter() { public Object evaluate(Exchange exchange) { - if (SimpleLanguage.hasSimpleFunction(expression)) { + if (LanguageSupport.hasSimpleFunction(expression)) { // resolve language using context to have a clear separation of packages // must call evaluate to return the nested language evaluate when evaluating // stacked expressions diff --git a/core/camel-support/src/main/java/org/apache/camel/support/LanguageSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/LanguageSupport.java index ad0750c..31ebde8 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/LanguageSupport.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/LanguageSupport.java @@ -32,6 +32,8 @@ public abstract class LanguageSupport implements Language, IsSingleton, CamelCon public static final String RESOURCE = "resource:"; + private static final String[] SIMPLE_FUNCTION_START = new String[]{"${", "$simple{"}; + private CamelContext camelContext; public CamelContext getCamelContext() { @@ -73,4 +75,18 @@ public abstract class LanguageSupport implements Language, IsSingleton, CamelCon } return expression; } + + /** + * Does the expression include a simple function. + * + * @param expression the expression + * @return <tt>true</tt> if one or more simple function is included in the expression + */ + public static boolean hasSimpleFunction(String expression) { + if (expression != null) { + return expression.contains(SIMPLE_FUNCTION_START[0]) || expression.contains(SIMPLE_FUNCTION_START[1]); + } + return false; + } + }
