use of org.apache.camel.Converter in project camel by apache.
the class NIOConverter method toByteBuffer.
@Converter
public static ByteBuffer toByteBuffer(Short value) {
ByteBuffer buf = ByteBuffer.allocate(2);
buf.putShort(value);
buf.flip();
return buf;
}
use of org.apache.camel.Converter in project camel by apache.
the class NIOConverter method toByteBuffer.
@Converter
public static ByteBuffer toByteBuffer(Double value) {
ByteBuffer buf = ByteBuffer.allocate(8);
buf.putDouble(value);
buf.flip();
return buf;
}
use of org.apache.camel.Converter in project camel by apache.
the class InjectedTypeConverter method convert.
@Converter
public TypeConverterOutput convert(TypeConverterInput input) throws Exception {
TypeConverterOutput output = new TypeConverterOutput();
output.setProperty(context.resolvePropertyPlaceholders(input.getProperty()));
return output;
}
use of org.apache.camel.Converter in project camel by apache.
the class CxfConverter method toInputStream.
@Converter
public static InputStream toInputStream(Response response, Exchange exchange) {
Object obj = response.getEntity();
if (obj == null) {
return null;
}
if (obj instanceof InputStream) {
// short circuit the lookup
return (InputStream) obj;
}
TypeConverterRegistry registry = exchange.getContext().getTypeConverterRegistry();
TypeConverter tc = registry.lookup(InputStream.class, obj.getClass());
if (tc != null) {
return tc.convertTo(InputStream.class, exchange, obj);
}
return null;
}
use of org.apache.camel.Converter in project camel by apache.
the class CxfPayloadConverter method nodeListToCxfPayload.
@Converter
public static <T> CxfPayload<T> nodeListToCxfPayload(NodeList nodeList, Exchange exchange) {
List<T> headers = new ArrayList<T>();
List<Element> body = new ArrayList<Element>();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
// add all nodes to the body that are elements
if (Element.class.isAssignableFrom(node.getClass())) {
body.add((Element) node);
}
}
return new CxfPayload<T>(headers, body);
}
Aggregations