org.apache.camel.builder
Class ExpressionBuilder

java.lang.Object
  extended by org.apache.camel.builder.ExpressionBuilder

public final class ExpressionBuilder
extends Object

A helper class for working with expressions.

Version:

Method Summary
static Expression append(Expression left, Expression right)
          Appends the String evaluations of the two expressions together
static Expression attachmentsExpression()
          Returns an expression for the inbound message attachments
static Expression attachmentValuesExpression()
          Returns an expression for the inbound message attachments
static Expression beanExpression(Class<?> beanType, String methodName)
           
static Expression beanExpression(Object bean, String methodName)
           
static Expression beanExpression(String expression)
           
static Expression beanExpression(String beanRef, String methodName)
           
static Expression bodyExpression()
          Returns the expression for the exchanges inbound message body
static
<T> Expression
bodyExpression(Class<T> type)
          Returns the expression for the exchanges inbound message body converted to the given type
static Expression bodyExpression(String name)
          Returns the expression for the exchanges inbound message body converted to the given type
static Expression bodyOgnlExpression(String ognl)
          Returns the expression for the exchanges inbound message body invoking methods defined in a simple OGNL notation
static Expression bodyTypeExpression()
          Returns the expression for the exchanges inbound message body type
static Expression camelContextExpression()
          Returns an expression for the CamelContext
static Expression camelContextNameExpression()
          Returns an expression for the CamelContext name
static Expression camelContextPropertiesExpression()
          Returns an expression for the properties of the camel context
static Expression camelContextPropertyExpression(String propertyName)
          Returns an expression for the property value of the camel context with the given name
static Expression concatExpression(Collection<Expression> expressions)
          Returns an expression which returns the string concatenation value of the various expressions
static Expression concatExpression(Collection<Expression> expressions, String expression)
          Returns an expression which returns the string concatenation value of the various expressions
static Expression constantExpression(Object value)
          Returns an expression for the constant value
static Expression convertToExpression(Expression expression, Class<?> type)
          Returns an expression which converts the given expression to the given type
static Expression convertToExpression(Expression expression, Expression type)
          Returns an expression which converts the given expression to the given type the type expression is evaluated to
static Expression dateExpression(String command, String pattern)
           
static Expression exchangeExceptionExpression()
          Returns an expression for an exception set on the exchange
static Expression exchangeExceptionExpression(Class<Exception> type)
          Returns an expression for an exception set on the exchange

Is used to get the caused exception that typically have been wrapped in some sort of Camel wrapper exception

static Expression exchangeExceptionMessageExpression()
          Returns an expression for an exception message set on the exchange
static Expression exchangeExceptionOgnlExpression(String ognl)
          Returns the expression for the exchanges exception invoking methods defined in a simple OGNL notation
static Expression exchangeExceptionStackTraceExpression()
          Returns an expression for an exception stacktrace set on the exchange
static Expression exchangeExpression()
          Returns the expression for the exchange
static Expression exchangeIdExpression()
          Returns an Expression for the exchange id
static Expression exchangePatternExpression()
          Returns an expression for the exchange pattern
static Expression faultBodyExpression()
          Returns the expression for the fault messages body
static
<T> Expression
faultBodyExpression(Class<T> type)
          Returns the expression for the exchanges fault message body converted to the given type
static Expression fileAbsoluteExpression()
           
static Expression fileAbsolutePathExpression()
           
static Expression fileExtensionExpression()
           
static Expression fileLastModifiedExpression()
           
static Expression fileNameExpression()
           
static Expression fileNameNoExtensionExpression()
           
static Expression fileOnlyNameExpression()
           
static Expression fileOnlyNameNoExtensionExpression()
           
static Expression fileParentExpression()
           
static Expression filePathExpression()
           
static Expression fileSizeExpression()
           
static Expression groupIteratorExpression(Expression expression, String token, int group)
           
static Expression headerExpression(String headerName)
          Returns an expression for the header value with the given name

Will fallback and look in properties if not found in headers.

static
<T> Expression
headerExpression(String headerName, Class<T> type)
          Returns an expression for the header value with the given name converted to the given type

Will fallback and look in properties if not found in headers.

