org.plasma.sdo.helper
Class DataConverter

java.lang.Object
  extended by org.plasma.sdo.helper.DataConverter

public class DataConverter
extends Object


Field Summary
static String FORMAT_PATTERN_DATE
           
static String FORMAT_PATTERN_DATETIME
           
static String FORMAT_PATTERN_DAY
           
static String FORMAT_PATTERN_MONTH
           
static String FORMAT_PATTERN_MONTHDAY
           
static String FORMAT_PATTERN_TIME
           
static String FORMAT_PATTERN_YEAR
           
static String FORMAT_PATTERN_YEARMONTH
           
static String FORMAT_PATTERN_YEARMONTHDAY
           
static DataConverter INSTANCE
           
 
Method Summary
 Object convert(Type targetType, Object value)
           
 Object convert(Type targetType, Type sourceType, Object value)
           
 Object fromBoolean(Type targetType, boolean value)
           
 Object fromByte(Type targetType, byte value)
           
 Object fromBytes(Type targetType, byte[] value)
           
 Object fromCharacter(Type targetType, char value)
           
 Object fromDate(Type targetType, Date value)
           
 Object fromDecimal(Type targetType, BigDecimal value)
           
 Object fromDouble(Type targetType, double value)
           
 Object fromFloat(Type targetType, float value)
           
 Object fromInt(Type targetType, int value)
           
 Object fromInteger(Type targetType, BigInteger value)
           
 Object fromLong(Type targetType, long value)
           
 Object fromShort(Type targetType, short value)
           
 Object fromString(Type targetType, String value)
          Converts the given string value to an object appropriate for the target type.
 Object fromStrings(Type targetType, List<String> value)
           
 Object fromTemporalDataType(Type targetType, Type sourceType, String value)
           
 List<DataType> getAllowableTargetTypes(DataType dataType)
           
 DateFormat getDateFormat()
           
 DateFormat getDateTimeFormat()
           
 DateFormat getDayFormat()
           
 org.joda.time.format.PeriodFormatter getDurationFormat()
           
 DateFormat getMonthDayFormat()
           
 DateFormat getMonthFormat()
           
 DateFormat getTimeFormat()
           
 DateFormat getYearFormat()
           
 DateFormat getYearMonthDayFormat()
           
 DateFormat getYearMonthFormat()
           
 boolean toBoolean(Type sourceType, Object value)
           
 byte toByte(Type sourceType, Object value)
           
 byte[] toBytes(Type sourceType, Object value)
           
 char toCharacter(Type sourceType, Object value)
           
 Date toDate(Type sourceType, Object value)
           
 BigDecimal toDecimal(Type sourceType, Object value)
           
 double toDouble(Type sourceType, Object value)
           
 float toFloat(Type sourceType, Object value)
           
 int toInt(Type sourceType, Object value)
           
 BigInteger toInteger(Type sourceType, Object value)
           
 long toLong(Type sourceType, Object value)
           
 Class<?> toPrimitiveJavaClass(DataType dataType)
          Returns a primitive Java class, wherever possible, for the given SDO data-type (as per the SDO Specification 2.10 Section 8.1), and where no primitive exists for the give SDO datatype, the appropriate class is returned.
 short toShort(Type sourceType, Object value)
           
 String toString(Type sourceType, Object value)
          Converts the given value to a string.
 List<String> toStrings(Type sourceType, Object value)
           
 String toTemporalDataType(Type targetType, Type sourceType, Object value)
           
 Class<?> toWrapperJavaClass(DataType dataType)
          Returns a primitive wrapper Java class, wherever possible, for the given SDO data-type (as per the SDO Specification 2.10 Section 8.1), and where no primitive exists for the give SDO datatype, the appropriate class is returned.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static DataConverter INSTANCE

FORMAT_PATTERN_TIME

public static final String FORMAT_PATTERN_TIME
See Also:
Constant Field Values

FORMAT_PATTERN_DATE

public static final String FORMAT_PATTERN_DATE
See Also:
Constant Field Values

FORMAT_PATTERN_DATETIME

public static final String FORMAT_PATTERN_DATETIME
See Also:
Constant Field Values

FORMAT_PATTERN_DAY

public static final String FORMAT_PATTERN_DAY
See Also:
Constant Field Values

FORMAT_PATTERN_MONTH

public static final String FORMAT_PATTERN_MONTH
See Also:
Constant Field Values

FORMAT_PATTERN_MONTHDAY

public static final String FORMAT_PATTERN_MONTHDAY
See Also:
Constant Field Values

FORMAT_PATTERN_YEAR

public static final String FORMAT_PATTERN_YEAR
See Also:
Constant Field Values

FORMAT_PATTERN_YEARMONTH

public static final String FORMAT_PATTERN_YEARMONTH
See Also:
Constant Field Values

