org.apache.axis2.databinding.utils
Class ConverterUtil

java.lang.Object
  extended by org.apache.axis2.databinding.utils.ConverterUtil

public class ConverterUtil
extends Object

Converter methods to go from 1. simple type -> String 2. simple type -> Object 3. String -> simpletype 4. Object list -> array


Nested Class Summary
static class ConverterUtil.ObjectConversionException
          A simple exception that is thrown when the conversion fails
 
Field Summary
static String SYSTEM_PROPERTY_ADB_CONVERTERUTIL
           
 
Constructor Summary
ConverterUtil()
           
 
Method Summary
static void appendDate(StringBuffer dateString, Calendar calendar)
           
static void appendTime(Calendar value, StringBuffer dateString)
           
static void appendTimeZone(Calendar calendar, StringBuffer dateString)
           
static double compare(BigDecimal binBigDecimal, String value)
           
static long compare(BigInteger binBigInteger, String value)
           
static int compare(byte byteVlaue, String value)
           
static long compare(Calendar calendar, String value)
           
static long compare(Date date, String value)
           
static double compare(double doubleValue, String value)
           
static long compare(Duration duration, String value)
           
static float compare(float floatValue, String value)
           
static int compare(int intValue, String value)
           
static long compare(long longValue, String value)
           
static int compare(short shortValue, String value)
           
static long compare(Time time, String value)
           
static long compare(UnsignedLong unsignedLong, String value)
           
static String convertToAnySimpleType(String s)
           
static org.apache.axiom.om.OMElement convertToAnyType(String s)
           
static URI convertToAnyURI(String s)
           
static Object convertToArray(Class baseArrayClass, List objectList)
           
static Object convertToArray(Class baseArrayClass, String[] valueArray)
           
static DataHandler convertToBase64Binary(String s)
           
static BigDecimal convertToBigDecimal(String s)
           
static BigInteger convertToBigInteger(String s)
           
static boolean convertToBoolean(String s)
           
static byte convertToByte(String s)
           
static DataHandler convertToDataHandler(String s)
           
static Date convertToDate(String source)
          Converts a given string into a date.
static Calendar convertToDateTime(String source)
          Code from Axis1 code base Note - We only follow the convention in the latest schema spec
static BigDecimal convertToDecimal(String s)
           
static double convertToDouble(String s)
           
static Duration convertToDuration(String s)
           
static Entities convertToENTITIES(String s)
           
static Entity convertToENTITY(String s)
           
static float convertToFloat(String s)
           
static Day convertToGDay(String s)
           
static Month convertToGMonth(String s)
           
static MonthDay convertToGMonthDay(String s)
           
static Year convertToGYear(String s)
           
static YearMonth convertToGYearMonth(String s)
           
static HexBinary convertToHexBinary(String s)
           
static Id convertToId(String s)
           
static Id convertToID(String s)
           
static IDRef convertToIDREF(String s)
           
static IDRefs convertToIDREFS(String s)
           
static int convertToInt(String s)
           
static BigInteger convertToInteger(String s)
           
static Language convertToLanguage(String s)
           
static long convertToLong(String s)
           
static Name convertToName(String s)
           
static NCName convertToNCName(String s)
           
static NegativeInteger convertToNegativeInteger(String s)
           
static NMToken convertToNMTOKEN(String s)
           
static NMTokens convertToNMTOKENS(String s)
           
static NonNegativeInteger convertToNonNegativeInteger(String s)
           
static NonPositiveInteger convertToNonPositiveInteger(String s)
           
static NormalizedString convertToNormalizedString(String s)
           
static Notation convertToNOTATION(String s)
           
static Object convertToObject(boolean i)
           
static Object convertToObject(byte i)
           
static Object convertToObject(char i)
           
static Object convertToObject(double i)
           
static Object convertToObject(short i)
           
static Object convertToObject(String i)
           
static PositiveInteger convertToPositiveInteger(String s)
           
static QName convertToQName(String source, String nameSpaceuri)
          Code from Axis1 code base
static short convertToShort(String s)
           
static BigDecimal convertToStandardDecimalNotation(String s)
           
static String convertToString(BigInteger o)
           
static String convertToString(boolean i)
           
static String convertToString(byte i)
           
static String convertToString(Byte o)
           
static String convertToString(byte[] bytes)
           
static String convertToString(Calendar value)
           
static String convertToString(char i)
           
static String convertToString(DataHandler handler)
           
static String convertToString(Date value)
           
static String convertToString(Day o)
           
static String convertToString(double i)
           
static String convertToString(Double o)
           
static String convertToString(Duration o)
           
static String convertToString(float i)
           
static String convertToString(Float o)
           
static String convertToString(HexBinary o)
           
static String convertToString(int i)
           
static String convertToString(Integer o)
           
static String convertToString(long i)
           
static String convertToString(Long o)
           
static String convertToString(Month o)
           
static String convertToString(MonthDay o)
           
static String convertToString(Object o)
           
static String convertToString(QName o)
           
static String convertToString(short i)
           
static String convertToString(Short o)
           
static String convertToString(String s)
           
