org.apache.tuscany.sca.databinding.jaxb
Class DataConverter

java.lang.Object
  extended by org.apache.tuscany.sca.databinding.jaxb.DataConverter

public class DataConverter
extends java.lang.Object

Provides utilities to convert an object into a different kind of Object. For example, convert a String[] into a List


Constructor Summary
DataConverter()
           
 
Method Summary
static java.lang.Object convert(java.lang.Object arg, java.lang.Class<?> destClass)
          Utility function to convert an Object to some desired Class.
static java.lang.Class getWrapperClass(java.lang.Class primitive)
           
static boolean isConvertable(java.lang.Object obj, java.lang.Class dest)
          This method should return true if the convert method will succeed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataConverter

public DataConverter()
Method Detail

isConvertable

public static boolean isConvertable(java.lang.Object obj,
                                    java.lang.Class dest)
This method should return true if the convert method will succeed.

Note that any changes to isConvertable() must also be accompanied by similar changes to convert()

Parameters:
obj - source object or class
dest - destination class
Returns:
boolean true if convert(..) can convert obj to the destination class

convert

public static java.lang.Object convert(java.lang.Object arg,
                                       java.lang.Class<?> destClass)
Utility function to convert an Object to some desired Class.

Normally this is used for T[] to List processing. Other conversions are also done (i.e. HashMap <->Hashtable, etc.)

Use the isConvertable() method to determine if conversion is possible. Note that any changes to convert() must also be accompanied by similar changes to isConvertable()

Parameters:
arg - the array to convert
destClass - the actual class we want
Returns:
object of destClass if conversion possible, otherwise returns arg

getWrapperClass

public static java.lang.Class getWrapperClass(java.lang.Class primitive)