static Expression headerExpression(String headerName, String name)
          Returns an expression for the header value with the given name converted to the given type

Will fallback and look in properties if not found in headers.

static Expression headersExpression()
          Returns an expression for the inbound message headers
static Expression headersOgnlExpression(String ognl)
          Returns the expression for the exchanges inbound message header invoking methods defined in a simple OGNL notation
static Expression inMessageExpression()
          Returns the expression for the IN message
static
<T> Expression
mandatoryBodyExpression(Class<T> type)
          Returns the expression for the exchanges inbound message body converted to the given type.
static
<T> Expression
mandatoryBodyExpression(Class<T> type, boolean nullBodyAllowed)
          Returns the expression for the exchanges inbound message body converted to the given type
static Expression mandatoryBodyExpression(String name)
          Returns the expression for the exchanges inbound message body converted to the given type
static Expression messageIdExpression()
          Returns an Expression for the inbound message id
static Expression outBodyExpression()
          Returns the expression for the out messages body
static
<T> Expression
outBodyExpression(Class<T> type)
          Returns the expression for the exchanges outbound message body converted to the given type
static Expression outHeaderExpression(String headerName)
          Returns an expression for the out header value with the given name

Will fallback and look in properties if not found in headers.

static Expression outHeadersExpression()
          Returns an expression for the outbound message headers
static Expression outMessageExpression()
          Returns the expression for the OUT message
static Expression prepend(Expression left, Expression right)
          Prepends the String evaluations of the two expressions together
static Expression propertiesComponentExpression(String key, String locations)
           
static Expression propertiesExpression()
          Returns an expression for the properties of exchange
static Expression propertyExpression(String propertyName)
          Returns an expression for the property value of exchange with the given name
static Expression propertyOgnlExpression(String ognl)
          Returns an expression for the property value of exchange with the given name invoking methods defined in a simple OGNL notation
static Expression refExpression(String ref)
          Returns an expression for lookup a bean in the Registry
static Expression regexReplaceAll(Expression expression, String regex, Expression replacementExpression)
          Transforms the expression into a String then performs the regex replaceAll to transform the String and return the result
static Expression regexReplaceAll(Expression expression, String regex, String replacement)
          Transforms the expression into a String then performs the regex replaceAll to transform the String and return the result
static Expression regexTokenizeExpression(Expression expression, String regexTokenizer)
          Returns a tokenize expression which will tokenize the string with the given regex
static Expression registryExpression()
          Returns an expression for the Registry
static Expression simpleExpression(String expression)
           
static Expression sortExpression(Expression expression, Comparator comparator)
          Returns a sort expression which will sort the expression with the given comparator.
static Expression systemEnvironmentExpression(String propertyName)
          Returns an expression for a system environment value with the given name
static Expression systemEnvironmentExpression(String propertyName, String defaultValue)
          Returns an expression for a system environment value with the given name
static Expression systemPropertyExpression(String propertyName)
          Returns an expression for a system property value with the given name
static Expression systemPropertyExpression(String propertyName, String defaultValue)
          Returns an expression for a system property value with the given name
static Expression threadNameExpression()
          Returns the expression for the current thread name
static Expression toExpression(String uri)
          Returns an expression processing the exchange to the given endpoint uri
static Expression tokenizeExpression(Expression expression, String token)
          Returns a tokenize expression which will tokenize the string with the given token
static Expression tokenizePairExpression(String startToken, String endToken, boolean includeTokens)
          Returns an TokenPairExpressionIterator expression
static Expression tokenizeXMLExpression(String tagName, String inheritNamespaceTagName)
          Returns an TokenXMLExpressionIterator expression
static Expression typeConverterExpression()
          Returns an expression for the type converter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

attachmentsExpression

public static Expression attachmentsExpression()
Returns an expression for the inbound message attachments

Returns:
an expression object which will return the inbound message attachments

attachmentValuesExpression

public static Expression attachmentValuesExpression()
Returns an expression for the inbound message attachments

Returns:
an expression object which will return the inbound message attachments

headerExpression

public static Expression headerExpression(String headerName)
Returns an expression for the header value with the given name

