Package org.apache.camel

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


                    addTypeConverter(type, fromType, tc);
                    Object rc;
                    if (tryConvert) {
                        rc = tc.tryConvertTo(primitiveType, exchange, value);
                    } else {
                        rc = tc.convertTo(primitiveType, exchange, value);
                    }
                    if (rc == null && tc.allowNull()) {
                        return null;
                    } else if (rc != null) {
                        return rc;
View Full Code Here


            TypeConverter tc = fallback.getFallbackTypeConverter();
            Object rc;
            if (tryConvert) {
                rc = tc.tryConvertTo(type, exchange, value);
            } else {
                rc = tc.convertTo(type, exchange, value);
            }
            if (rc == null && tc.allowNull()) {
                return null;
            }
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

        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

                try {
                    // 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
                    return converter.convertTo(type, e, body);
                } catch (NoTypeConversionAvailableException ex) {
                    // ignore
                }
                return converter.convertTo(type, this);
            }
View Full Code Here

                    // payload
                    return converter.convertTo(type, e, body);
                } catch (NoTypeConversionAvailableException ex) {
                    // ignore
                }
                return converter.convertTo(type, this);
            }
        }
        return (T)getBody();
    }
View Full Code Here

public class CamelJaxbTest extends ContextTestSupport {
   
    public void testConvertor() throws Exception {
        TypeConverter converter = context.getTypeConverter();
        PersonType person = converter.convertTo(PersonType.class,
            "<Person><firstName>FOO</firstName><lastName>BAR</lastName></Person>");
        assertNotNull("Person should not be null ", person);
        assertEquals("Get the wrong first name ", person.getFirstName(), "FOO");
        assertEquals("Get the wrong second name ", person.getLastName(), "BAR");
    }
View Full Code Here

        try {
            Node base = getBaseNode(session);
            Node node = base.addNode(getNodeName(exchange));
            TypeConverter converter = exchange.getContext().getTypeConverter();
            for (String key : exchange.getProperties().keySet()) {
                Value value = converter.convertTo(Value.class,
                    exchange, exchange.getProperty(key));
                node.setProperty(key, value);
            }
            node.addMixin("mix:referenceable");
            session.save();
View Full Code Here

            return new StreamSource((InputStream)body);
        }
        if (body != null) {
            TypeConverter tc = exchange.getContext().getTypeConverterRegistry().lookup(Source.class, body.getClass());
            if (tc != null) {
                source = tc.convertTo(Source.class, body);
            }
        }

        if (source == null) {
            // then try SAX
View Full Code Here

        // Separate URI values from query parameters
        for (Map.Entry<String, Object> entry : entries) {
            String key = entry.getKey();
            Object value = entry.getValue();
            if (key.equals(EndpointConfiguration.URI_SCHEME)) {
                scheme = converter.convertTo(String.class, value);
            } else if (key.equals(EndpointConfiguration.URI_SCHEME_SPECIFIC_PART)) {
                schemeSpecificPart = converter.convertTo(String.class, value);
            } else if (key.equals(EndpointConfiguration.URI_AUTHORITY)) {
                authority = converter.convertTo(String.class, value);
            } else if (key.equals(EndpointConfiguration.URI_USER_INFO)) {
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.