Search in sources :

Example 31 with Expression

use of org.apache.camel.Expression in project camel by apache.

the class ValueBuilder method tokenize.

public ValueBuilder tokenize(String token, int group, boolean skipFirst) {
    Expression newExp = ExpressionBuilder.tokenizeExpression(expression, token);
    if (group == 0 && skipFirst) {
        // wrap in skip first (if group then it has its own skip first logic)
        newExp = ExpressionBuilder.skipFirstExpression(newExp);
    }
    newExp = ExpressionBuilder.groupIteratorExpression(newExp, token, group, skipFirst);
    return onNewValueBuilder(newExp);
}
Also used : Expression(org.apache.camel.Expression)

Example 32 with Expression

use of org.apache.camel.Expression in project camel by apache.

the class ValueBuilder method in.

public Predicate in(Object... values) {
    List<Predicate> predicates = new ArrayList<Predicate>();
    for (Object value : values) {
        Expression right = asExpression(value);
        right = ExpressionBuilder.convertToExpression(right, expression);
        Predicate predicate = onNewPredicate(PredicateBuilder.isEqualTo(expression, right));
        predicates.add(predicate);
    }
    return in(predicates.toArray(new Predicate[predicates.size()]));
}
Also used : Expression(org.apache.camel.Expression) ArrayList(java.util.ArrayList) Predicate(org.apache.camel.Predicate)

Example 33 with Expression

use of org.apache.camel.Expression in project camel by apache.

the class ValueBuilder method xtokenize.

public ValueBuilder xtokenize(String path, char mode, Namespaces namespaces) {
    Expression newExp = ExpressionBuilder.tokenizeXMLAwareExpression(path, mode);
    ((NamespaceAware) newExp).setNamespaces(namespaces.getNamespaces());
    return onNewValueBuilder(newExp);
}
Also used : Expression(org.apache.camel.Expression) NamespaceAware(org.apache.camel.spi.NamespaceAware)

Example 34 with Expression

use of org.apache.camel.Expression in project camel by apache.

the class XPathBuilder method createSimpleFunction.

private XPathFunction createSimpleFunction() {
    return new XPathFunction() {

        @SuppressWarnings("rawtypes")
        public Object evaluate(List list) throws XPathFunctionException {
            if (!list.isEmpty()) {
                Object value = list.get(0);
                if (value != null) {
                    String text = exchange.get().getContext().getTypeConverter().convertTo(String.class, value);
                    Language simple = exchange.get().getContext().resolveLanguage("simple");
                    Expression exp = simple.createExpression(text);
                    Object answer = exp.evaluate(exchange.get(), Object.class);
                    return answer;
                }
            }
            return null;
        }
    };
}
Also used : Language(org.apache.camel.spi.Language) XPathExpression(javax.xml.xpath.XPathExpression) Expression(org.apache.camel.Expression) XPathFunction(javax.xml.xpath.XPathFunction) NodeList(org.w3c.dom.NodeList) List(java.util.List)

Example 35 with Expression

use of org.apache.camel.Expression in project camel by apache.

the class MethodInfo method createParameterExpressions.

protected Expression[] createParameterExpressions() {
    final int size = parameters.size();
    LOG.trace("Creating parameters expression for {} parameters", size);
    final Expression[] expressions = new Expression[size];
    for (int i = 0; i < size; i++) {
        Expression parameterExpression = parameters.get(i).getExpression();
        expressions[i] = parameterExpression;
        LOG.trace("Parameter #{} has expression: {}", i, parameterExpression);
    }
    return expressions;
}
Also used : Expression(org.apache.camel.Expression)

Aggregations

Expression (org.apache.camel.Expression)183 Exchange (org.apache.camel.Exchange)44 Processor (org.apache.camel.Processor)24 Predicate (org.apache.camel.Predicate)22 DefaultExchange (org.apache.camel.impl.DefaultExchange)21 AggregationStrategy (org.apache.camel.processor.aggregate.AggregationStrategy)18 ArrayList (java.util.ArrayList)15 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)15 AggregateProcessor (org.apache.camel.processor.aggregate.AggregateProcessor)15 Language (org.apache.camel.spi.Language)15 BodyInAggregatingStrategy (org.apache.camel.processor.BodyInAggregatingStrategy)14 SendProcessor (org.apache.camel.processor.SendProcessor)14 Test (org.junit.Test)8 SimpleParserException (org.apache.camel.language.simple.types.SimpleParserException)7 File (java.io.File)4 ExecutorService (java.util.concurrent.ExecutorService)4 SimpleIllegalSyntaxException (org.apache.camel.language.simple.types.SimpleIllegalSyntaxException)4 HashMap (java.util.HashMap)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)3 CamelExchangeException (org.apache.camel.CamelExchangeException)3