Will fallback and look in properties if not found in headers.

Parameters:
headerName - the name of the header the expression will return
Returns:
an expression object which will return the header value

headerExpression

public static <T> Expression headerExpression(String headerName,
                                              Class<T> type)
Returns an expression for the header value with the given name converted to the given type

Will fallback and look in properties if not found in headers.

Parameters:
headerName - the name of the header the expression will return
type - the type to convert to
Returns:
an expression object which will return the header value

headerExpression

public static Expression headerExpression(String headerName,
                                          String name)
Returns an expression for the header value with the given name converted to the given type

Will fallback and look in properties if not found in headers.

Parameters:
headerName - the name of the header the expression will return
name - the type to convert to as a FQN class name
Returns:
an expression object which will return the header value

headersOgnlExpression

public static Expression headersOgnlExpression(String ognl)
Returns the expression for the exchanges inbound message header invoking methods defined in a simple OGNL notation

Parameters:
ognl - methods to invoke on the header in a simple OGNL syntax

headersExpression

public static Expression headersExpression()
Returns an expression for the inbound message headers

Returns:
an expression object which will return the inbound headers

outHeaderExpression

public static Expression outHeaderExpression(String headerName)
Returns an expression for the out header value with the given name

Will fallback and look in properties if not found in headers.

Parameters:
headerName - the name of the header the expression will return
Returns:
an expression object which will return the header value

outHeadersExpression

public static Expression outHeadersExpression()
Returns an expression for the outbound message headers

Returns:
an expression object which will return the headers, will be null if the exchange is not out capable.

exchangePatternExpression

public static Expression exchangePatternExpression()
Returns an expression for the exchange pattern

Returns:
an expression object which will return the exchange pattern
See Also:
Exchange.getPattern()

exchangeExceptionExpression

public static Expression exchangeExceptionExpression()
Returns an expression for an exception set on the exchange

Returns:
an expression object which will return the exception set on the exchange
See Also:
Exchange.getException()

exchangeExceptionExpression

public static Expression exchangeExceptionExpression(Class<Exception> type)
Returns an expression for an exception set on the exchange

Is used to get the caused exception that typically have been wrapped in some sort of Camel wrapper exception

Parameters:
type - the exception type
Returns:
an expression object which will return the exception set on the exchange
See Also:
Exchange.getException(Class)

exchangeExceptionOgnlExpression

public static Expression exchangeExceptionOgnlExpression(String ognl)
Returns the expression for the exchanges exception invoking methods defined in a simple OGNL notation

Parameters:
ognl - methods to invoke on the body in a simple OGNL syntax

typeConverterExpression

public static Expression typeConverterExpression()
Returns an expression for the type converter

Returns:
an expression object which will return the type converter

registryExpression

public static Expression registryExpression()
Returns an expression for the Registry

Returns:
an expression object which will return the registry

refExpression

public static Expression refExpression(String ref)
Returns an expression for lookup a bean in the Registry

Returns:
an expression object which will return the bean

camelContextExpression

public static Expression camelContextExpression()
Returns an expression for the CamelContext

Returns:
an expression object which will return the camel context

camelContextNameExpression

public static Expression camelContextNameExpression()
Returns an expression for the CamelContext name

Returns:
an expression object which will return the camel context name

exchangeExceptionMessageExpression

public static Expression exchangeExceptionMessageExpression()
Returns an expression for an exception message set on the exchange

Returns:
an expression object which will return the exception message set on the exchange
See Also:
Exchange.getException().getMessage()

exchangeExceptionStackTraceExpression

public static Expression exchangeExceptionStackTraceExpression()
Returns an expression for an exception stacktrace set on the exchange

Returns:
an expression object which will return the exception stacktrace set on the exchange

propertyExpression

public static Expression propertyExpression(String propertyName)
Returns an expression for the property value of exchange with the given name

Parameters:
propertyName - the name of the property the expression will return
Returns:
an expression object which will return the property value

propertyOgnlExpression

public static Expression propertyOgnlExpression(String ognl)
Returns an expression for the property value of exchange with the given name invoking methods defined in a simple OGNL notation

