org.apache.camel.util
Class ExchangeHelper

java.lang.Object
  extended by org.apache.camel.util.ExchangeHelper

public class ExchangeHelper
extends Object

Some helper methods for working with Exchange objects

Version:
$Revision: 563607 $

Method Summary
static
<T> T
convertToMandatoryType(Exchange exchange, Class<T> type, Object value)
          Converts the value to the given expected type or throws an exception
static
<T> T
convertToType(Exchange exchange, Class<T> type, Object value)
          Converts the value to the given expected type returning null if it could not be converted
static
<T> T
getMandatoryInBody(Exchange exchange, Class<T> type)
          Returns the mandatory inbound message body of the correct type or throws an exception if it is not present
static
<T> T
getMandatoryProperty(Exchange exchange, String propertyName, Class<T> type)
           
static
<E extends Exchange>
Endpoint<E>
resolveEndpoint(E exchange, Object value)
          Attempts to resolve the endpoint for the given value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

resolveEndpoint

public static <E extends Exchange> Endpoint<E> resolveEndpoint(E exchange,
                                                               Object value)
                                                    throws NoSuchEndpointException
Attempts to resolve the endpoint for the given value

Parameters:
exchange - the message exchange being processed
value - the value which can be an Endpoint or an object which provides a String representation of an endpoint via Object.toString()
Returns:
the endpoint
Throws:
NoSuchEndpointException - if the endpoint cannot be resolved

getMandatoryProperty

public static <T> T getMandatoryProperty(Exchange exchange,
                                         String propertyName,
                                         Class<T> type)
                              throws NoSuchPropertyException
Throws:
NoSuchPropertyException

getMandatoryInBody

public static <T> T getMandatoryInBody(Exchange exchange,
                                       Class<T> type)
                            throws InvalidPayloadException
Returns the mandatory inbound message body of the correct type or throws an exception if it is not present

Throws:
InvalidPayloadException

convertToMandatoryType

public static <T> T convertToMandatoryType(Exchange exchange,
                                           Class<T> type,
                                           Object value)
                                throws InvalidTypeException
Converts the value to the given expected type or throws an exception

Throws:
InvalidTypeException

convertToType

public static <T> T convertToType(Exchange exchange,
                                  Class<T> type,
                                  Object value)
Converts the value to the given expected type returning null if it could not be converted



Copyright © 2007 Apache Software Foundation. All Rights Reserved.