Class SDODataHelper
- java.lang.Object
-
- org.eclipse.persistence.sdo.helper.SDODataHelper
-
- All Implemented Interfaces:
commonj.sdo.helper.DataHelper
public class SDODataHelper extends java.lang.Object implements commonj.sdo.helper.DataHelperPurpose: A helper class for performing data conversions.
-
-
Constructor Summary
Constructors Constructor Description SDODataHelper()SDODataHelper(commonj.sdo.helper.HelperContext aContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectconvert(commonj.sdo.Property property, java.lang.Object value)Convert the specified value to aninstanceof the specified property'stype.java.lang.Objectconvert(commonj.sdo.Type type, java.lang.Object value)Convert the specified value to aninstanceof the specified type.java.lang.ObjectconvertFromStringValue(java.lang.String value, commonj.sdo.Type sdoType)Convert a String value based to the appropriate type.java.lang.ObjectconvertFromStringValue(java.lang.String value, commonj.sdo.Type sdoType, javax.xml.namespace.QName schemaType)Convert a String value based to the appropriate type.java.lang.ObjectconvertFromStringValue(java.lang.String value, java.lang.Class convertClass)Convert a String value based to the appropriate type.java.lang.ObjectconvertFromStringValue(java.lang.String value, java.lang.Class convertClass, javax.xml.namespace.QName schemaType)Convert a String value based to the appropriate type.java.lang.StringconvertToStringValue(java.lang.Object value, commonj.sdo.Type sdoType)Convert to a String value based to the SDO type.java.lang.ObjectconvertValue(java.lang.Object value, java.lang.Class convertClass, javax.xml.namespace.QName schemaType)Convert a value based to the appropriate type.java.lang.ObjectconvertValueToClass(commonj.sdo.Property prop, java.lang.Object valueToConvert, java.lang.Class convertToClass)INTERNAL:commonj.sdo.helper.HelperContextgetHelperContext()INTERNAL:voidsetHelperContext(commonj.sdo.helper.HelperContext helperContext)INTERNAL:voidsetTimeZone(java.util.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.java.util.CalendartoCalendar(java.lang.String dateString)Convert from a String representation of an SDO date type to a Calendar using the default locale.java.util.CalendartoCalendar(java.lang.String dateString, java.util.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.java.util.DatetoDate(java.lang.String dateString)Convert from a String representation of the Date type to a Date.java.lang.StringtoDateTime(java.util.Calendar calendar)Convert from a Calendar to a String representation of the DateTime type.java.lang.StringtoDateTime(java.util.Date date)Convert from a Date to a String representation of the DateTime type.java.lang.StringtoDay(java.util.Calendar calendar)Convert from a Calendar to a String representation of the Day type.java.lang.StringtoDay(java.util.Date date)Convert from a Date to a String representation of the Day type.java.lang.StringtoDuration(java.util.Calendar calendar)Convert from a Calendar to a String representation of the Duration type.java.lang.StringtoDuration(java.util.Date date)Convert from a Date to a String representation of the Duration type.java.lang.StringtoMonth(java.util.Calendar calendar)Convert from a Calendar to a String representation of the Month type.java.lang.StringtoMonth(java.util.Date date)Convert from a Date to a String representation of the Month type.java.lang.StringtoMonthDay(java.util.Calendar calendar)Convert from a Calendar to a String representation of the MonthDay type.java.lang.StringtoMonthDay(java.util.Date date)Convert from a Date to a String representation of the MonthDay type.java.lang.StringtoTime(java.util.Calendar calendar)Convert from a Calendar to a String representation of the Time type.java.lang.StringtoTime(java.util.Date date)Convert from a Date to a String representation of the Time type.java.lang.StringtoYear(java.util.Calendar calendar)Convert from a Calendar to a String representation of the Year type.java.lang.StringtoYear(java.util.Date date)Convert from a Date to a String representation of the Year type.java.lang.StringtoYearMonth(java.util.Calendar calendar)Convert from a Calendar to a String representation of the YearMonth type.java.lang.StringtoYearMonth(java.util.Date date)Convert from a Date to a String representation of the YearMonth type.java.lang.StringtoYearMonthDay(java.util.Calendar calendar)Convert from a Calendar to a String representation of the YearMonthDay type.java.lang.StringtoYearMonthDay(java.util.Date date)Convert from a Date to a String representation of the YearMonthDay type.
-
-
-
Method Detail
-
setTimeZone
public void setTimeZone(java.util.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 java.util.Calendar toCalendar(java.lang.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 interfacecommonj.sdo.helper.DataHelper- Parameters:
dateString- the String representation of an SDO date type- Returns:
- a Calendar representation of an SDO date type.
- Throws:
java.lang.IllegalArgumentException- for invalid formats.
-
toCalendar
public java.util.Calendar toCalendar(java.lang.String dateString, java.util.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 interfacecommonj.sdo.helper.DataHelper- 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:
java.lang.IllegalArgumentException- for invalid formats.
-
toDate
public java.util.Date toDate(java.lang.String dateString)
Convert from a String representation of the Date type to a Date.- Specified by:
toDatein interfacecommonj.sdo.helper.DataHelper- Parameters:
dateString- a String representation of the Date type- Returns:
- a Date from a String representation of the Date type.
-
toDateTime
public java.lang.String toDateTime(java.util.Calendar calendar)
Convert from a Calendar to a String representation of the DateTime type.- Specified by:
toDateTimein interfacecommonj.sdo.helper.DataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the DateTime type.
-
toDateTime
public java.lang.String toDateTime(java.util.Date date)
Convert from a Date to a String representation of the DateTime type.- Specified by:
toDateTimein interfacecommonj.sdo.helper.DataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the DateTime type.
-
toDay
public java.lang.String toDay(java.util.Calendar calendar)
Convert from a Calendar to a String representation of the Day type.- Specified by:
toDayin interfacecommonj.sdo.helper.DataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the Day type.
-
toDay
public java.lang.String toDay(java.util.Date date)
Convert from a Date to a String representation of the Day type.- Specified by:
toDayin interfacecommonj.sdo.helper.DataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the Day type.
-
toDuration
public java.lang.String toDuration(java.util.Calendar calendar)
Convert from a Calendar to a String representation of the Duration type.- Specified by:
toDurationin interfacecommonj.sdo.helper.DataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the Duration type.
-
toDuration
public java.lang.String toDuration(java.util.Date date)
Convert from a Date to a String representation of the Duration type.- Specified by:
toDurationin interfacecommonj.sdo.helper.DataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the Duration type.
-
toMonth
public java.lang.String toMonth(java.util.Calendar calendar)
Convert from a Calendar to a String representation of the Month type.- Specified by:
toMonthin interfacecommonj.sdo.helper.DataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the Month type.
-
toMonth
public java.lang.String toMonth(java.util.Date date)
Convert from a Date to a String representation of the Month type.- Specified by:
toMonthin interfacecommonj.sdo.helper.DataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the Month type.
-
toMonthDay
public java.lang.String toMonthDay(java.util.Calendar calendar)
Convert from a Calendar to a String representation of the MonthDay type.- Specified by:
toMonthDayin interfacecommonj.sdo.helper.DataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the MonthDay type.
-
toMonthDay
public java.lang.String toMonthDay(java.util.Date date)
Convert from a Date to a String representation of the MonthDay type.- Specified by:
toMonthDayin interfacecommonj.sdo.helper.DataHelper- Parameters:
date- the date to convert- Returns:
- a Date to a String representation of the MonthDay type.
-
toTime
public java.lang.String toTime(java.util.Calendar calendar)
Convert from a Calendar to a String representation of the Time type.- Specified by:
toTimein interfacecommonj.sdo.helper.DataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the Time type.
-
toTime
public java.lang.String toTime(java.util.Date date)
Convert from a Date to a String representation of the Time type.- Specified by:
toTimein interfacecommonj.sdo.helper.DataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the Time type.
-
toYear
public java.lang.String toYear(java.util.Calendar calendar)
Convert from a Calendar to a String representation of the Year type.- Specified by:
toYearin interfacecommonj.sdo.helper.DataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the Year type.
-
toYear
public java.lang.String toYear(java.util.Date date)
Convert from a Date to a String representation of the Year type.- Specified by:
toYearin interfacecommonj.sdo.helper.DataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the Year type.
-
toYearMonth
public java.lang.String toYearMonth(java.util.Date date)
Convert from a Date to a String representation of the YearMonth type.- Specified by:
toYearMonthin interfacecommonj.sdo.helper.DataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the YearMonth type.
-
toYearMonthDay
public java.lang.String toYearMonthDay(java.util.Date date)
Convert from a Date to a String representation of the YearMonthDay type.- Specified by:
toYearMonthDayin interfacecommonj.sdo.helper.DataHelper- Parameters:
date- the date- Returns:
- a Date to a String representation of the YearMonthDay type.
-
toYearMonth
public java.lang.String toYearMonth(java.util.Calendar calendar)
Convert from a Calendar to a String representation of the YearMonth type.- Specified by:
toYearMonthin interfacecommonj.sdo.helper.DataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the YearMonth type.
-
toYearMonthDay
public java.lang.String toYearMonthDay(java.util.Calendar calendar)
Convert from a Calendar to a String representation of the YearMonthDay type.- Specified by:
toYearMonthDayin interfacecommonj.sdo.helper.DataHelper- Parameters:
calendar- the calendar to convert- Returns:
- a Calendar to a String representation of the YearMonthDay type.
-
convertValue
public java.lang.Object convertValue(java.lang.Object value, java.lang.Class convertClass, javax.xml.namespace.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 java.lang.Object convertFromStringValue(java.lang.String value, java.lang.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 java.lang.Object convertFromStringValue(java.lang.String value, commonj.sdo.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 java.lang.Object convertFromStringValue(java.lang.String value, commonj.sdo.Type sdoType, javax.xml.namespace.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 java.lang.Object convertFromStringValue(java.lang.String value, java.lang.Class convertClass, javax.xml.namespace.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 java.lang.String convertToStringValue(java.lang.Object value, commonj.sdo.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 java.lang.Object convert(commonj.sdo.Type type, java.lang.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 interfacecommonj.sdo.helper.DataHelper- Parameters:
type- the targetdata type.value- the value to convert- Returns:
- a value of the specified type's instance class
- Throws:
java.lang.IllegalArgumentException- if the value could not be converted- See Also:
convert(Property, Object)
-
convert
public java.lang.Object convert(commonj.sdo.Property property, java.lang.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 interfacecommonj.sdo.helper.DataHelper- Parameters:
property- the targetdata typeproperty.value- the value or List of values to convert- Returns:
- a converted value or list of converted values
- Throws:
java.lang.IllegalArgumentException- if the value could not be converted- See Also:
convert(Type, Object)
-
convertValueToClass
public java.lang.Object convertValueToClass(commonj.sdo.Property prop, java.lang.Object valueToConvert, java.lang.Class convertToClass)INTERNAL:
-
getHelperContext
public commonj.sdo.helper.HelperContext getHelperContext()
INTERNAL:
-
setHelperContext
public void setHelperContext(commonj.sdo.helper.HelperContext helperContext)
INTERNAL:
-
-