[[Expression-Expressions]]
= Expressions

Expressions and Predicates can then be used to
create the various xref:{eip-vc}:eips:enterprise-integration-patterns.adoc[Enterprise
Integration Patterns] in the DSL or
XML Configuration like the
Recipient List. +
 To support dynamic rules Camel supports pluggable
https://www.javadoc.io/doc/org.apache.camel/camel-api/current/org/apache/camel/Expression.html[Expression]
strategies using a variety of different Languages.

[[Expression-API]]
== API

If you are outside of the DSL and want to create your own
expressions you can either implement the
https://www.javadoc.io/doc/org.apache.camel/camel-api/current/org/apache/camel/Expression.html[Expression
interface], reuse one of the other builders or try the
https://www.javadoc.io/doc/org.apache.camel/camel-support/current/org/apache/camel/support/builder/ExpressionBuilder.html[ExpressionBuilder
class].

[[Expression-Expression]]
=== Expression

The API for a Camel Expression is defined in the
`org.apache.camel.Expression` interface as shown:

[source,java]
-------------------------------------------------------------------------------
public interface Expression {

    /**
     * Returns the value of the expression on the given exchange
     *
     * @param exchange the message exchange on which to evaluate the expression
     * @param type the expected type of the evaluation result
     * @return the value of the expression
     */
    <T> T evaluate(Exchange exchange, Class<T> type);
}
-------------------------------------------------------------------------------

[[Expression-Predicate]]
=== Predicate

The API for a Camel Predicate is defined in the
`org.apache.camel.Predicate` interface as shown:

[source,java]
-------------------------------------------------------------------------------
public interface Predicate {

    /**
     * Evaluates the predicate on the message exchange and returns true if this
     * exchange matches the predicate
     * 
     * @param exchange the message exchange
     * @return true if the predicate matches
     */
    boolean matches(Exchange exchange);

}
-------------------------------------------------------------------------------

[[Expression-ExpressionLanguages]]
== Expression Languages

The following languages are supported out of the box

* xref:components:languages:bean-language.adoc[Bean Language] for using Java for expressions
* xref:components:languages:constant-language.adoc[Constant]
* xref:components:languages:header-language.adoc[Header]
* xref:components:languages:jsonpath-language.adoc[JSonPath]
* xref:components::mvel-component.adoc[Mvel]
* xref:components:languages:ognl-language.adoc[OGNL]
* xref:components:languages:ref-language.adoc[Ref Language]
* ExchangeProperty / Property
* Scripting Languages such as
** BeanShell
** JavaScript
** xref:components:languages:groovy-language.adoc[Groovy]
* xref:components:languages:simple-language.adoc[Simple]
** xref:components:languages:file-language.adoc[File Language]
* xref:components:languages:spel-language.adoc[Spring Expression Language]
* xref:components::sql-component.adoc[SQL]
* Tokenizer
* xref:components:languages:xpath-language.adoc[XPath]
* xref:components::xquery-component.adoc[XQuery]
* https://github.com/camel-extra/camel-extra/blob/master/components/camel-vtdxml/src/main/docs/vtdxml-component.adoc[VTD-XML]

Most of these languages is also supported used as
xref:parameter-binding-annotations.adoc[Annotation Based
Expression Language].

[[Expression-UsingExpressionsinyourIDE]]
== Using Expressions in your IDE

To use different expression and predicates in your IDE you need to
perform a static import of the builder class for the language(s) you
wish to use.

[width="100%",cols="20%,80%",options="header",]
|=======================================================================
|Language(s) |Builder class to import

|Scripting Languages such as
BeanShell, JavaScript,
xref:components:languages:groovy-language.adoc[Groovy] |

|xref:components::sql-component.adoc[SQL] |

|xref:components:languages:xpath-language.adoc[XPath] |https://github.com/apache/camel/blob/main/components/camel-xpath/src/main/java/org/apache/camel/language/xpath/XPathBuilder.java[org.apache.camel.builder.xml.XPathBuilder]

|xref:components::xquery-component.adoc[XQuery] |https://github.com/apache/camel/blob/main/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java[org.apache.camel.builder.saxon.XQueryBuilder]
|=======================================================================

