org.apache.tuscany.sdo.helper
Class DataHelperImpl

java.lang.Object
  extended by org.apache.tuscany.sdo.helper.DataHelperImpl
All Implemented Interfaces:
DataHelper

public class DataHelperImpl
extends Object
implements DataHelper

Data helper methods.


Field Summary
 
Fields inherited from interface commonj.sdo.helper.DataHelper
INSTANCE
 
Constructor Summary
DataHelperImpl()
           
 
Method Summary
 Object convert(Property property, Object value)
          Convert the specified value to an instance of the specified property's type.
 Object convert(Type type, Object value)
          Convert the specified value to an instance of the specified type.
 Date handleBCE(Date output)
           
 Date handleNegative(Date output)
           
 String obtainDurationFormats(String dateString)
           
 String obtainSpecificFormat(String dateString)
           
 Calendar toCalendar(String dateString)
          Convert from a String representation of an SDO date type to a Calendar using the default locale.
 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.
 Date toDate(String dateString)
          Convert from a String representation of an SDO date type to a Date.
 String toDateTime(Calendar calendar)
          Convert from a Calendar to a String representation of the DateTime type.
 String toDateTime(Date date)
          Convert from a Date to a String representation of the DateTime type.
 String toDay(Calendar calendar)
          Convert from a Calendar to a String representation of the Day type.
 String toDay(Date date)
          Convert from a Date to a String representation of the Day type.
 String toDuration(Calendar calendar)
          Convert from a Calendar to a String representation of the Duration type.
 String toDuration(Date date)
          Convert from a Date to a String representation of the Duration type.
 String toMonth(Calendar calendar)
          Convert from a Calendar to a String representation of the Month type.
 String toMonth(Date date)
          Convert from a Date to a String representation of the Month type.
 String toMonthDay(Calendar calendar)
          Convert from a Calendar to a String representation of the MonthDay type.
 String toMonthDay(Date date)
          Convert from a Date to a String representation of the MonthDay type.
 String toTime(Calendar calendar)
          Convert from a Calendar to a String representation of the Time type.
 String toTime(Date date)
          Convert from a Date to a String representation of the Time type.
 String toYear(Calendar calendar)
          Convert from a Calendar to a String representation of the Year type.
 String toYear(Date date)
          Convert from a Date to a String representation of the Year type.
 String toYearMonth(Calendar calendar)
          Convert from a Calendar to a String representation of the YearMonth type.
 String toYearMonth(Date date)
          Convert from a Date to a String representation of the YearMonth type.
 String toYearMonthDay(Calendar calendar)
          Convert from a Calendar to a String representation of the YearMonthDay type.
 String toYearMonthDay(Date date)
          Convert from a Date to a String representation of the YearMonthDay type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataHelperImpl

public DataHelperImpl()
Method Detail

toDate

public Date toDate(String dateString)
Description copied from interface: DataHelper
Convert from a String representation of an SDO date type to a Date.

Specified by:
toDate in interface DataHelper
Parameters:
dateString - - Must comply to the pattern of yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'
Returns:
null if dataString couldn't be parsed

obtainSpecificFormat

public String obtainSpecificFormat(String dateString)

obtainDurationFormats

public String obtainDurationFormats(String dateString)

handleNegative

public Date handleNegative(Date output)

handleBCE

public Date handleBCE(Date output)

toCalendar

public Calendar toCalendar(String dateString)
Description copied from interface: DataHelper
Convert from a String representation of an SDO date type to a Calendar using the default locale. Same as toCalendar(dateString, null).

Specified by:
toCalendar in interface DataHelper
Parameters:
dateString - the String representation of an SDO date type
Returns:
a Calendar representation of an SDO date type.

toCalendar

public Calendar toCalendar(String dateString,
                           Locale locale)
Description copied from interface: DataHelper
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:
toCalendar in interface DataHelper
Parameters:
dateString - the String representation of an SDO date type
locale - the locale or null for default locale.
Returns:
a Calendar representation of an SDO date type.

toDateTime

public String toDateTime(Date date)
Description copied from interface: DataHelper
Convert from a Date to a String representation of the DateTime type.

Specified by:
toDateTime in interface DataHelper
Parameters:
date - the date
Returns:
a Date to a String representation of the DateTime type.

toDuration

public String toDuration(Date date)
Description copied from interface: DataHelper
Convert from a Date to a String representation of the Duration type.

Specified by:
toDuration in interface DataHelper
Parameters:
date - the date
Returns:
a Date to a String representation of the Duration type.

toTime

public String toTime(Date date)
Description copied from interface: DataHelper
Convert from a Date to a String representation of the Time type.

Specified by:
toTime in interface DataHelper
Parameters:
date - the date
Returns:
a Date to a String representation of the Time type.

toDay

public String toDay(Date date)
Description copied from interface: DataHelper
Convert from a Date to a String representation of the Day type.

Specified by:
toDay in interface DataHelper
Parameters:
date - the date
Returns:
a Date to a String representation of the Day type.

