- java.lang.Object
-
- org.eclipse.persistence.sdo.helper.SDODataHelper
-
- All Implemented Interfaces:
DataHelper
public class SDODataHelper extends Object implements DataHelper
Purpose: A helper class for performing data conversions.
-
-
Field Summary
-
Fields inherited from interface commonj.sdo.helper.DataHelper
INSTANCE
-
-
Constructor Summary
Constructors Constructor Description SDODataHelper()SDODataHelper(HelperContext aContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectconvert(Property property, Object value)Objectconvert(Type type, Object value)Convert the specified value to aninstanceof the specified type.ObjectconvertFromStringValue(String value, Type sdoType)Convert a String value based to the appropriate type.ObjectconvertFromStringValue(String value, Type sdoType, QName schemaType)Convert a String value based to the appropriate type.ObjectconvertFromStringValue(String value, Class<?> convertClass)Convert a String value based to the appropriate type.ObjectconvertFromStringValue(String value, Class<?> convertClass, QName schemaType)Convert a String value based to the appropriate type.StringconvertToStringValue(Object value, Type sdoType)Convert to a String value based to the SDO type.ObjectconvertValue(Object value, Class<?> convertClass, QName schemaType)Convert a value based to the appropriate type.ObjectconvertValueToClass(Property prop, Object valueToConvert, Class<?> convertToClass)INTERNAL:HelperContextgetHelperContext()INTERNAL:voidsetHelperContext(HelperContext helperContext)INTERNAL:voidsetTimeZone(TimeZone timeZone)The specified TimeZone will be used for all String to Date object conversions.voidsetTimeZoneQualified(boolean timeZoneQualified)By setting this flag to true the marshalled date objects marshalled to the XML schema types time and dateTime will be qualified by a time zone.CalendartoCalendar(String dateString)Convert from a String representation of an SDO date type to a Calendar using the default locale.CalendartoCalendar(String dateString, Locale locale)Convert from a String representation of an SDO date type to a Calendar using the specified locale, or the default locale if the locale is null.DatetoDate(String dateString)Convert from a String representation of the Date type to a Date.StringtoDateTime(Calendar calendar)Convert from a Calendar to a String representation of the DateTime type.StringtoDateTime(Date date)Convert from a Date to a String representation of the DateTime type.StringtoDay(Calendar calendar)Convert from a Calendar to a String representation of the Day type.StringtoDay(Date date)Convert from a Date to a String representation of the Day type.StringtoDuration(Calendar calendar)Convert from a Calendar to a String representation of the Duration type.StringtoDuration(Date date)Convert from a Date to a String representation of the Duration type.StringtoMonth(Calendar calendar)Convert from a Calendar to a String representation of the Month type.StringtoMonth(Date date)Convert from a Date to a String representation of the Month type.StringtoMonthDay(Calendar calendar)Convert from a Calendar to a String representation of the MonthDay type.StringtoMonthDay(Date date)Convert from a Date to a String representation of the MonthDay type.StringtoTime(Calendar calendar)Convert from a Calendar to a String representation of the Time type.StringtoTime(Date date)Convert from a Date to a String representation of the Time type.StringtoYear(Calendar calendar)Convert from a Calendar to a String representation of the Year type.StringtoYear(Date date)Convert from a Date to a String representation of the Year type.StringtoYearMonth(Calendar calendar)Convert from a Calendar to a String representation of the YearMonth type.StringtoYearMonth(Date date)Convert from a Date to a String representation of the YearMonth type.StringtoYearMonthDay(Calendar calendar)Convert from a Calendar to a String representation of the YearMonthDay type.StringtoYearMonthDay(Date date)Convert from a Date to a String representation of the YearMonthDay type.
-
-
-
Constructor Detail
-
SDODataHelper
public SDODataHelper()
-
SDODataHelper
public SDODataHelper(HelperContext aContext)
-
-
Method Detail
-
setTimeZone
public void setTimeZone(TimeZone timeZone)
The specified TimeZone will be used for all String to Date object conversions. By default the GMT time zone is used.
-
setTimeZoneQualified
public void setTimeZoneQualified(boolean timeZoneQualified)
By setting this flag to true the marshalled date objects marshalled to the XML schema types time and dateTime will be qualified by a time zone. By default time information is not time zone qualified.
-
toCalendar
public Calendar toCalendar(String dateString)
Convert from a String representation of an SDO date type to a Calendar using the default locale. Same as toCalendar(dateString, null).- Specified by:
toCalendarin interfaceDataHelper- Parameters:
dateString- the String representation of an SDO date type- Returns:
- a Calendar representation of an SDO date type.
- Throws:
IllegalArgumentException- for invalid formats.
-
toCalendar
public Calendar toCalendar(String dateString, Locale locale)
Convert from a String representation of an SDO date type to a Calendar using the specified locale, or the default locale if the locale is null.- Specified by:
toCalendarin interfaceDataHelper- Parameters:
dateString- the String representation of an SDO date typelocale- the locale or null for default locale.- Returns:
- a Calendar representation of an SDO date type.
- Throws:
IllegalArgumentException- for invalid formats.
-
toDate
public Date toDate(String dateString)
Convert from a String representation of the Date type to a Date.- Specified by:
toDatein interfaceDataHelper- Parameters:
dateString- a String representation of the Date type- Returns:
- a Date from a String representation of the Date type.
-
toDateTime
public String toDateTime(Calendar calendar)
Convert from a Calendar to a String representation of the DateTime type.- Specified by:
toDateTimein interfaceDataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the DateTime type.
-
toDateTime
public String toDateTime(Date date)
Convert from a Date to a String representation of the DateTime type.- Specified by:
toDateTimein interfaceDataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the DateTime type.
-
toDay
public String toDay(Calendar calendar)
Convert from a Calendar to a String representation of the Day type.- Specified by:
toDayin interfaceDataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the Day type.
-
toDay
public String toDay(Date date)
Convert from a Date to a String representation of the Day type.- Specified by:
toDayin interfaceDataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the Day type.
-
toDuration
public String toDuration(Calendar calendar)
Convert from a Calendar to a String representation of the Duration type.- Specified by:
toDurationin interfaceDataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the Duration type.
-
toDuration
public String toDuration(Date date)
Convert from a Date to a String representation of the Duration type.- Specified by:
toDurationin interfaceDataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the Duration type.
-
toMonth
public String toMonth(Calendar calendar)
Convert from a Calendar to a String representation of the Month type.- Specified by:
toMonthin interfaceDataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the Month type.
-
toMonth
public String toMonth(Date date)
Convert from a Date to a String representation of the Month type.- Specified by:
toMonthin interfaceDataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the Month type.
-
toMonthDay
public String toMonthDay(Calendar calendar)
Convert from a Calendar to a String representation of the MonthDay type.- Specified by:
toMonthDayin interfaceDataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the MonthDay type.
-
toMonthDay
public String toMonthDay(Date date)
Convert from a Date to a String representation of the MonthDay type.- Specified by:
toMonthDayin interfaceDataHelper- Parameters:
date- the date to convert- Returns:
- a Date to a String representation of the MonthDay type.
-
toTime
public String toTime(Calendar calendar)
Convert from a Calendar to a String representation of the Time type.- Specified by:
toTimein interfaceDataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the Time type.
-
toTime
public String toTime(Date date)
Convert from a Date to a String representation of the Time type.- Specified by:
toTimein interfaceDataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the Time type.
-
toYear
public String toYear(Calendar calendar)
Convert from a Calendar to a String representation of the Year type.- Specified by:
toYearin interfaceDataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the Year type.
-
toYear
public String toYear(Date date)
Convert from a Date to a String representation of the Year type.- Specified by:
toYearin interfaceDataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the Year type.
-
toYearMonth
public String toYearMonth(Date date)
Convert from a Date to a String representation of the YearMonth type.- Specified by:
toYearMonthin interfaceDataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the YearMonth type.
-
toYearMonthDay
public String toYearMonthDay(Date date)
Convert from a Date to a String representation of the YearMonthDay type.- Specified by:
toYearMonthDayin interfaceDataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the YearMonthDay type.
-
toYearMonth
public String toYearMonth(Calendar calendar)
Convert from a Calendar to a String representation of the YearMonth type.- Specified by:
toYearMonthin interfaceDataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the YearMonth type.
-
toYearMonthDay
public String toYearMonthDay(Calendar calendar)
Convert from a Calendar to a String representation of the YearMonthDay type.- Specified by:
toYearMonthDayin interfaceDataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the YearMonthDay type.
-
convertValue
public Object convertValue(Object value, Class<?> convertClass, QName schemaType)
Convert a value based to the appropriate type.- Parameters:
value- The value to convert.convertClass- The class to convert the value to.schemaType- The schema type if available.- Returns:
- the original value converted based on the convertClass parameter.
-
convertFromStringValue
public Object convertFromStringValue(String value, Class<?> convertClass)
Convert a String value based to the appropriate type.- Parameters:
value- The String value to convert.convertClass- The class to convert the value to.- Returns:
- the original value converted based on the convertClass parameter.
-
convertFromStringValue
public Object convertFromStringValue(String value, Type sdoType)
Convert a String value based to the appropriate type.- Parameters:
value- The String value to convert.sdoType- The SDO type of the value to convert the value to.- Returns:
- the original value converted based on the SDO type.
-
convertFromStringValue
public Object convertFromStringValue(String value, Type sdoType, QName schemaType)
Convert a String value based to the appropriate type.- Parameters:
value- The String value to convert.sdoType- The SDO type of the value to convert the value to.schemaType- The schema type if available.- Returns:
- the original value converted based on the convertClass parameter.
-
convertFromStringValue
public Object convertFromStringValue(String value, Class<?> convertClass, QName schemaType)
Convert a String value based to the appropriate type.- Parameters:
value- The String value to convert.convertClass- The class to convert the value to.schemaType- The schema type if available.- Returns:
- the original value converted based on the convertClass parameter.
-
convertToStringValue
public String convertToStringValue(Object value, Type sdoType)
Convert to a String value based to the SDO type.- Parameters:
value- The value to convert.sdoType- the SDO type- Returns:
- the original value converted to a String based on the SDO type specified.
-
convert
public Object convert(Type type, Object value)
Convert the specified value to aninstanceof the specified type. Supported conversions are listed in Section 14 of the SDO specification.- Specified by:
convertin interfaceDataHelper- Parameters:
type- the targetdata type.value- the value to convert- Returns:
- a value of the specified type's instance class
- Throws:
IllegalArgumentException- if the value could not be converted- See Also:
convert(Property, Object)
-
convert
public Object convert(Property property, Object value)
Convert the specified value to aninstanceof the specified property'stype. The specified value must be a List if the property ismany valued. In this case, all the values in the List are converted.- Specified by:
convertin interfaceDataHelper- Parameters:
property- the targetdata typeproperty.value- the value or List of values to convert- Returns:
- a converted value or list of converted values
- Throws:
IllegalArgumentException- if the value could not be converted- See Also:
convert(Type, Object)
-
convertValueToClass
public Object convertValueToClass(Property prop, Object valueToConvert, Class<?> convertToClass)
INTERNAL:
-
getHelperContext
public HelperContext getHelperContext()
INTERNAL:
-
setHelperContext
public void setHelperContext(HelperContext helperContext)
INTERNAL:
-
-