Parameters:
ognl - methods to invoke on the property in a simple OGNL syntax

propertiesExpression

public static Expression propertiesExpression()
Returns an expression for the properties of exchange

Returns:
an expression object which will return the properties

camelContextPropertiesExpression

public static Expression camelContextPropertiesExpression()
Returns an expression for the properties of the camel context

Returns:
an expression object which will return the properties

camelContextPropertyExpression

public static Expression camelContextPropertyExpression(String propertyName)
Returns an expression for the property value of the camel context with the given name

Parameters:
propertyName - the name of the property the expression will return
Returns:
an expression object which will return the property value

systemPropertyExpression

public static Expression systemPropertyExpression(String propertyName)
Returns an expression for a system property value with the given name

Parameters:
propertyName - the name of the system property the expression will return
Returns:
an expression object which will return the system property value

systemPropertyExpression

public static Expression systemPropertyExpression(String propertyName,
                                                  String defaultValue)
Returns an expression for a system property value with the given name

Parameters:
propertyName - the name of the system property the expression will return
defaultValue - default value to return if no system property exists
Returns:
an expression object which will return the system property value

systemEnvironmentExpression

public static Expression systemEnvironmentExpression(String propertyName)
Returns an expression for a system environment value with the given name

Parameters:
propertyName - the name of the system environment the expression will return
Returns:
an expression object which will return the system property value

systemEnvironmentExpression

public static Expression systemEnvironmentExpression(String propertyName,
                                                     String defaultValue)
Returns an expression for a system environment value with the given name

Parameters:
propertyName - the name of the system environment the expression will return
defaultValue - default value to return if no system environment exists
Returns:
an expression object which will return the system environment value

constantExpression

public static Expression constantExpression(Object value)
Returns an expression for the constant value

Parameters:
value - the value the expression will return
Returns:
an expression object which will return the constant value

bodyExpression

public static Expression bodyExpression()
Returns the expression for the exchanges inbound message body


bodyOgnlExpression

public static Expression bodyOgnlExpression(String ognl)
Returns the expression for the exchanges inbound message body invoking methods defined in a simple OGNL notation

Parameters:
ognl - methods to invoke on the body in a simple OGNL syntax

bodyExpression

public static <T> Expression bodyExpression(Class<T> type)
Returns the expression for the exchanges inbound message body converted to the given type


bodyExpression

public static Expression bodyExpression(String name)
Returns the expression for the exchanges inbound message body converted to the given type


mandatoryBodyExpression

public static Expression mandatoryBodyExpression(String name)
Returns the expression for the exchanges inbound message body converted to the given type


threadNameExpression

public static Expression threadNameExpression()
Returns the expression for the current thread name


mandatoryBodyExpression

public static <T> Expression mandatoryBodyExpression(Class<T> type)
Returns the expression for the exchanges inbound message body converted to the given type.

Does not allow null bodies.


mandatoryBodyExpression

public static <T> Expression mandatoryBodyExpression(Class<T> type,
                                                     boolean nullBodyAllowed)
Returns the expression for the exchanges inbound message body converted to the given type

Parameters:
type - the type
nullBodyAllowed - whether null bodies is allowed and if so a null is returned, otherwise an exception is thrown

bodyTypeExpression

public static Expression bodyTypeExpression()
Returns the expression for the exchanges inbound message body type


outBodyExpression

public static Expression outBodyExpression()
Returns the expression for the out messages body


outBodyExpression

public static <T> Expression outBodyExpression(Class<T> type)
Returns the expression for the exchanges outbound message body converted to the given type


faultBodyExpression

public static Expression faultBodyExpression()
Returns the expression for the fault messages body


faultBodyExpression

public static <T> Expression faultBodyExpression(Class<T> type)
Returns the expression for the exchanges fault message body converted to the given type


exchangeExpression

public static Expression exchangeExpression()
Returns the expression for the exchange


inMessageExpression

public static Expression inMessageExpression()
Returns the expression for the IN message


outMessageExpression

public static Expression outMessageExpression()
Returns the expression for the OUT message


convertToExpression

public static Expression convertToExpression(Expression expression,
                                             Class<?> type)