toMonth

public String toMonth(Date date)
Description copied from interface: DataHelper
Convert from a Date to a String representation of the Month type.

Specified by:
toMonth in interface DataHelper
Parameters:
date - the date
Returns:
a Date to a String representation of the Month type.

toMonthDay

public String toMonthDay(Date date)
Description copied from interface: DataHelper
Convert from a Date to a String representation of the MonthDay type.

Specified by:
toMonthDay in interface DataHelper
Parameters:
date - the date
Returns:
a Date to a String representation of the MonthDay type.

toYear

public String toYear(Date date)
Description copied from interface: DataHelper
Convert from a Date to a String representation of the Year type.

Specified by:
toYear in interface DataHelper
Parameters:
date - the date
Returns:
a Date to a String representation of the Year type.

toYearMonth

public String toYearMonth(Date date)
Description copied from interface: DataHelper
Convert from a Date to a String representation of the YearMonth type.

Specified by:
toYearMonth in interface DataHelper
Parameters:
date - the date
Returns:
a Date to a String representation of the YearMonth type.

toYearMonthDay

public String toYearMonthDay(Date date)
Description copied from interface: DataHelper
Convert from a Date to a String representation of the YearMonthDay type.

Specified by:
toYearMonthDay in interface DataHelper
Parameters:
date - the date
Returns:
a Date to a String representation of the YearMonthDay type.

toDateTime

public String toDateTime(Calendar calendar)
Description copied from interface: DataHelper
Convert from a Calendar to a String representation of the DateTime type.

Specified by:
toDateTime in interface DataHelper
Parameters:
calendar - the calendar to convert
Returns:
a Calendar to a String representation of the DateTime type.

toDuration

public String toDuration(Calendar calendar)
Description copied from interface: DataHelper
Convert from a Calendar to a String representation of the Duration type.

Specified by:
toDuration in interface DataHelper
Parameters:
calendar - the calendar to convert
Returns:
a Calendar to a String representation of the Duration type.

toTime

public String toTime(Calendar calendar)
Description copied from interface: DataHelper
Convert from a Calendar to a String representation of the Time type.

Specified by:
toTime in interface DataHelper
Parameters:
calendar - the calendar to convert
Returns:
a Calendar to a String representation of the Time type.

toDay

public String toDay(Calendar calendar)
Description copied from interface: DataHelper
Convert from a Calendar to a String representation of the Day type.

Specified by:
toDay in interface DataHelper
Parameters:
calendar - the calendar to convert
Returns:
a Calendar to a String representation of the Day type.

toMonth

public String toMonth(Calendar calendar)
Description copied from interface: DataHelper
Convert from a Calendar to a String representation of the Month type.

Specified by:
toMonth in interface DataHelper
Parameters:
calendar - the calendar to convert
Returns:
a Calendar to a String representation of the Month type.

toMonthDay

public String toMonthDay(Calendar calendar)
Description copied from interface: DataHelper
Convert from a Calendar to a String representation of the MonthDay type.

Specified by:
toMonthDay in interface DataHelper
Parameters:
calendar - the calendar to convert
Returns:
a Calendar to a String representation of the MonthDay type.

toYear

public String toYear(Calendar calendar)
Description copied from interface: DataHelper
Convert from a Calendar to a String representation of the Year type.

Specified by:
toYear in interface DataHelper
Parameters:
calendar - the calendar to convert
Returns:
a Calendar to a String representation of the Year type.

toYearMonth

public String toYearMonth(Calendar calendar)
Description copied from interface: DataHelper
Convert from a Calendar to a String representation of the YearMonth type.

Specified by:
toYearMonth in interface DataHelper
Parameters:
calendar - the calendar to convert
Returns:
a Calendar to a String representation of the YearMonth type.

toYearMonthDay

public String toYearMonthDay(Calendar calendar)
Description copied from interface: DataHelper
Convert from a Calendar to a String representation of the YearMonthDay type.

Specified by:
toYearMonthDay in interface DataHelper
Parameters:
calendar - the calendar to convert
Returns:
a Calendar to a String representation of the YearMonthDay type.

convert

public Object convert(Type type,
                      Object value)
Description copied from interface: DataHelper
Convert the specified value to an instance of the specified type. Supported conversions are listed in Section 16 of the SDO specification.

Specified by:
convert in interface DataHelper
Parameters:
type - the target data type.
value - the value to convert
Returns:
a value of the specified type's instance class
See Also:
DataHelper.convert(Property, Object)

convert

public Object convert(Property property,
                      Object value)
Description copied from interface: DataHelper
Convert the specified value to an instance of the specified property's type. The specified value must be a List if the property is many valued. In this case, all the values in the List are converted.

Specified by:
convert in interface DataHelper
Parameters:
property - the target data type property.
value - the value or List of values to convert
Returns:
a converted value or list of converted values
See Also:
DataHelper.convert(Type, Object)


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.