Search in sources :

Example 66 with Converter

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;
}
Also used : ByteBuffer(java.nio.ByteBuffer) Converter(org.apache.camel.Converter)

Example 67 with Converter

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;
}
Also used : ByteBuffer(java.nio.ByteBuffer) Converter(org.apache.camel.Converter)

Example 68 with Converter

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;
}
Also used : TypeConverterOutput(org.apache.camel.cdi.pojo.TypeConverterOutput) Converter(org.apache.camel.Converter)

Example 69 with Converter

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;
}
Also used : TypeConverter(org.apache.camel.TypeConverter) TypeConverterRegistry(org.apache.camel.spi.TypeConverterRegistry) InputStream(java.io.InputStream) FallbackConverter(org.apache.camel.FallbackConverter) Converter(org.apache.camel.Converter) TypeConverter(org.apache.camel.TypeConverter)

Example 70 with Converter

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);
}
Also used : CxfPayload(org.apache.camel.component.cxf.CxfPayload) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) XmlConverter(org.apache.camel.converter.jaxp.XmlConverter) FallbackConverter(org.apache.camel.FallbackConverter) Converter(org.apache.camel.Converter) TypeConverter(org.apache.camel.TypeConverter)

Aggregations

Converter (org.apache.camel.Converter)71 TypeConverter (org.apache.camel.TypeConverter)11 FallbackConverter (org.apache.camel.FallbackConverter)10 InputStream (java.io.InputStream)8 ByteBuffer (java.nio.ByteBuffer)7 IOConverter (org.apache.camel.converter.IOConverter)7 InputSource (org.xml.sax.InputSource)6 FileNotFoundException (java.io.FileNotFoundException)5 IOException (java.io.IOException)5 List (java.util.List)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 StringReader (java.io.StringReader)4 ArrayList (java.util.ArrayList)4 FileInputStream (java.io.FileInputStream)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 SAXSource (javax.xml.transform.sax.SAXSource)3 MultiSearchRequest (org.elasticsearch.action.search.MultiSearchRequest)3 SearchRequest (org.elasticsearch.action.search.SearchRequest)3 Document (org.w3c.dom.Document)3 Element (org.w3c.dom.Element)3