static String convertToString(Time o)
           
static String convertToString(UnsignedByte o)
           
static String convertToString(UnsignedInt o)
           
static String convertToString(UnsignedLong o)
           
static String convertToString(Year o)
           
static String convertToString(YearMonth o)
           
static Time convertToTime(String s)
           
static Token convertToToken(String s)
           
static UnsignedByte convertToUnsignedByte(String s)
           
static UnsignedInt convertToUnsignedInt(String s)
           
static UnsignedLong convertToUnsignedLong(String s)
           
static UnsignedShort convertToUnsignedShort(String s)
           
static URI convertToURI(String s)
           
static Object getAnyTypeObject(XMLStreamReader xmlStreamReader, Class extensionMapperClass)
           
static Object getObjectForClass(Class clazz, String value)
          A reflection based method to generate an instance of a given class and populate it with a given value
static String getStringFromDatahandler(DataHandler dataHandler)
          Converts the given .datahandler to a string
static void serializeAnyType(Object value, XMLStreamWriter xmlStreamWriter)
           
static List toList(Object[] array)
          We could have used the Arraya.asList() method but that returns an *immutable* list !!!!!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYSTEM_PROPERTY_ADB_CONVERTERUTIL

public static final String SYSTEM_PROPERTY_ADB_CONVERTERUTIL
See Also:
Constant Field Values
Constructor Detail

ConverterUtil

public ConverterUtil()
Method Detail

convertToString

public static String convertToString(int i)

convertToString

public static String convertToString(float i)

convertToString

public static String convertToString(long i)

convertToString

public static String convertToString(double i)

convertToString

public static String convertToString(byte i)

convertToString

public static String convertToString(char i)

convertToString

public static String convertToString(short i)

convertToString

public static String convertToString(boolean i)

convertToString

public static String convertToString(Date value)

appendTimeZone

public static void appendTimeZone(Calendar calendar,
                                  StringBuffer dateString)

appendDate

public static void appendDate(StringBuffer dateString,
                              Calendar calendar)

convertToString

public static String convertToString(Calendar value)

appendTime

public static void appendTime(Calendar value,
                              StringBuffer dateString)

convertToString

public static String convertToString(Day o)

convertToString

public static String convertToString(YearMonth o)

convertToString

public static String convertToString(Year o)

convertToString

public static String convertToString(HexBinary o)

convertToString

public static String convertToString(MonthDay o)

convertToString

public static String convertToString(Time o)

convertToString

public static String convertToString(Byte o)

convertToString

public static String convertToString(BigInteger o)

convertToString

public static String convertToString(Integer o)

convertToString

public static String convertToString(Long o)

convertToString

public static String convertToString(Short o)

convertToString

public static String convertToString(UnsignedByte o)

convertToString

public static String convertToString(UnsignedInt o)

convertToString

public static String convertToString(UnsignedLong o)

convertToString

public static String convertToString(QName o)

convertToString

public static String convertToString(Object o)

convertToString

public static String convertToString(Double o)

convertToString

public static String convertToString(Duration o)

convertToString

public static String convertToString(Float o)

convertToString

public static String convertToString(Month o)

convertToString

public static String convertToString(byte[] bytes)

convertToString

public static String convertToString(DataHandler handler)

convertToInt

public static int convertToInt(String s)

convertToBigDecimal

public static BigDecimal convertToBigDecimal(String s)

convertToDouble

public static double convertToDouble(String s)

convertToDecimal

public static BigDecimal convertToDecimal(String s)

convertToStandardDecimalNotation

public static BigDecimal convertToStandardDecimalNotation(String s)

convertToFloat

public static float convertToFloat(String s)

convertToString

public static String convertToString(String s)

convertToLong

public static long convertToLong(String s)

convertToShort

public static short convertToShort(String s)

convertToBoolean

public static boolean convertToBoolean(String s)

convertToAnySimpleType

public static String convertToAnySimpleType(String s)

convertToAnyType

public static org.apache.axiom.om.OMElement convertToAnyType(String s)

convertToGYearMonth

public static YearMonth convertToGYearMonth(String s)

convertToGMonthDay

public static MonthDay convertToGMonthDay(String s)

convertToGYear

public static Year convertToGYear(String s)

convertToGMonth

public static Month convertToGMonth(String s)

convertToGDay

public static Day convertToGDay(String s)

convertToDuration

public static Duration convertToDuration(String s)

convertToHexBinary

public static HexBinary convertToHexBinary(String s)

convertToBase64Binary

public static DataHandler convertToBase64Binary(String s)

convertToDataHandler

public static DataHandler convertToDataHandler(String s)

convertToDate

public static Date convertToDate(String source)
Converts a given string into a date. Code from Axis1 DateDeserializer.

Parameters:
source -
Returns:
Returns Date.

convertToTime

public static Time convertToTime(String s)

convertToToken

public static Token convertToToken(String s)

convertToNormalizedString

public static NormalizedString convertToNormalizedString(String s)

convertToUnsignedLong

public static UnsignedLong convertToUnsignedLong(String s)

convertToUnsignedInt

public static UnsignedInt convertToUnsignedInt(String s)

