Class 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
    • 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)
      • convertToString

        public static String convertToString​(Calendar value)
      • convertToString

        public static String convertToString​(Day o)
      • convertToString

        public static String convertToString​(Year 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​(Integer o)
      • convertToString

        public static String convertToString​(Long o)
      • convertToString

        public static String convertToString​(Short 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)
      • convertToInt

        public static int convertToInt​(String s)
      • convertToBigDecimal

        public static BigDecimal convertToBigDecimal​(String s)
      • convertToDouble

        public static double convertToDouble​(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 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.
      • convertXmlToDate

        public static Date convertXmlToDate​(String source)
        Convert lexical representation of date to java.util.Date.
        Parameters:
        source - the source
        Returns:
        the date This method used to parse the lexical string representation defined in XML Schema 1.0 Part 2, Section 3.2.[7-14].1 to a java.util.Date based on XMLGregorianCalendar. This replaced the behavior of convertToDate() method that copied from Axis1 .
      • convertToTime

        public static Time convertToTime​(String s)
      • convertToToken

        public static Token convertToToken​(String s)
      • convertToUnsignedInt

        public static UnsignedInt convertToUnsignedInt​(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)
      • 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)
      • 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