Package org.apache.camel.support.builder
Class ValueBuilder
- java.lang.Object
-
- org.apache.camel.support.builder.ValueBuilder
-
- All Implemented Interfaces:
org.apache.camel.Expression,org.apache.camel.Predicate
public class ValueBuilder extends Object implements org.apache.camel.Expression, org.apache.camel.Predicate
A builder of expressions or predicates based on values.
-
-
Constructor Summary
Constructors Constructor Description ValueBuilder(org.apache.camel.Expression expression)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValueBuilderappend(Object value)Appends the string evaluation of this expression with the given valueprotected org.apache.camel.ExpressionasExpression(Object value)org.apache.camel.Predicatecontains(Object value)Create a predicate that the left hand expression contains the value of the right hand expressionValueBuilderconvertTo(Class<?> type)Converts the current value to the given type using the registered type convertersValueBuilderconvertToString()Converts the current value to a String using the registered type convertersorg.apache.camel.PredicateendsWith(Object value)<T> Tevaluate(org.apache.camel.Exchange exchange, Class<T> type)org.apache.camel.ExpressiongetExpression()org.apache.camel.Predicatein(Object... values)org.apache.camel.Predicatein(org.apache.camel.Predicate... predicates)voidinit(org.apache.camel.CamelContext context)voidinitPredicate(org.apache.camel.CamelContext context)org.apache.camel.PredicateisEqualTo(Object value)org.apache.camel.PredicateisEqualToIgnoreCase(Object value)org.apache.camel.PredicateisGreaterThan(Object value)org.apache.camel.PredicateisGreaterThanOrEqualTo(Object value)org.apache.camel.PredicateisInstanceOf(Class<?> type)org.apache.camel.PredicateisLessThan(Object value)org.apache.camel.PredicateisLessThanOrEqualTo(Object value)org.apache.camel.PredicateisNotEqualTo(Object value)org.apache.camel.PredicateisNotNull()org.apache.camel.PredicateisNull()booleanmatches(org.apache.camel.Exchange exchange)ValueBuildermethod(String methodName)Invokes the method with the given name (supports OGNL syntax).ValueBuildernot()Negates the built expression.org.apache.camel.Predicatenot(org.apache.camel.Predicate predicate)protected org.apache.camel.PredicateonNewPredicate(org.apache.camel.Predicate predicate)A strategy method to allow derived classes to deal with the newly created predicate in different waysprotected ValueBuilderonNewValueBuilder(org.apache.camel.Expression exp)ValueBuilderprepend(Object value)Prepends the string evaluation of this expression with the given valueorg.apache.camel.Predicateregex(String regex)Creates a predicate which is true if this expression matches the given regular expressionValueBuilderregexReplaceAll(String regex, String replacement)Replaces all occurrences of the regular expression with the given replacementValueBuilderregexReplaceAll(String regex, org.apache.camel.Expression replacement)Replaces all occurrences of the regular expression with the given replacementValueBuilderregexTokenize(String regex)Tokenizes the string conversion of this expression using the given regular expressionValueBuildersort(Comparator<?> comparator)Sorts the current value using the given comparator.org.apache.camel.PredicatestartsWith(Object value)ValueBuildertokenize()ValueBuildertokenize(String token)ValueBuildertokenize(String token, int group, boolean skipFirst)ValueBuildertokenize(String token, String group, boolean skipFirst)StringtoString()
-
-
-
Method Detail
-
init
public void init(org.apache.camel.CamelContext context)
- Specified by:
initin interfaceorg.apache.camel.Expression- Specified by:
initin interfaceorg.apache.camel.Predicate
-
initPredicate
public void initPredicate(org.apache.camel.CamelContext context)
- Specified by:
initPredicatein interfaceorg.apache.camel.Predicate
-
evaluate
public <T> T evaluate(org.apache.camel.Exchange exchange, Class<T> type)- Specified by:
evaluatein interfaceorg.apache.camel.Expression
-
matches
public boolean matches(org.apache.camel.Exchange exchange)
- Specified by:
matchesin interfaceorg.apache.camel.Predicate
-
getExpression
public org.apache.camel.Expression getExpression()
-
isNotEqualTo
public org.apache.camel.Predicate isNotEqualTo(Object value)
-
isEqualTo
public org.apache.camel.Predicate isEqualTo(Object value)
-
isEqualToIgnoreCase
public org.apache.camel.Predicate isEqualToIgnoreCase(Object value)
-
isLessThan
public org.apache.camel.Predicate isLessThan(Object value)
-
isLessThanOrEqualTo
public org.apache.camel.Predicate isLessThanOrEqualTo(Object value)
-
isGreaterThan
public org.apache.camel.Predicate isGreaterThan(Object value)
-
isGreaterThanOrEqualTo
public org.apache.camel.Predicate isGreaterThanOrEqualTo(Object value)
-
isInstanceOf
public org.apache.camel.Predicate isInstanceOf(Class<?> type)
-
isNull
public org.apache.camel.Predicate isNull()
-
isNotNull
public org.apache.camel.Predicate isNotNull()
-
not
public org.apache.camel.Predicate not(org.apache.camel.Predicate predicate)
-
in
public org.apache.camel.Predicate in(Object... values)
-
in
public org.apache.camel.Predicate in(org.apache.camel.Predicate... predicates)
-
startsWith
public org.apache.camel.Predicate startsWith(Object value)
-
endsWith
public org.apache.camel.Predicate endsWith(Object value)
-
contains
public org.apache.camel.Predicate contains(Object value)
Create a predicate that the left hand expression contains the value of the right hand expression- Parameters:
value- the element which is compared to be contained within this expression- Returns:
- a predicate which evaluates to true if the given value expression is contained within this expression value
-
regex
public org.apache.camel.Predicate regex(String regex)
Creates a predicate which is true if this expression matches the given regular expression- Parameters:
regex- the regular expression to match- Returns:
- a predicate which evaluates to true if the expression matches the regex
-
tokenize
public ValueBuilder tokenize()
-
tokenize
public ValueBuilder tokenize(String token)
-
tokenize
public ValueBuilder tokenize(String token, int group, boolean skipFirst)
-
tokenize
public ValueBuilder tokenize(String token, String group, boolean skipFirst)
-
regexTokenize
public ValueBuilder regexTokenize(String regex)
Tokenizes the string conversion of this expression using the given regular expression
-
regexReplaceAll
public ValueBuilder regexReplaceAll(String regex, String replacement)
Replaces all occurrences of the regular expression with the given replacement
-
regexReplaceAll
public ValueBuilder regexReplaceAll(String regex, org.apache.camel.Expression replacement)
Replaces all occurrences of the regular expression with the given replacement
-
convertTo
public ValueBuilder convertTo(Class<?> type)
Converts the current value to the given type using the registered type converters- Parameters:
type- the type to convert the value to- Returns:
- the current builder
-
convertToString
public ValueBuilder convertToString()
Converts the current value to a String using the registered type converters- Returns:
- the current builder
-
append
public ValueBuilder append(Object value)
Appends the string evaluation of this expression with the given value- Parameters:
value- the value or expression to append- Returns:
- the current builder
-
prepend
public ValueBuilder prepend(Object value)
Prepends the string evaluation of this expression with the given value- Parameters:
value- the value or expression to prepend- Returns:
- the current builder
-
sort
public ValueBuilder sort(Comparator<?> comparator)
Sorts the current value using the given comparator. The current value must be convertable to aListto allow sorting using the comparator.- Parameters:
comparator- the comparator used by sorting- Returns:
- the current builder
-
method
public ValueBuilder method(String methodName)
Invokes the method with the given name (supports OGNL syntax).- Parameters:
methodName- name of method to invoke.- Returns:
- the current builder
-
not
public ValueBuilder not()
Negates the built expression.- Returns:
- the current builder
-
onNewPredicate
protected org.apache.camel.Predicate onNewPredicate(org.apache.camel.Predicate predicate)
A strategy method to allow derived classes to deal with the newly created predicate in different ways
-
asExpression
protected org.apache.camel.Expression asExpression(Object value)
-
onNewValueBuilder
protected ValueBuilder onNewValueBuilder(org.apache.camel.Expression exp)
-
-