KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > types > DataValueFactory


1 /*
2
3    Derby - Class org.apache.derby.iapi.types.DataValueFactory
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.types;
23
24 import org.apache.derby.iapi.types.RowLocation;
25
26 import org.apache.derby.iapi.error.StandardException;
27
28 import java.sql.Date JavaDoc;
29 import java.sql.Time JavaDoc;
30 import java.sql.Timestamp JavaDoc;
31
32
33 /**
34  * This interface is how we get constant data values of different types.
35  */

36
37 public interface DataValueFactory
38 {
39         /**
40          * Get a SQL int with the given value. A null argument means get
41          * a SQL null value. The second form uses the previous value (if non-null)
42          * to hold the return value.
43          *
44          */

45         NumberDataValue getDataValue(Integer JavaDoc value);
46         NumberDataValue getDataValue(Integer JavaDoc value, NumberDataValue previous)
47                                                         throws StandardException;
48
49         /**
50          * Get a SQL int with a char value. A null argument means get
51          * a SQL null value. The second form uses the previous value (if non-null)
52          * to hold the return value.
53          *
54          */

55         public NumberDataValue getDataValue(char value);
56         public NumberDataValue getDataValue(char value, NumberDataValue previous)
57                                                         throws StandardException;
58
59         /**
60          * Get a SQL smallint with the given value. A null argument means get
61          * a SQL null value. The second form uses the previous value (if non-null)
62          * to hold the return value.
63          *
64          */

65         NumberDataValue getDataValue(Short JavaDoc value);
66         NumberDataValue getDataValue(Short JavaDoc value, NumberDataValue previous)
67                                                         throws StandardException;
68
69         /**
70          * Get a SQL TINYINT with the given value. A null argument means get
71          * a SQL null value. The second form uses the previous value (if non-null)
72          * to hold the return value.
73          *
74          */

75         NumberDataValue getDataValue(Byte JavaDoc value);
76         NumberDataValue getDataValue(Byte JavaDoc value, NumberDataValue previous)
77                                                         throws StandardException;
78
79         /**
80          * Get a SQL bigint with the given value. A null argument means get
81          * a SQL null value. The second form uses the previous value (if non-null)
82          * to hold the return value.
83          *
84          */

85         NumberDataValue getDataValue(Long JavaDoc value);
86         NumberDataValue getDataValue(Long JavaDoc value, NumberDataValue previous)
87                                                         throws StandardException;
88
89         /**
90          * Get a SQL real with the given value. A null argument means get
91          * a SQL null value. The second form uses the previous value (if non-null)
92          * to hold the return value.
93          *
94          */

95         NumberDataValue getDataValue(Float JavaDoc value) throws StandardException;
96         NumberDataValue getDataValue(Float JavaDoc value, NumberDataValue previous)
97                                                         throws StandardException;
98
99         /**
100          * Get a SQL double precision with the given value. A null argument means
101          * a SQL null value. The second form uses the previous value (if non-null)
102          * to hold the return value.
103          *
104          * @exception StandardException Thrown on error
105          */

106         NumberDataValue getDataValue(Double JavaDoc value) throws StandardException;
107         NumberDataValue getDataValue(Double JavaDoc value, NumberDataValue previous)
108                                                         throws StandardException;
109
110         /**
111          * Get a SQL boolean with the given value. A null argument means get
112          * a SQL null value. The second form uses the previous value (if non-null)
113          * to hold the return value.
114          *
115          */

116         BooleanDataValue getDataValue(Boolean JavaDoc value);
117         BooleanDataValue getDataValue(Boolean JavaDoc value, BooleanDataValue previous)
118                                                         throws StandardException;
119         
120         // ------ LONGVARBIT
121

122         /**
123          * Get a SQL Long Bit Varying with the given value. A null argument means
124          * get a SQL null value. The second form uses the previous value (if
125          * non-null) to hold the return value.
126          *
127          * @exception StandardException Thrown on error
128          */

129         BitDataValue getLongVarbitDataValue(byte[] value) throws StandardException;
130         BitDataValue getLongVarbitDataValue(byte[] value,
131                                                                                                 BitDataValue previous)
132                                                         throws StandardException;
133
134         // ------ BLOB
135

136         /**
137          * Get a SQL Blob with the given value. A null argument means
138          * get a SQL null value. The second form uses the previous value (if
139          * non-null) to hold the return value.
140          *
141          * @exception StandardException Thrown on error
142          */

143         BitDataValue getBlobDataValue(byte[] value) throws StandardException;
144         BitDataValue getBlobDataValue(byte[] value,
145                                                                                                 BitDataValue previous)
146                                                         throws StandardException;
147         // ------ BOOLEAN
148
/**
149          * Get a SQL boolean with the given value. A null argument means get
150          * a SQL null value. The second form uses the previous value (if non-null)
151          * to hold the return value.
152          *
153          * @exception StandardException Thrown on error
154          */

155         BooleanDataValue getDataValue(BooleanDataValue value) throws StandardException;
156
157         /**
158          * Get a SQL varchar with the given value. A null argument means get
159          * a SQL null value. The second form uses the previous value (if non-null)
160          * to hold the return value.
161          *
162          */

163         StringDataValue getVarcharDataValue(String JavaDoc value);
164         StringDataValue getVarcharDataValue(String JavaDoc value,
165                                                                                         StringDataValue previous)
166                                                                                                         throws StandardException;
167
168         /**
169          * Get a SQL long varchar with the given value. A null argument means
170          * get a SQL null value. The second form uses the previous value
171          * (if non-null) to hold the return value.
172          *
173          */

174         StringDataValue getLongvarcharDataValue(String JavaDoc value);
175         StringDataValue getLongvarcharDataValue(String JavaDoc value, StringDataValue previous) throws StandardException;
176
177         /**
178          * Get a SQL Clob with the given value. A null argument means
179          * get a SQL null value. The second form uses the previous value
180          * (if non-null) to hold the return value.
181          *
182          */

183         StringDataValue getClobDataValue(String JavaDoc value);
184         StringDataValue getClobDataValue(String JavaDoc value, StringDataValue previous) throws StandardException;
185
186         /**
187          * Get a SQL national varchar with the given value. A null argument means get
188          * a SQL null value. The second form uses the previous value (if non-null)
189          * to hold the return value.
190          */

191         StringDataValue getNationalVarcharDataValue(String JavaDoc value);
192         StringDataValue getNationalVarcharDataValue(String JavaDoc value,
193                                                                                         StringDataValue previous)
194                                                                                                         throws StandardException;
195
196         /**
197          * Get a SQL national long varchar with the given value. A null argument means
198          * get a SQL null value. The second form uses the previous value
199          * (if non-null) to hold the return value.
200          */

201         StringDataValue getNationalLongvarcharDataValue(String JavaDoc value);
202         StringDataValue getNationalLongvarcharDataValue(String JavaDoc value,
203                                                                                                 StringDataValue previous)
204                                                                                                         throws StandardException;
205
206         /**
207          * Get a SQL national blob with the given value. A null argument means
208          * get a SQL null value. The second form uses the previous value
209          * (if non-null) to hold the return value.
210          */

211         StringDataValue getNClobDataValue(String JavaDoc value);
212         StringDataValue getNClobDataValue(String JavaDoc value, StringDataValue previous)
213             throws StandardException;
214
215         /**
216          * Get a User-defined data value with the given value and type name.
217          * A null argument means get a SQL null value. The second form uses
218          * the previous value (if non-null) hold the return value.
219          *
220          */

221         UserDataValue getDataValue(Object JavaDoc value);
222         UserDataValue getDataValue(Object JavaDoc value,
223                                                                                 UserDataValue previous);
224
225         /**
226          * Get a RefDataValue with the given value. A null argument means get
227          * a SQL null value. The second form uses the previous value (if non-null)
228          * to hold the return value.
229          *
230          */

231         RefDataValue getDataValue(RowLocation value);
232         RefDataValue getDataValue(RowLocation value, RefDataValue previous);
233
234         /**
235          * Get a SQL int with the given value. The second form re-uses the
236          * previous value, if non-null, as the data holder to return.
237          *
238          */

239         NumberDataValue getDataValue(int value);
240         NumberDataValue getDataValue(int value, NumberDataValue previous)
241                                                         throws StandardException;
242
243         /**
244          * Get a SQL bigint with the given value. The second form re-uses the
245          * previous value, if non-null, as the data holder to return.
246          *
247          */

248         NumberDataValue getDataValue(long value);
249         NumberDataValue getDataValue(long value, NumberDataValue previous)
250                                                         throws StandardException;
251
252         /**
253          * Get a SQL real with the given value. The second form
254          * re-uses the previous value, if non-null, as the data holder to return.
255          *
256          * @exception StandardException Thrown on error
257          */

258         NumberDataValue getDataValue(float value) throws StandardException;
259         NumberDataValue getDataValue(float value, NumberDataValue previous)
260                                                         throws StandardException;
261
262         /**
263          * Get a SQL double precision with the given value. The second form
264          * re-uses the previous value, if non-null, as the data holder to return.
265          *
266          * @exception StandardException Thrown on error
267          */

268         NumberDataValue getDataValue(double value) throws StandardException;
269         NumberDataValue getDataValue(double value, NumberDataValue previous)
270                                                         throws StandardException;
271
272         /**
273          * Get a SQL SMALLINT with the given value. The second form re-uses the
274          * previous value, if non-null, as the data holder to return.
275          *
276          */

277         NumberDataValue getDataValue(short value);
278         NumberDataValue getDataValue(short value, NumberDataValue previous)
279                                                         throws StandardException;
280
281         /**
282          * Get a SQL TINYINT with the given value. The second form re-uses the
283          * previous value, if non-null, as the data holder to return.
284          *
285          */

286         NumberDataValue getDataValue(byte value);
287         NumberDataValue getDataValue(byte value, NumberDataValue previous)
288                                                         throws StandardException;
289
290         /**
291          * Get a SQL DECIMAL with the given value. The second form re-uses the
292          * previous value, if non-null, as the data holder to return.
293          *
294          * @exception StandardException Thrown on error
295          */

296         NumberDataValue getDecimalDataValue(Number JavaDoc value) throws StandardException;
297         NumberDataValue getDecimalDataValue(Number JavaDoc value, NumberDataValue previous)
298                                                         throws StandardException;
299
300
301         /**
302          * Get a SQL DECIMAL with the given value.
303          *
304          * @exception StandardException Thrown on error
305          */

306         NumberDataValue getDecimalDataValue(Long JavaDoc value, NumberDataValue previous)
307                                                         throws StandardException;
308
309
310         /**
311          * Get a SQL DECIMAL with the given value. The second form re-uses the
312          * previous value, if non-null, as the data holder to return.
313          *
314          * @exception StandardException Thrown on error
315          */

316         NumberDataValue getDecimalDataValue(String JavaDoc value) throws StandardException;
317         NumberDataValue getDecimalDataValue(String JavaDoc value,
318                                                                                         NumberDataValue previous)
319                                                         throws StandardException;
320
321         /**
322          * Get a SQL boolean with the given value. The second form re-uses the
323          * previous value, if non-null, as the data holder to return.
324          *
325          */

326         BooleanDataValue getDataValue(boolean value);
327         BooleanDataValue getDataValue(boolean value, BooleanDataValue previous)
328                                                         throws StandardException;
329
330         /**
331          * Get a SQL bit with the given value. The second form re-uses the
332          * previous value, if non-null, as the data holder to return.
333          *
334          * @exception StandardException Thrown on error
335          */

336         BitDataValue getBitDataValue(byte[] value) throws StandardException;
337         BitDataValue getBitDataValue(byte[] value, BitDataValue previous)
338                                                         throws StandardException;
339
340         /**
341          * Get a SQL bit with the given value. The second form re-uses the
342          * previous value, if non-null, as the data holder to return.
343          *
344          * @exception StandardException Thrown on error
345          */

346         BitDataValue getVarbitDataValue(byte[] value) throws StandardException;
347         BitDataValue getVarbitDataValue(byte[] value, BitDataValue previous)
348                                                         throws StandardException;
349
350         /**
351          * Get a SQL char with the given value. A null argument means get
352          * a SQL null value. The second form re-uses the previous value,
353          * if non-null, as the data holder to return.
354          *
355          */

356         StringDataValue getCharDataValue(String JavaDoc value);
357         StringDataValue getCharDataValue(String JavaDoc value, StringDataValue previous)
358                                                         throws StandardException;
359
360         /**
361          * Get a SQL national char with the given value. A null argument means get
362          * a SQL null value. The second form re-uses the previous value,
363          * if non-null, as the data holder to return.
364          */

365         StringDataValue getNationalCharDataValue(String JavaDoc value);
366         StringDataValue getNationalCharDataValue(String JavaDoc value, StringDataValue previous)
367                                                         throws StandardException;
368
369         /**
370          * Get a SQL date with the given value. A null argument means get
371          * a SQL null value. The second form re-uses the previous value,
372          * if non-null, as the data holder to return.
373          *
374          */

375         DateTimeDataValue getDataValue(Date JavaDoc value) throws StandardException;
376         DateTimeDataValue getDataValue(Date JavaDoc value, DateTimeDataValue previous)
377                                                         throws StandardException;
378
379         /**
380          * Get a SQL time with the given value. A null argument means get
381          * a SQL null value. The second form re-uses the previous value,
382          * if non-null, as the data holder to return.
383          *
384          */

385         DateTimeDataValue getDataValue(Time JavaDoc value) throws StandardException;
386         DateTimeDataValue getDataValue(Time JavaDoc value, DateTimeDataValue previous)
387                                                         throws StandardException;
388
389         /**
390          * Get a SQL timestamp with the given value. A null argument means get
391          * a SQL null value. The second form re-uses the previous value,
392          * if non-null, as the data holder to return.
393          *
394          */

395         DateTimeDataValue getDataValue(Timestamp JavaDoc value) throws StandardException;
396         DateTimeDataValue getDataValue(Timestamp JavaDoc value,
397                                                                                 DateTimeDataValue previous)
398                                                         throws StandardException;
399
400         /**
401          * Implement the timestamp SQL function: construct a SQL timestamp from a string, or timestamp.
402          *
403          * @param operand Must be a timestamp or a string convertible to a timestamp.
404          */

405         DateTimeDataValue getTimestamp( DataValueDescriptor operand) throws StandardException;
406
407         /**
408          * Construct a SQL timestamp from a date and time.
409          *
410          * @param date Must be convertible to a date.
411          * @param time Must be convertible to a time.
412          */

413         DateTimeDataValue getTimestamp( DataValueDescriptor date, DataValueDescriptor time) throws StandardException;
414
415         /**
416          * Implements the SQL date function
417          *
418          * @param operand A date, timestamp, string or integer.
419          *
420          * @return the corresponding date value
421          *
422          * @exception StandardException if the syntax is invalid or the date is out of range.
423          */

424         public DateTimeDataValue getDate( DataValueDescriptor operand) throws StandardException;
425
426         /**
427          * @param dateStr A date in one of the DB2 standard date formats or the local format.
428          * @param isJdbcEscape If true then the timestamp must be in the JDBC timestamp escape format, otherwise it must
429          * be in the DB2 timestamp format.
430          * @return A DateTimeDataValue
431          *
432          * @exception StandardException if the syntax is invalid or the date is out of range.
433          */

434         public DateTimeDataValue getDateValue( String JavaDoc dateStr, boolean isJdbcEscape) throws StandardException;
435
436         /**
437          * @param timeStr A date in one of the DB2 standard time formats or the local format.
438          * @param isJdbcEscape If true then the timestamp must be in the JDBC time escape format, otherwise it must
439          * be in the DB2 time format.
440          * @return A DateTimeDataValue
441          *
442          * @exception StandardException if the syntax is invalid or the time is out of range.
443          */

444         public DateTimeDataValue getTimeValue( String JavaDoc timeStr, boolean isJdbcEscape) throws StandardException;
445
446         /**
447          * @param timestampStr A time in string format.
448          * @param isJdbcEscape If true then the time must be in the JDBC time escape format, otherwise it must
449          * be in the DB2 time format.
450          * @return An internal timestamp
451          *
452          * @exception StandardException if the syntax is invalid or the timestamp is out of range.
453          */

454         public DateTimeDataValue getTimestampValue( String JavaDoc timestampStr, boolean isJdbcEscape) throws StandardException;
455
456         /**
457          * Get a null XML value. The second form re-uses the previous value,
458          * if non-null, as the data holder to return.
459          */

460         XMLDataValue getXMLDataValue();
461         XMLDataValue getXMLDataValue(XMLDataValue previous)
462             throws StandardException;
463
464         /**
465          * Get a SQL int with a SQL null value. If the supplied value
466          * is null then get a new value, otherwise set it to null and return
467          * that value.
468          *
469          */

470         NumberDataValue getNullInteger(NumberDataValue dataValue);
471
472         /**
473          * Get a SQL smallint with a SQL null value. If the supplied value
474          * is null then get a new value, otherwise set it to null and return
475          * that value.
476          */

477         NumberDataValue getNullShort(NumberDataValue dataValue);
478
479         /**
480          * Get a SQL tinyint with a SQL null value. If the supplied value
481          * is null then get a new value, otherwise set it to null and return
482          * that value.
483          *
484          */

485         NumberDataValue getNullByte(NumberDataValue dataValue);
486
487         /**
488          * Get a SQL bigint with a SQL null value. If the supplied value
489          * is null then get a new value, otherwise set it to null and return
490          * that value.
491          *
492          */

493         NumberDataValue getNullLong(NumberDataValue dataValue);
494
495         /**
496          * Get a SQL float with a SQL null value. If the supplied value
497          * is null then get a new value, otherwise set it to null and return
498          * that value.
499          *
500          */

501         NumberDataValue getNullFloat(NumberDataValue dataValue);
502
503         /**
504          * Get a SQL double with a SQL null value. If the supplied value
505          * is null then get a new value, otherwise set it to null and return
506          * that value.
507          *
508          */

509         NumberDataValue getNullDouble(NumberDataValue dataValue);
510
511         /**
512          * Get a SQL Decimal/Numeric with a SQL null value. If the supplied value
513          * is null then get a new value, otherwise set it to null and return
514          * that value.
515          *
516          */

517         NumberDataValue getNullDecimal(NumberDataValue dataValue);
518
519         /**
520          * Get a SQL boolean with a SQL null value. If the supplied value
521          * is null then get a new value, otherwise set it to null and return
522          * that value.
523          */

524         BooleanDataValue getNullBoolean(BooleanDataValue dataValue);
525
526         /**
527          * Get a SQL Bit with a SQL null value. If the supplied value
528          * is null then get a new value, otherwise set it to null and return
529          * that value.
530          *
531          * @exception StandardException Thrown on error
532          */

533         BitDataValue getNullBit(BitDataValue dataValue) throws StandardException;
534
535         /**
536          * Get a SQL Bit Varying with a SQL null value. If the supplied value
537          * is null then get a new value, otherwise set it to null and return
538          * that value.
539          *
540          * @exception StandardException Thrown on error
541          */

542         BitDataValue getNullVarbit(BitDataValue dataValue) throws StandardException;
543
544         // --- LONGVARBIT
545
/**
546          * Get a SQL Long Bit Varying with a SQL null value. If the supplied
547          * value is null then get a new value, otherwise set it to null
548          * and return that value.
549          *
550          * @exception StandardException Thrown on error
551          */

552         BitDataValue getNullLongVarbit(
553                                                                                                         BitDataValue dataValue)
554                                                                 throws StandardException;
555         // --- BLOB
556
/**
557          * Get a SQL Blob with a SQL null value. If the supplied
558          * value is null then get a new value, otherwise set it to null
559          * and return that value.
560          *
561          * @exception StandardException Thrown on error
562          */

563         BitDataValue getNullBlob(BitDataValue dataValue)
564                 throws StandardException;
565         
566     // ------ CHAR
567
/**
568          * Get a SQL char with a SQL null value. If the supplied value
569          * is null then get a new value, otherwise set it to null and return
570          * that value.
571          */

572         StringDataValue getNullChar(StringDataValue dataValue);
573
574         /**
575          * Get a SQL varchar with a SQL null value. If the supplied value
576          * is null then get a new value, otherwise set it to null and return
577          * that value.
578          *
579          */

580         StringDataValue getNullVarchar(StringDataValue dataValue);
581
582         /**
583          * Get a SQL long varchar with a SQL null value. If the supplied value
584          * is null then get a new value, otherwise set it to null and return
585          * that value.
586          *
587          */

588         StringDataValue getNullLongvarchar(StringDataValue dataValue);
589
590         /**
591          * Get a SQL long varchar with a SQL null value. If the supplied value
592          * is null then get a new value, otherwise set it to null and return
593          * that value.
594          *
595          */

596         StringDataValue getNullClob(StringDataValue dataValue);
597
598         /**
599          * Get a SQL national char with a SQL null value. If the supplied value
600          * is null then get a new value, otherwise set it to null and return
601          * that value.
602          */

603         StringDataValue getNullNationalChar(StringDataValue dataValue);
604
605         /**
606          * Get a SQL national varchar with a SQL null value. If the supplied value
607          * is null then get a new value, otherwise set it to null and return
608          * that value.
609          *
610          */

611         StringDataValue getNullNationalVarchar(StringDataValue dataValue);
612
613         /**
614          * Get a SQL national long varchar with a SQL null value. If the supplied value
615          * is null then get a new value, otherwise set it to null and return
616          * that value.
617          *
618          */

619         StringDataValue getNullNationalLongvarchar(StringDataValue dataValue);
620
621         /**
622          * Get a SQL NCLOB with a SQL null value. If the supplied value
623          * is null then get a new value, otherwise set it to null and return
624          * that value.
625          *
626          */

627         StringDataValue getNullNClob(StringDataValue dataValue);
628
629         /**
630          * Get a User-defined data value with a SQL null value. If the supplied value
631          * is null then get a new value, otherwise set it to null and return
632          * that value.
633          *
634          */

635         UserDataValue getNullObject(UserDataValue dataValue);
636
637         /**
638          * Get a RefDataValue with a SQL null value. If the supplied value
639          * is null then get a new value, otherwise set it to null and return
640          * that value.
641          *
642          */

643         RefDataValue getNullRef(RefDataValue dataValue);
644
645         /**
646          * Get a SQL date with a SQL null value. If the supplied value
647          * is null then get a new value, otherwise set it to null and return
648          * that value.
649          *
650          */

651         DateTimeDataValue getNullDate(DateTimeDataValue dataValue);
652
653         /**
654          * Get a SQL time with a SQL null value. If the supplied value
655          * is null then get a new value, otherwise set it to null and return
656          * that value.
657          *
658          */

659         DateTimeDataValue getNullTime(DateTimeDataValue dataValue);
660
661         /**
662          * Get a SQL timestamp with a SQL null value. If the supplied value
663          * is null then get a new value, otherwise set it to null and return
664          * that value.
665          */

666         DateTimeDataValue getNullTimestamp(DateTimeDataValue dataValue);
667
668         /**
669          * Get an XML with a SQL null value. If the supplied value is
670          * null then get a new value, otherwise set it to null and return
671          * that value.
672          */

673         XMLDataValue getNullXML(XMLDataValue dataValue);
674 }
675
Popular Tags