Package org.apache.camel

Examples of org.apache.camel.TypeConverter.convertTo()


                NodeList nodeList = tc.convertTo(NodeList.class, exchange, value);
                return (T) nodeListToCxfPayload(nodeList, exchange);
            }
            tc = registry.lookup(Document.class, value.getClass());
            if (tc != null) {
                Document document = tc.convertTo(Document.class, exchange, value);
                return (T) documentToCxfPayload(document, exchange);
            }
            // maybe we can convert via an InputStream
            CxfPayload<?> p = null;
            p = convertVia(InputStream.class, exchange, value, registry);
View Full Code Here


        }
        // Convert a CxfPayload into something else
        if (CxfPayload.class.isAssignableFrom(value.getClass())) {
            TypeConverter tc = registry.lookup(type, NodeList.class);
            if (tc != null) {
                return tc.convertTo(type, cxfPayloadToNodeList((CxfPayload<?>) value, exchange));
            }
            // we cannot convert a node list, so we try the first item from the
            // node list
            tc = registry.lookup(type, Node.class);
            if (tc != null) {
View Full Code Here

            // node list
            tc = registry.lookup(type, Node.class);
            if (tc != null) {
                NodeList nodeList = cxfPayloadToNodeList((CxfPayload<?>) value, exchange);
                if (nodeList.getLength() > 0) {
                    return tc.convertTo(type, nodeList.item(0));
                }
            }
        }
        return null;
    }
View Full Code Here

        TypeConverter tc = registry.lookup(via, value.getClass());
        if (tc != null) {
            TypeConverter tc1 = registry.lookup(Document.class, via);
            if (tc1 != null) {
                V is = tc.convertTo(via, exchange, value);
                Document document = tc1.convertTo(Document.class, exchange, is);
                return documentToCxfPayload(document, exchange);
            }
        }
        return null;
    }
View Full Code Here

                    try {
                        // lets first try converting the body itself first
                        // as for some types like InputStream v Reader its more efficient to do the transformation
                        // from the body itself as its got efficient implementations of them, before trying the
                        // message
                        return converter.convertTo(type, e, body);
                    } catch (NoTypeConversionAvailableException ex) {
                        // ignore
                    }
                }
                // fallback to the message itself
View Full Code Here

                    } catch (NoTypeConversionAvailableException ex) {
                        // ignore
                    }
                }
                // fallback to the message itself
                return converter.convertTo(type, this);
            }
        }
        return (T)getBody();
    }
View Full Code Here

        checkLoaded();

        // try to find a suitable type converter
        TypeConverter converter = getOrFindTypeConverter(type, value);
        if (converter != null) {
            T rc = converter.convertTo(type, exchange, value);
            if (rc != null) {
                return rc;
            }
        }
View Full Code Here

    @SuppressWarnings({"unchecked" })
    public <T> T getBody(Class<T> type) {
        Exchange e = getExchange();
        if (e != null) {
            TypeConverter converter = e.getContext().getTypeConverter();
            T answer = converter.convertTo(type, getBody());
            if (answer == null) {
                // lets first try converting the message itself first
                // as for some types like InputStream v Reader its more efficient to do the transformation
                // from the Message itself as its got efficient implementations of them, before trying the
                // payload
View Full Code Here

            if (answer == null) {
                // lets first try converting the message itself first
                // as for some types like InputStream v Reader its more efficient to do the transformation
                // from the Message itself as its got efficient implementations of them, before trying the
                // payload
                answer = converter.convertTo(type, this);
            }
            return answer;
        }
        return (T)getBody();
    }
View Full Code Here

            return toType.cast(value);
        }
        checkLoaded();
        TypeConverter converter = getOrFindTypeConverter(toType, value);
        if (converter != null) {
            return converter.convertTo(toType, value);
        }

        for (TypeConverter fallback : fallbackConverters) {
            T rc = fallback.convertTo(toType, value);
            if (rc != null) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.