Returns an expression which converts the given expression to the given type


convertToExpression

public static Expression convertToExpression(Expression expression,
                                             Expression type)
Returns an expression which converts the given expression to the given type the type expression is evaluated to


tokenizeExpression

public static Expression tokenizeExpression(Expression expression,
                                            String token)
Returns a tokenize expression which will tokenize the string with the given token


tokenizePairExpression

public static Expression tokenizePairExpression(String startToken,
                                                String endToken,
                                                boolean includeTokens)
Returns an TokenPairExpressionIterator expression


tokenizeXMLExpression

public static Expression tokenizeXMLExpression(String tagName,
                                               String inheritNamespaceTagName)
Returns an TokenXMLExpressionIterator expression


regexTokenizeExpression

public static Expression regexTokenizeExpression(Expression expression,
                                                 String regexTokenizer)
Returns a tokenize expression which will tokenize the string with the given regex


groupIteratorExpression

public static Expression groupIteratorExpression(Expression expression,
                                                 String token,
                                                 int group)

sortExpression

public static Expression sortExpression(Expression expression,
                                        Comparator comparator)
Returns a sort expression which will sort the expression with the given comparator.

The expression is evaluated as a List object to allow sorting.


regexReplaceAll

public static Expression regexReplaceAll(Expression expression,
                                         String regex,
                                         String replacement)
Transforms the expression into a String then performs the regex replaceAll to transform the String and return the result


regexReplaceAll

public static Expression regexReplaceAll(Expression expression,
                                         String regex,
                                         Expression replacementExpression)
Transforms the expression into a String then performs the regex replaceAll to transform the String and return the result


append

public static Expression append(Expression left,
                                Expression right)
Appends the String evaluations of the two expressions together


prepend

public static Expression prepend(Expression left,
                                 Expression right)
Prepends the String evaluations of the two expressions together


concatExpression

public static Expression concatExpression(Collection<Expression> expressions)
Returns an expression which returns the string concatenation value of the various expressions

Parameters:
expressions - the expression to be concatenated dynamically
Returns:
an expression which when evaluated will return the concatenated values

concatExpression

public static Expression concatExpression(Collection<Expression> expressions,
                                          String expression)
Returns an expression which returns the string concatenation value of the various expressions

Parameters:
expressions - the expression to be concatenated dynamically
expression - the text description of the expression
Returns:
an expression which when evaluated will return the concatenated values

messageIdExpression

public static Expression messageIdExpression()
Returns an Expression for the inbound message id


exchangeIdExpression

public static Expression exchangeIdExpression()
Returns an Expression for the exchange id


dateExpression

public static Expression dateExpression(String command,
                                        String pattern)

simpleExpression

public static Expression simpleExpression(String expression)

beanExpression

public static Expression beanExpression(String expression)

beanExpression

public static Expression beanExpression(Class<?> beanType,
                                        String methodName)

beanExpression

public static Expression beanExpression(Object bean,
                                        String methodName)

beanExpression

public static Expression beanExpression(String beanRef,
                                        String methodName)

toExpression

public static Expression toExpression(String uri)
Returns an expression processing the exchange to the given endpoint uri

Parameters:
uri - endpoint uri to send the exchange to
Returns:
an expression object which will return the OUT body

fileNameExpression

public static Expression fileNameExpression()

fileOnlyNameExpression

public static Expression fileOnlyNameExpression()

fileNameNoExtensionExpression

public static Expression fileNameNoExtensionExpression()

fileOnlyNameNoExtensionExpression

public static Expression fileOnlyNameNoExtensionExpression()

fileExtensionExpression

public static Expression fileExtensionExpression()

fileParentExpression

public static Expression fileParentExpression()

filePathExpression

public static Expression filePathExpression()

fileAbsolutePathExpression

public static Expression fileAbsolutePathExpression()

fileAbsoluteExpression

public static Expression fileAbsoluteExpression()

fileSizeExpression

public static Expression fileSizeExpression()

fileLastModifiedExpression

public static Expression fileLastModifiedExpression()

propertiesComponentExpression

public static Expression propertiesComponentExpression(String key,
                                                       String locations)


Apache CAMEL