use of org.apache.camel.Converter in project camel by apache.
the class XmlConverter method toReaderFromSource.
@Converter
public Reader toReaderFromSource(Source src, Exchange exchange) throws TransformerException {
StreamSource stSrc = toStreamSource(src, exchange);
Reader r = stSrc.getReader();
if (r == null) {
r = new InputStreamReader(stSrc.getInputStream());
}
return r;
}
use of org.apache.camel.Converter in project camel by apache.
the class CamelConverter method toProcessor.
@Converter
public static Processor toProcessor(final Expression expression) {
return new Processor() {
public void process(Exchange exchange) throws Exception {
Object answer = expression.evaluate(exchange, Object.class);
Message out = exchange.getOut();
out.copyFrom(exchange.getIn());
out.setBody(answer);
}
};
}
use of org.apache.camel.Converter in project camel by apache.
the class CollectionConverter method toProperties.
@Converter
public static Properties toProperties(Map<Object, Object> map) {
Properties answer = new Properties();
answer.putAll(map);
return answer;
}
use of org.apache.camel.Converter in project camel by apache.
the class DurationConverter method fromString.
@Converter
public static Duration fromString(String source) {
Duration duration = Duration.parse(source);
LOG.trace("source: {} milliseconds: ", source, duration);
return duration;
}
use of org.apache.camel.Converter in project camel by apache.
the class IOConverter method toBytes.
@Converter
public static byte[] toBytes(InputStream stream) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
IOHelper.copy(IOHelper.buffered(stream), bos);
// implementation is noop
return bos.toByteArray();
}
Aggregations