Search in sources :

Example 6 with XPathExpression

use of org.apache.camel.model.language.XPathExpression in project camel by apache.

the class ExpressionClauseSupport method xpath.

/**
     * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
     * expression</a> with the specified result type on the supplied
     * header name's contents
     *
     * @param text the expression to be evaluated
     * @param resultType the return type expected by the expression
     * @param headerName the name of the header to apply the expression to
     * @return the builder to continue processing the DSL
     */
public T xpath(String text, Class<?> resultType, String headerName) {
    XPathExpression expression = new XPathExpression(text);
    expression.setHeaderName(headerName);
    setExpressionType(expression);
    return result;
}
Also used : XPathExpression(org.apache.camel.model.language.XPathExpression) JXPathExpression(org.apache.camel.model.language.JXPathExpression)

Example 7 with XPathExpression

use of org.apache.camel.model.language.XPathExpression in project camel by apache.

the class ExpressionNodeHelper method toExpressionDefinition.

/**
     * Determines which {@link ExpressionDefinition} describes the given predicate best possible.
     * <p/>
     * This implementation will use types such as {@link SimpleExpression}, {@link XPathExpression} etc.
     * if the given predicate is detect as such a type.
     *
     * @param predicate the predicate
     * @return a definition which describes the predicate
     */
public static ExpressionDefinition toExpressionDefinition(Predicate predicate) {
    if (predicate instanceof SimpleBuilder) {
        SimpleBuilder builder = (SimpleBuilder) predicate;
        // we keep the original expression by using the constructor that accepts an expression
        SimpleExpression answer = new SimpleExpression(builder);
        answer.setExpression(builder.getText());
        return answer;
    } else if (predicate instanceof XPathBuilder) {
        XPathBuilder builder = (XPathBuilder) predicate;
        // we keep the original expression by using the constructor that accepts an expression
        XPathExpression answer = new XPathExpression(builder);
        answer.setExpression(builder.getText());
        return answer;
    } else if (predicate instanceof ValueBuilder) {
        // ValueBuilder wraps the actual predicate so unwrap
        ValueBuilder builder = (ValueBuilder) predicate;
        Expression expression = builder.getExpression();
        if (expression instanceof Predicate) {
            predicate = (Predicate) expression;
        }
    }
    if (predicate instanceof ExpressionDefinition) {
        return (ExpressionDefinition) predicate;
    }
    return new ExpressionDefinition(predicate);
}
Also used : XPathExpression(org.apache.camel.model.language.XPathExpression) ValueBuilder(org.apache.camel.builder.ValueBuilder) SimpleBuilder(org.apache.camel.builder.SimpleBuilder) XPathExpression(org.apache.camel.model.language.XPathExpression) SimpleExpression(org.apache.camel.model.language.SimpleExpression) Expression(org.apache.camel.Expression) XPathBuilder(org.apache.camel.builder.xml.XPathBuilder) ExpressionDefinition(org.apache.camel.model.language.ExpressionDefinition) SimpleExpression(org.apache.camel.model.language.SimpleExpression) Predicate(org.apache.camel.Predicate)

Example 8 with XPathExpression

use of org.apache.camel.model.language.XPathExpression in project camel by apache.

the class Namespaces method xpath.

/**
     * Creates the XPath expression using the current namespace context
     */
public XPathExpression xpath(String expression, Class<?> resultType) {
    XPathExpression answer = xpath(expression);
    answer.setResultType(resultType);
    return answer;
}
Also used : XPathExpression(org.apache.camel.model.language.XPathExpression)

Example 9 with XPathExpression

use of org.apache.camel.model.language.XPathExpression in project camel by apache.

the class Namespaces method xpath.

/**
     * Creates the XPath expression using the current namespace context
     */
public XPathExpression xpath(String expression) {
    XPathExpression answer = new XPathExpression(expression);
    configure(answer);
    return answer;
}
Also used : XPathExpression(org.apache.camel.model.language.XPathExpression)

Example 10 with XPathExpression

use of org.apache.camel.model.language.XPathExpression in project camel by apache.

the class ExpressionClauseSupport method xpath.

/**
     * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
     * expression</a> on the supplied header name's contents
     * 
     * @param text the expression to be evaluated
     * @param headerName the name of the header to apply the expression to
     * @return the builder to continue processing the DSL
     */
public T xpath(String text, String headerName) {
    XPathExpression expression = new XPathExpression(text);
    expression.setHeaderName(headerName);
    return expression(expression);
}
Also used : XPathExpression(org.apache.camel.model.language.XPathExpression) JXPathExpression(org.apache.camel.model.language.JXPathExpression)

Aggregations

XPathExpression (org.apache.camel.model.language.XPathExpression)11 JXPathExpression (org.apache.camel.model.language.JXPathExpression)5 SimpleBuilder (org.apache.camel.builder.SimpleBuilder)2 ValueBuilder (org.apache.camel.builder.ValueBuilder)2 XPathBuilder (org.apache.camel.builder.xml.XPathBuilder)2 ExpressionDefinition (org.apache.camel.model.language.ExpressionDefinition)2 SimpleExpression (org.apache.camel.model.language.SimpleExpression)2 Expression (org.apache.camel.Expression)1 Predicate (org.apache.camel.Predicate)1 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)1 Test (org.junit.Test)1