Java 类org.apache.camel.builder.ValueBuilder 实例源码

项目:Ardulink-2    文件:MqttCamelRouteBuilder.java   
private Processor divideByValueOf(final ValueBuilder valueBuilder) {
    return new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            Message in = exchange.getIn();
            BigDecimal sum = new BigDecimal(checkNotNull(
                    in.getBody(Number.class), "Body of %s is null", in)
                    .toString());
            BigDecimal divisor = new BigDecimal(checkNotNull(
                    valueBuilder.evaluate(exchange, Integer.class),
                    "No %s set in exchange %s", valueBuilder, exchange)
                    .toString());
            in.setBody(sum.divide(divisor, HALF_UP));
        }

    };
}
项目:jentrata    文件:ExpressionHelper.java   
/**
 * Creates an expression that gets the value of a header and if it is null
 * it evaluates a default expression
 *
 * @param name - header name
 * @param defaultExpression - default expression to evaluate if the header is null
 * @return an expression
 */
public static final Expression headerWithDefault(final String name, final Expression defaultExpression) {
    return new ValueBuilder(new ExpressionAdapter() {
        public Object evaluate(Exchange exchange) {
            Object header = exchange.getIn().getHeader(name);
            if(header == null) {
               return defaultExpression.evaluate(exchange,Object.class);
            } else {
                return header;
            }
        }

        @Override
        public String toString() {
            return "headerWithDefault(" + name + ", " + defaultExpression + ")";
        }
    });
}
项目:Camel    文件:BinaryExpression.java   
private Expression createInExpression(final Expression leftExp, final Expression rightExp) {
    return new Expression() {
        @Override
        public <T> T evaluate(Exchange exchange, Class<T> type) {
            // okay the in operator is a bit more complex as we need to build a list of values
            // from the right hand side expression.
            // each element on the right hand side must be separated by comma (default for create iterator)
            Iterator<Object> it = ObjectHelper.createIterator(rightExp.evaluate(exchange, Object.class));
            List<Object> values = new ArrayList<Object>();
            while (it.hasNext()) {
                values.add(it.next());
            }
            // then reuse value builder to create the in predicate with the list of values
            ValueBuilder vb = new ValueBuilder(leftExp);
            Predicate predicate = vb.in(values.toArray());
            if (operator == BinaryOperatorType.NOT_IN) {
                predicate = PredicateBuilder.not(predicate);
            }
            boolean answer = predicate.matches(exchange);
            return exchange.getContext().getTypeConverter().convertTo(type, answer);
        }

        @Override
        public String toString() {
            return left + " " + token.getText() + " " + right;
        }
    };
}
项目:Camel    文件:HL7.java   
public static ValueBuilder convertLFToCR() {
    return new ValueBuilder(new ExpressionAdapter() {

        @Override
        public Object evaluate(Exchange exchange) {
            String s = exchange.getIn().getBody(String.class);
            return s != null ? s.replace('\n', '\r') : null;
        }

    });
}
项目:Camel    文件:AssertionClause.java   
@Override
protected ValueBuilder onNewValueBuilder(Expression exp) {
    return new PredicateValueBuilder(exp);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given header
 */
public static ValueBuilder header(String name) {
    return Builder.header(name);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given exchange property
 */
public static ValueBuilder exchangeProperty(String name) {
    return Builder.exchangeProperty(name);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a predicate and value builder for the inbound body on an exchange
 */
public static ValueBuilder body() {
    return Builder.body();
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given system property
 */
public static ValueBuilder systemProperty(String name) {
    return Builder.systemProperty(name);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given system property
 */
public static ValueBuilder systemProperty(String name, String defaultValue) {
    return Builder.systemProperty(name, defaultValue);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given header
 */
public static ValueBuilder header(String name) {
    return Builder.header(name);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given exchange property
 */
public static ValueBuilder exchangeProperty(String name) {
    return Builder.exchangeProperty(name);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a predicate and value builder for the inbound body on an exchange
 */
public static ValueBuilder body() {
    return Builder.body();
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given system property
 */
public static ValueBuilder systemProperty(String name) {
    return Builder.systemProperty(name);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given system property
 */
public static ValueBuilder systemProperty(String name, String defaultValue) {
    return Builder.systemProperty(name, defaultValue);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given header
 */
public static ValueBuilder header(String name) {
    return Builder.header(name);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given property
 */
public static ValueBuilder property(String name) {
    return Builder.exchangeProperty(name);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a predicate and value builder for the inbound body on an exchange
 */
public static ValueBuilder body() {
    return Builder.body();
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given system property
 */
public static ValueBuilder systemProperty(String name) {
    return Builder.systemProperty(name);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given system property
 */
public static ValueBuilder systemProperty(String name, String defaultValue) {
    return Builder.systemProperty(name, defaultValue);
}
项目:Camel    文件:HL7.java   
public static ValueBuilder terser(String expression) {
    return new ValueBuilder(new TerserExpression(expression));
}
项目:Camel    文件:HL7.java   
public static ValueBuilder ack() {
    return new ValueBuilder(new AckExpression());
}
项目:Camel    文件:HL7.java   
/**
 * @deprecated Use {@link #ack(ca.uhn.hl7v2.AcknowledgmentCode)}
 */
@Deprecated
public static ValueBuilder ack(AckCode code) {
    return new ValueBuilder(new AckExpression(code));
}
项目:Camel    文件:HL7.java   
public static ValueBuilder ack(AcknowledgmentCode code) {
    return new ValueBuilder(new AckExpression(code));
}
项目:Camel    文件:HL7.java   
/**
 * @deprecated Use {@link #ack(ca.uhn.hl7v2.AcknowledgmentCode, String, ErrorCode)}
 */
@Deprecated
public static ValueBuilder ack(AckCode code, String errorMessage, int errorCode) {
    return ack(code.toAcknowledgmentCode(), errorMessage, ErrorCode.errorCodeFor(errorCode));
}
项目:Camel    文件:HL7.java   
/**
 * @deprecated Use {@link #ack(ca.uhn.hl7v2.AcknowledgmentCode, String, ErrorCode)}
 */
@Deprecated
public static ValueBuilder ack(AckCode code, String errorMessage, ErrorCode errorCode) {
    return ack(code.toAcknowledgmentCode(), errorMessage, errorCode);
}
项目:Camel    文件:HL7.java   
public static ValueBuilder ack(AcknowledgmentCode code, String errorMessage, ErrorCode errorCode) {
    return new ValueBuilder(new AckExpression(code, errorMessage, errorCode));
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given header
 */
public static ValueBuilder header(String name) {
    return Builder.header(name);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given exchange property
 */
public static ValueBuilder exchangeProperty(String name) {
    return Builder.exchangeProperty(name);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a predicate and value builder for the inbound body on an exchange
 */
public static ValueBuilder body() {
    return Builder.body();
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given system property
 */
public static ValueBuilder systemProperty(String name) {
    return Builder.systemProperty(name);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given system property
 */
public static ValueBuilder systemProperty(String name, String defaultValue) {
    return Builder.systemProperty(name, defaultValue);
}
项目:rassyeyanie    文件:HL7.java   
public static ValueBuilder terser(String expression) {
    return new ValueBuilder(new TerserExpression(expression));
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a value builder for the given exchange property
 * 
 * @deprecated use {@link #exchangeProperty(String)}
 */
@Deprecated
public static ValueBuilder property(String name) {
    return Builder.exchangeProperty(name);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a predicate and value builder for the inbound message body as a
 * specific type
 */
public static <T> ValueBuilder bodyAs(Class<T> type) {
    return Builder.bodyAs(type);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a predicate and value builder for the outbound body on an
 * exchange
 * 
 * @deprecated use {@link #body()}
 */
@Deprecated
public static ValueBuilder outBody() {
    return Builder.outBody();
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a predicate and value builder for the outbound message body as a
 * specific type
 * 
 * @deprecated use {@link #bodyAs(Class)}
 */
@Deprecated
public static <T> ValueBuilder outBodyAs(Class<T> type) {
    return Builder.outBodyAs(type);
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a predicate and value builder for the fault body on an
 * exchange
 */
public static ValueBuilder faultBody() {
    return Builder.faultBody();
}
项目:Camel    文件:TestSupport.java   
/**
 * Returns a predicate and value builder for the fault message body as a
 * specific type
 * 
 * @deprecated use {@link #bodyAs(Class)}
 */
@Deprecated
public static <T> ValueBuilder faultBodyAs(Class<T> type) {
    return Builder.faultBodyAs(type);
}