1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
/**
* <copyright>
*
* Service Data Objects
* Version 2.1.0
* Licensed Materials
*
* (c) Copyright BEA Systems, Inc., International Business Machines Corporation,
* Oracle Corporation, Primeton Technologies Ltd., Rogue Wave Software, SAP AG.,
* Software AG., Sun Microsystems, Sybase Inc., Xcalia, Zend Technologies,
* 2005, 2006. All rights reserved.
*
* </copyright>
*
*/
package commonj.sdo.helper;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import commonj.sdo.Type;
import commonj.sdo.Property;
import commonj.sdo.impl.HelperProvider;
/**
* Data helper methods.
*/
public interface DataHelper
{
/**
* Convert from a String representation of an SDO date type to a Date.
* @param dateString the String representation of an SDO date type
* @return a Date representation of an SDO date type.
* @throws IllegalArgumentException for invalid formats.
*/
Date toDate(String dateString);
/**
* Convert from a String representation of an SDO date type to a Calendar using the
* default locale. Same as toCalendar(dateString, null).
* @param dateString the String representation of an SDO date type
* @return a Calendar representation of an SDO date type.
* @throws IllegalArgumentException for invalid formats.
*/
Calendar toCalendar(String dateString);
/**
* 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.
* @param dateString the String representation of an SDO date type
* @param locale the locale or null for default locale.
* @return a Calendar representation of an SDO date type.
* @throws IllegalArgumentException for invalid formats.
*/
Calendar toCalendar(String dateString, Locale locale);
/**
* Convert from a Date to a String representation of the DateTime type.
* @param date the date
* @return a Date to a String representation of the DateTime type.
*/
String toDateTime(Date date);
/**
* Convert from a Date to a String representation of the Duration type.
* @param date the date
* @return a Date to a String representation of the Duration type.
*/
String toDuration(Date date);
/**
* Convert from a Date to a String representation of the Time type.
* @param date the date
* @return a Date to a String representation of the Time type.
*/
String toTime(Date date);
/**
* Convert from a Date to a String representation of the Day type.
* @param date the date
* @return a Date to a String representation of the Day type.
*/
String toDay(Date date);
/**
* Convert from a Date to a String representation of the Month type.
* @param date the date
* @return a Date to a String representation of the Month type.
*/
String toMonth(Date date);
/**
* Convert from a Date to a String representation of the MonthDay type.
* @param date the date
* @return a Date to a String representation of the MonthDay type.
*/
String toMonthDay(Date date);
/**
* Convert from a Date to a String representation of the Year type.
* @param date the date
* @return a Date to a String representation of the Year type.
*/
String toYear(Date date);
/**
* Convert from a Date to a String representation of the YearMonth type.
* @param date the date
* @return a Date to a String representation of the YearMonth type.
*/
String toYearMonth(Date date);
/**
* Convert from a Date to a String representation of the YearMonthDay type.
* @param date the date
* @return a Date to a String representation of the YearMonthDay type.
*/
String toYearMonthDay(Date date);
/**
* Convert from a Calendar to a String representation of the DateTime type.
* @param calendar the calendar to convert
* @return a Calendar to a String representation of the DateTime type.
*/
String toDateTime(Calendar calendar);
/**
* Convert from a Calendar to a String representation of the Duration type.
* @param calendar the calendar to convert
* @return a Calendar to a String representation of the Duration type.
*/
String toDuration(Calendar calendar);
/**
* Convert from a Calendar to a String representation of the Time type.
* @param calendar the calendar to convert
* @return a Calendar to a String representation of the Time type.
*/
String toTime(Calendar calendar);
/**
* Convert from a Calendar to a String representation of the Day type.
* @param calendar the calendar to convert
* @return a Calendar to a String representation of the Day type.
*/
String toDay(Calendar calendar);
/**
* Convert from a Calendar to a String representation of the Month type.
* @param calendar the calendar to convert
* @return a Calendar to a String representation of the Month type.
*/
String toMonth(Calendar calendar);
/**
* Convert from a Calendar to a String representation of the MonthDay type.
* @param calendar the calendar to convert
* @return a Calendar to a String representation of the MonthDay type.
*/
String toMonthDay(Calendar calendar);
/**
* Convert from a Calendar to a String representation of the Year type.
* @param calendar the calendar to convert
* @return a Calendar to a String representation of the Year type.
*/
String toYear(Calendar calendar);
/**
* Convert from a Calendar to a String representation of the YearMonth type.
* @param calendar the calendar to convert
* @return a Calendar to a String representation of the YearMonth type.
*/
String toYearMonth(Calendar calendar);
/**
* Convert from a Calendar to a String representation of the YearMonthDay type.
* @param calendar the calendar to convert
* @return a Calendar to a String representation of the YearMonthDay type.
*/
String toYearMonthDay(Calendar calendar);
/**
* Convert the specified value to an {@link Type#getInstanceClass() instance}
* of the specified type.
* Supported conversions are listed in Section 16 of the SDO specification.
* @param type the target {@link Type#isDataType() data type}.
* @param value the value to convert
* @return a value of the specified type's instance class
* @throws IllegalArgumentException if the value could not be converted
* @see #convert(Property, Object)
*/
Object convert(Type type, Object value);
/**
* Convert the specified value to an {@link Type#getInstanceClass() instance}
* of the specified property's {@link Property#getType() type}.
* The specified value must be a List if the property is {@link Property#isMany()
* many valued}. In this case, all the values in the List are converted.
* @param property the target {@link Type#isDataType() data type} property.
* @param value the value or List of values to convert
* @return a converted value or list of converted values
* @throws IllegalArgumentException if the value could not be converted
* @see #convert(Type, Object)
*/
Object convert(Property property, Object value);
/**
* The default DataHelper.
*/
DataHelper INSTANCE = HelperProvider.getDataHelper();
}
|