convertToUnsignedShort

public static UnsignedShort convertToUnsignedShort(String s)

convertToUnsignedByte

public static UnsignedByte convertToUnsignedByte(String s)

convertToNonNegativeInteger

public static NonNegativeInteger convertToNonNegativeInteger(String s)

convertToNegativeInteger

public static NegativeInteger convertToNegativeInteger(String s)

convertToPositiveInteger

public static PositiveInteger convertToPositiveInteger(String s)

convertToNonPositiveInteger

public static NonPositiveInteger convertToNonPositiveInteger(String s)

convertToName

public static Name convertToName(String s)

convertToNCName

public static NCName convertToNCName(String s)

convertToID

public static Id convertToID(String s)

convertToId

public static Id convertToId(String s)

convertToLanguage

public static Language convertToLanguage(String s)

convertToNMTOKEN

public static NMToken convertToNMTOKEN(String s)

convertToNMTOKENS

public static NMTokens convertToNMTOKENS(String s)

convertToNOTATION

public static Notation convertToNOTATION(String s)

convertToENTITY

public static Entity convertToENTITY(String s)

convertToENTITIES

public static Entities convertToENTITIES(String s)

convertToIDREF

public static IDRef convertToIDREF(String s)

convertToIDREFS

public static IDRefs convertToIDREFS(String s)

convertToURI

public static URI convertToURI(String s)

convertToAnyURI

public static URI convertToAnyURI(String s)

convertToInteger

public static BigInteger convertToInteger(String s)

convertToBigInteger

public static BigInteger convertToBigInteger(String s)

convertToByte

public static byte convertToByte(String s)

convertToDateTime

public static Calendar convertToDateTime(String source)
Code from Axis1 code base Note - We only follow the convention in the latest schema spec

Parameters:
source -
Returns:
Returns Calendar.

convertToQName

public static QName convertToQName(String source,
                                   String nameSpaceuri)
Code from Axis1 code base

Parameters:
source -
Returns:
Returns QName.

convertToObject

public static Object convertToObject(String i)

convertToObject

public static Object convertToObject(boolean i)

convertToObject

public static Object convertToObject(double i)

convertToObject

public static Object convertToObject(byte i)

convertToObject

public static Object convertToObject(char i)

convertToObject

public static Object convertToObject(short i)

convertToArray

public static Object convertToArray(Class baseArrayClass,
                                    String[] valueArray)

convertToArray

public static Object convertToArray(Class baseArrayClass,
                                    List objectList)
Parameters:
baseArrayClass -
objectList - -> for primitive type array conversion we assume the content to be strings!
Returns:
Returns Object.

toList

public static List toList(Object[] array)
We could have used the Arraya.asList() method but that returns an *immutable* list !!!!!

Parameters:
array -
Returns:
list

compare

public static int compare(int intValue,
                          String value)
Parameters:
intValue -
value -
Returns:
0 if equal , + value if greater than , - value if less than

compare

public static double compare(double doubleValue,
                             String value)
Parameters:
doubleValue -
value -
Returns:
0 if equal , + value if greater than , - value if less than

compare

public static float compare(float floatValue,
                            String value)
Parameters:
floatValue -
value -
Returns:
0 if equal , + value if greater than , - value if less than

compare

public static long compare(long longValue,
                           String value)
Parameters:
longValue -
value -
Returns:
0 if equal , + value if greater than , - value if less than

compare

public static int compare(short shortValue,
                          String value)
Parameters:
shortValue -
value -
Returns:
0 if equal , + value if greater than , - value if less than

compare

public static int compare(byte byteVlaue,
                          String value)
Parameters:
byteVlaue -
value -
Returns:
0 if equal , + value if greater than , - value if less than

compare

public static long compare(BigInteger binBigInteger,
                           String value)
Parameters:
binBigInteger -
value -
Returns:
0 if equal , + value if greater than , - value if less than

compare

public static double compare(BigDecimal binBigDecimal,
                             String value)
Parameters:
binBigDecimal -
value -
Returns:
0 if equal , + value if greater than , - value if less than

compare

public static long compare(Duration duration,
                           String value)

compare

public static long compare(Date date,
                           String value)

compare

public static long compare(Time time,
                           String value)

compare

public static long compare(Calendar calendar,
                           String value)

compare

public static long compare(UnsignedLong unsignedLong,
                           String value)

getStringFromDatahandler

public static String getStringFromDatahandler(DataHandler dataHandler)
Converts the given .datahandler to a string

Returns:
string

getObjectForClass

public static Object getObjectForClass(Class clazz,
                                       String value)
A reflection based method to generate an instance of a given class and populate it with a given value

Parameters:
clazz -
value -
Returns:
object

serializeAnyType

public static void serializeAnyType(Object value,
                                    XMLStreamWriter xmlStreamWriter)
                             throws XMLStreamException
Throws:
XMLStreamException

getAnyTypeObject

public static Object getAnyTypeObject(XMLStreamReader xmlStreamReader,
                                      Class extensionMapperClass)
                               throws XMLStreamException
Throws:
XMLStreamException


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.