FORMAT_PATTERN_YEARMONTHDAY

public static final String FORMAT_PATTERN_YEARMONTHDAY
See Also:
Constant Field Values
Method Detail

getDateTimeFormat

public DateFormat getDateTimeFormat()

getTimeFormat

public DateFormat getTimeFormat()

getDateFormat

public DateFormat getDateFormat()

getDurationFormat

public org.joda.time.format.PeriodFormatter getDurationFormat()

getDayFormat

public DateFormat getDayFormat()

getMonthFormat

public DateFormat getMonthFormat()

getMonthDayFormat

public DateFormat getMonthDayFormat()

getYearFormat

public DateFormat getYearFormat()

getYearMonthFormat

public DateFormat getYearMonthFormat()

getYearMonthDayFormat

public DateFormat getYearMonthDayFormat()

convert

public Object convert(Type targetType,
                      Object value)

convert

public Object convert(Type targetType,
                      Type sourceType,
                      Object value)

toBoolean

public boolean toBoolean(Type sourceType,
                         Object value)

fromBoolean

public Object fromBoolean(Type targetType,
                          boolean value)

toByte

public byte toByte(Type sourceType,
                   Object value)

fromByte

public Object fromByte(Type targetType,
                       byte value)

toBytes

public byte[] toBytes(Type sourceType,
                      Object value)

fromBytes

public Object fromBytes(Type targetType,
                        byte[] value)

toCharacter

public char toCharacter(Type sourceType,
                        Object value)

fromCharacter

public Object fromCharacter(Type targetType,
                            char value)

toDecimal

public BigDecimal toDecimal(Type sourceType,
                            Object value)

fromDecimal

public Object fromDecimal(Type targetType,
                          BigDecimal value)

toDouble

public double toDouble(Type sourceType,
                       Object value)

fromDouble

public Object fromDouble(Type targetType,
                         double value)

toFloat

public float toFloat(Type sourceType,
                     Object value)

fromFloat

public Object fromFloat(Type targetType,
                        float value)

toInt

public int toInt(Type sourceType,
                 Object value)

fromInt

public Object fromInt(Type targetType,
                      int value)

toInteger

public BigInteger toInteger(Type sourceType,
                            Object value)

fromInteger

public Object fromInteger(Type targetType,
                          BigInteger value)

toLong

public long toLong(Type sourceType,
                   Object value)

fromLong

public Object fromLong(Type targetType,
                       long value)

toShort

public short toShort(Type sourceType,
                     Object value)

fromShort

public Object fromShort(Type targetType,
                        short value)

toString

public String toString(Type sourceType,
                       Object value)
Converts the given value to a string. Uses java.util.Arrays formatting for 'many' properties.

Parameters:
sourceType - the property type for the given property
value - the value to convert
Returns:
the string value
Throws:
InvalidDataConversionException - if the given source type cannot be converted to string as per the SDO 2.1 datatype conversion table.
IllegalArgumentException - if the given value is not the expected Java type as per the SDO 2.1 specification

fromString

public Object fromString(Type targetType,
                         String value)
Converts the given string value to an object appropriate for the target type. If java.util.Arrays formatting is detected for the given string, the formatting is from removed and the arrays converted into a list of elements appropriate for the target type.

Parameters:
targetType - the target data type
value - the value
Returns:
the converted value

toStrings

public List<String> toStrings(Type sourceType,
                              Object value)

fromStrings

public Object fromStrings(Type targetType,
                          List<String> value)

toDate

public Date toDate(Type sourceType,
                   Object value)

fromDate

public Object fromDate(Type targetType,
                       Date value)

toTemporalDataType

public String toTemporalDataType(Type targetType,
                                 Type sourceType,
                                 Object value)

fromTemporalDataType

public Object fromTemporalDataType(Type targetType,
                                   Type sourceType,
                                   String value)

toPrimitiveJavaClass

public Class<?> toPrimitiveJavaClass(DataType dataType)
Returns a primitive Java class, wherever possible, for the given SDO data-type (as per the SDO Specification 2.10 Section 8.1), and where no primitive exists for the give SDO datatype, the appropriate class is returned.

Parameters:
dataType - the SDO datatype
Returns:
the primitive Java class.

toWrapperJavaClass

public Class<?> toWrapperJavaClass(DataType dataType)
Returns a primitive wrapper Java class, wherever possible, for the given SDO data-type (as per the SDO Specification 2.10 Section 8.1), and where no primitive exists for the give SDO datatype, the appropriate class is returned.

Parameters:
dataType - the SDO datatype
Returns:
the primitive Java class.

getAllowableTargetTypes

public List<DataType> getAllowableTargetTypes(DataType dataType)


Copyright © 2014. All rights reserved.