KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > dods > builder > generator > dataobject > GenericDO


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: GenericDO.java,v 1.4 2005/03/14 12:23:25 predrag Exp $
22  */

23
24 /*
25  * GenericDO.java
26  *
27  * This class is the parent of all the generated DO classes produced
28  * by the SourceGenerator_DO. The template file
29  * SourceGenerator_DO/templates/writeFileHeader.template
30  * contains the line
31  * class <CLASS_NAME> <EXTENDS> {
32  * and the EXTENDS tag is replaced by either
33  * extends GenericDO
34  * or, if the DataObject is derived from another DataOBject, the replacement is
35  * extends ThatOtherDO
36  */

37 package com.lutris.dods.builder.generator.dataobject;
38
39 import java.io.ByteArrayInputStream JavaDoc;
40 import java.io.IOException JavaDoc;
41 import java.math.BigDecimal JavaDoc;
42 import java.sql.PreparedStatement JavaDoc;
43 import java.sql.ResultSet JavaDoc;
44 import java.sql.SQLException JavaDoc;
45 import java.sql.Types JavaDoc;
46 import com.lutris.logging.Logger;
47 import org.enhydra.dods.DODS;
48 import org.enhydra.dods.cache.Condition;
49 import com.lutris.appserver.server.sql.CloneableDO;
50 import com.lutris.appserver.server.sql.CoreDO;
51 import com.lutris.appserver.server.sql.DBConnection;
52 import com.lutris.appserver.server.sql.DBRowUpdateException;
53 import com.lutris.appserver.server.sql.DatabaseManagerException;
54 import com.lutris.appserver.server.sql.ObjectId;
55 import com.lutris.appserver.server.sql.ObjectIdException;
56 import com.lutris.appserver.server.sql.standard.DriverSpecificConstants;
57 import com.lutris.appserver.server.sql.standard.StandardLogicalDatabase;
58 import com.lutris.dods.builder.generator.query.DataObjectException;
59 import com.lutris.dods.builder.generator.query.QueryException;
60 import com.lutris.dods.builder.generator.query.RefAssertionException;
61
62 abstract public class GenericDO extends CloneableDO {
63     static public void printMsg(int level, String JavaDoc s) {
64         try {
65             DODS.getLogChannel().write(level, s);
66         } catch (Exception JavaDoc e) {
67             System.out.println(level + " " + s);
68         }
69     }
70     // True if this object has been changed with respect to
71
// its persistent representation in the database.
72
protected boolean dirty = false;
73     // private boolean updateInProgress = false;
74
private boolean notUsingOId = false;
75
76     private static Boolean JavaDoc setNullAsVarchar = null;
77     
78     private static Boolean JavaDoc setBytesAsLongvarbinary = null;
79     
80     private static Boolean JavaDoc setBytesAsBinaryStream = null;
81     
82     private static Boolean JavaDoc setBooleanAsString = null;
83     
84     
85     
86     private static boolean isSetNullAsVarchar() {
87         if (setNullAsVarchar==null) {
88             setNullAsVarchar = new Boolean JavaDoc(DriverSpecificConstants.DEFAULT_SET_NULL_AS_VARCHAR);
89             try {
90                 String JavaDoc setNullAsVarcharStr = ((StandardLogicalDatabase)DODS.getDatabaseManager()
91                                                 .findLogicalDatabase(DODS.getDatabaseManager().getDefaultDB()))
92                                                 .getDriverProperty(DriverSpecificConstants.PARAMNAME_SET_NULL_AS_VARCHAR);
93                 if(setNullAsVarcharStr!=null){
94                     if(setNullAsVarcharStr.equalsIgnoreCase("true")){
95                         setNullAsVarchar=new Boolean JavaDoc(true);
96                     }else if(setNullAsVarcharStr.equalsIgnoreCase("false")){
97                         setNullAsVarchar=new Boolean JavaDoc(false);
98                     }else{
99                         DODS.getLogChannel().write(Logger.DEBUG,"Illegal value for SetNullAsVarchar parameter. Using default");
100                     }
101                 }
102             } catch (DatabaseManagerException e){
103                 DODS.getLogChannel().write(Logger.DEBUG," Unable to read configuration for SetNullAsVarchar. Using default. ");
104             }
105         }
106         return setNullAsVarchar.booleanValue();
107     }
108    
109     private static boolean isSetBooleanAsString() {
110         if (setBooleanAsString == null) {
111             setBooleanAsString = new Boolean JavaDoc(DriverSpecificConstants.DEFAULT_SET_BOOLEAN_AS_STRING);
112             try {
113                 String JavaDoc setBooleanAsStringStr = ((StandardLogicalDatabase)DODS.getDatabaseManager()
114                                                 .findLogicalDatabase(DODS.getDatabaseManager().getDefaultDB()))
115                                                 .getDriverProperty(DriverSpecificConstants.PARAMNAME_SET_BOOLEAN_AS_STRING);
116                 if(setBooleanAsStringStr!=null){
117                     if(setBooleanAsStringStr.equalsIgnoreCase("true")){
118                         setBooleanAsString=new Boolean JavaDoc(true);
119                     }else if(setBooleanAsStringStr.equalsIgnoreCase("false")){
120                         setBooleanAsString=new Boolean JavaDoc(false);
121                     }else{
122                         DODS.getLogChannel().write(Logger.DEBUG,"Illegal value for SetBooleanAsString parameter. Using default ('true').");
123                     }
124                 }
125             } catch (DatabaseManagerException e){
126                 DODS.getLogChannel().write(Logger.DEBUG," Unable to read configuration for SetBooleanAsString. Using default ('true'). ");
127             }
128         }
129         return setBooleanAsString.booleanValue();
130     }
131     
132     
133     private static boolean isSetBytesAsBinaryStream() {
134         if (setBytesAsBinaryStream == null) {
135             setBytesAsBinaryStream = new Boolean JavaDoc(DriverSpecificConstants.DEFAULT_SET_BYTES_AS_BINARY_STREAM);
136             try {
137                 String JavaDoc setBytesAsBinaryStreamStr = ((StandardLogicalDatabase)DODS.getDatabaseManager()
138                                                 .findLogicalDatabase(DODS.getDatabaseManager().getDefaultDB()))
139                                                 .getDriverProperty(DriverSpecificConstants.PARAMNAME_SET_BYTES_AS_BINARY_STREAM);
140                 if(setBytesAsBinaryStreamStr!=null){
141                     if(setBytesAsBinaryStreamStr.equalsIgnoreCase("true")){
142                         setBytesAsBinaryStream=new Boolean JavaDoc(true);
143                     }else if(setBytesAsBinaryStreamStr.equalsIgnoreCase("false")){
144                         setBytesAsBinaryStream=new Boolean JavaDoc(false);
145                     }else{
146                         DODS.getLogChannel().write(Logger.DEBUG,"Illegal value for SetBytesAsBinaryStream parameter. Using default");
147                     }
148                 }
149             } catch (DatabaseManagerException e){
150                 DODS.getLogChannel().write(Logger.DEBUG," Unable to read configuration for SetBytesAsBinaryStream. Using default. ");
151             }
152         }
153         return setBytesAsBinaryStream.booleanValue();
154     }
155     
156     private static boolean isSetBytesAsLongvarbinary() {
157         if (setBytesAsLongvarbinary == null) {
158             setBytesAsLongvarbinary = new Boolean JavaDoc(DriverSpecificConstants.DEFAULT_SET_BYTES_AS_LONGVARBINARY);
159             try {
160                 String JavaDoc setBytesAsLongvarbinaryStr = ((StandardLogicalDatabase)DODS.getDatabaseManager()
161                                                 .findLogicalDatabase(DODS.getDatabaseManager().getDefaultDB()))
162                                                 .getDriverProperty(DriverSpecificConstants.PARAMNAME_SET_BYTES_AS_LONGVARBINARY);
163                 if(setBytesAsLongvarbinaryStr!=null){
164                     if(setBytesAsLongvarbinaryStr.equalsIgnoreCase("true")){
165                         setBytesAsLongvarbinary=new Boolean JavaDoc(true);
166                     }else if(setBytesAsLongvarbinaryStr.equalsIgnoreCase("false")){
167                         setBytesAsLongvarbinary=new Boolean JavaDoc(false);
168                     }else{
169                         DODS.getLogChannel().write(Logger.DEBUG,"Illegal value for SetBytesAsLongvarchar parameter. Using default");
170                     }
171                 }
172             } catch (DatabaseManagerException e){
173                 DODS.getLogChannel().write(Logger.DEBUG," Unable to read configuration for SetBytesAsLongvarchar. Using default. ");
174             }
175         }
176         return setBytesAsLongvarbinary.booleanValue();
177     }
178
179
180     
181     /**
182      * Public constructor.
183      */

184     public GenericDO()
185           throws ObjectIdException, DatabaseManagerException {
186         super();
187         set_OId(DODS.getDatabaseManager().allocateObjectId());
188         markNewValue();
189     }
190
191     /**
192      * Public constructor.
193      */

194     public GenericDO(String JavaDoc dbName)
195           throws ObjectIdException, DatabaseManagerException {
196         super();
197         set_OId(DODS.getDatabaseManager().allocateObjectId(dbName));
198         markNewValue();
199     }
200
201     /**
202      * Public constructor.
203      */

204     public GenericDO(boolean notUsingOId)
205           throws ObjectIdException, DatabaseManagerException {
206         super();
207         this.notUsingOId = notUsingOId;
208         if (!notUsingOId) {
209             set_OId(DODS.getDatabaseManager().allocateObjectId());
210         }
211         markNewValue();
212     }
213
214     /**
215      * Public constructor.
216      */

217     public GenericDO(String JavaDoc dbName, boolean notUsingOId)
218           throws ObjectIdException, DatabaseManagerException {
219         super();
220         this.notUsingOId = notUsingOId;
221         if (!notUsingOId) {
222             set_OId(DODS.getDatabaseManager().allocateObjectId(dbName));
223         }
224         markNewValue();
225     }
226
227     /**
228      * Public constructor.
229      */

230     public GenericDO(ObjectId id)
231           throws ObjectIdException, DatabaseManagerException {
232         super();
233         set_OId(id);
234     }
235
236     /**
237      * Public constructor.
238      */

239     public GenericDO(String JavaDoc dbName, ObjectId id)
240           throws ObjectIdException, DatabaseManagerException {
241         super();
242         set_OId(id);
243     }
244
245     /**
246      * Public constructor.
247      * @param rs a result set.
248      * @exception SQLException if an error occurs while instantiating this
249      * object from the result set.
250      * @exception ObjectIdException if the object id for this object is
251      * invalid.
252      * @exception DatabaseManagerException
253      * If a nonexistent default logical database has been set.
254      */

255     public GenericDO(ResultSet JavaDoc rs)
256           throws SQLException JavaDoc, ObjectIdException, DatabaseManagerException {
257         super(rs);
258         //set_NewVersion(get_Version());
259
}
260
261     /**
262      * Public constructor.
263      * @param rs a result set.
264      * @exception SQLException if an error occurs while instantiating this
265      * object from the result set.
266      * @exception ObjectIdException if the object id for this object is
267      * invalid.
268      * @exception DatabaseManagerException
269      * If a nonexistent logical database name is supplied.
270      */

271     public GenericDO(String JavaDoc dbName, ResultSet JavaDoc rs)
272           throws SQLException JavaDoc, ObjectIdException, DatabaseManagerException {
273         super(rs);
274         //set_NewVersion(get_Version());
275
}
276
277     /**
278      * Creates a clone of the object, but ensures that
279      * a new and unique object id is created for the object
280      * and that the version number is set to zero.
281      * @exception DatabaseManagerException if an error occurs while
282      * allocation a new object id from the default logical database.
283      * @exception ObjectIdException if a new object id could not be
284      * allocated.
285      */

286     public synchronized Object JavaDoc cloneUnique()
287           throws DatabaseManagerException, ObjectIdException {
288         GenericDO dataObj = (GenericDO) super.cloneUnique();
289
290         // It's important to do the following. Otherwise two
291
// commits in a row on a cloned object will fail.
292
//dataObj.set_NewVersion(0);
293
dataObj.set_Version(0);
294         dataObj.markNewValue(); // make sure it gets commited.
295
return dataObj;
296     }
297
298     /**
299      * makeIdentical()
300      *
301      * Used by subclasses to assign any data members to this data object.
302      * Does not duplicate data. Just assigns references.
303      *
304      * @param obj The original DO.
305      *
306      */

307     protected void makeIdentical(GenericDO obj) {}
308
309     /**
310      * Updates the contents of this object in the database
311      * but only if the datab object is dirty. This requires
312      * that all set methods in the data objects keep track
313      * if a value has changed.
314      *
315      * @param conn the database connection.
316      * @exception java.sql.SQLException If a database access error occurs.
317      * @exception DBRowUpdateException If a version error occurs.
318      */

319     public synchronized void executeUpdate(DBConnection conn)
320         throws SQLException JavaDoc, DBRowUpdateException {
321         if (dirty/* && !updateInProgress*/) {
322             if (!notUsingOId) {
323                 printMsg(Logger.DEBUG,
324                         getClass().getName() + ".executeUpdate:" + persistent
325                         + ": " + getClass().getName() + ": "
326                         + get_OId().toString() + ": " + get_Version());
327             }
328             super.executeUpdate(conn);
329         }
330     }
331
332     /**
333      * Updates the contents of this object in the database
334      * but only if the datab object is dirty. This requires
335      * that all set methods in the data objects keep track
336      * if a value has changed.
337      *
338      * @param conn the database connection.
339      * @exception java.sql.SQLException If a database access error occurs.
340      * @exception DBRowUpdateException If a version error occurs.
341      */

342     public synchronized void executeInsert(DBConnection conn)
343         throws SQLException JavaDoc, DBRowUpdateException {
344
345         /* if (!updateInProgress) {*/
346         if (!notUsingOId) {
347             printMsg(Logger.DEBUG,
348                     getClass().getName() + ".executeInsert():" + persistent
349                     + ": " + get_OId().toString() + ": " + get_Version() + ": "
350                     + get_NewVersion());
351         }
352         super.executeInsert(conn);
353
354         /* updateInProgress = !getAutoSave();
355          } */

356     }
357
358     /**
359      * Deletes this object from the database.
360      *
361      * @param conn Database connection.
362      * @exception java.sql.SQLException If a database access error
363      * occurs.
364      */

365     public void executeDelete(DBConnection conn)
366         throws SQLException JavaDoc {
367         //PreparedStatement stmt = getDeleteStatement(conn); -dp
368

369         if (isPersistent()) {
370             if (!notUsingOId) {
371                 printMsg(Logger.DEBUG,
372                         getClass().getName() + ".executeDelete(): " + persistent
373                         + ": " + get_OId().toString() + ": " + get_Version());
374             }
375             super.executeDelete(conn);
376         }
377     }
378
379     /**
380      * If transaction succeeded marks this object as clean.
381      * @param success true if the transaction succeeded
382      * and this object was successfully inserted into the database.
383      */

384     public void finalizeInsert(boolean success) {
385         if (!notUsingOId) {
386             printMsg(Logger.DEBUG,
387                     getClass().getName() + ".finalizeInsert(" + success + ") "
388                     + "oid=" + get_OId().toString() + " " + "version="
389                     + get_Version());
390         }
391         boolean p = persistent;
392
393         super.finalizeInsert(success);
394         if (p == true) {
395             persistent = true; // fix bug in CoreDO.
396
}
397         if (success) {
398             dirty = false;
399         }
400     }
401
402     /**
403      * If transaction succeeded marks this object as clean.
404      * @param success true if the transaction succeeded
405      * and this object was successfully updated in the database.
406      */

407     public void finalizeUpdate(boolean success) {
408         if (!notUsingOId) {
409             printMsg(Logger.DEBUG,
410                     getClass().getName() + ".finalizeUpdate:" + success + ": "
411                     + get_OId().toString() + ": " + get_Version());
412         }
413         super.finalizeUpdate(success);
414         if (success) {
415             dirty = false;
416         }
417         // updateInProgress = false;
418
}
419
420     /**
421      * Return the name of the primary key column.
422      * FIX to get name from conf file (or via CoreDO?)
423      *
424      * @return the name of the primary key column.
425      * @see CoreDO
426      * author Jay Gunter
427      */

428     static protected String JavaDoc get_primaryKeyName() {
429         return CoreDO.get_OIdColumnName();
430     }
431
432     /**
433      * Return the name of the primary key column.
434      * FIX to get name from conf file (or via CoreDO?)
435      *
436      * @return the name of the primary key column.
437      * @see CoreDO
438      * author Jay Gunter
439      * @deprecated use get_primaryKeyName()
440      */

441     static protected String JavaDoc getPrimaryKeyName() {
442         return get_primaryKeyName();
443     }
444
445     /**
446      * @deprecated Use set_OId()
447      * @param oId this object's identifier.
448      */

449     protected void setOId(ObjectId oId) {
450         set_OId(oId);
451     }
452
453     /**
454      * Sets this object's identifier.
455      * @param oId this object's identifier.
456      */

457     protected void set_OId(ObjectId oId) {
458         if (!notUsingOId) {
459             super.set_OId(markNewValue(get_OId(), oId));
460         }
461     }
462
463     /**
464      * <CODE>isDirty()</CODE> returns true if this object has been
465      * modified (needs to be updated to the database).<p>
466      */

467     public boolean isDirty() {
468         return dirty;
469     }
470
471     /**
472      * <CODE>markClean()</CODE> with no arguments is used to indicate that
473      * this object is marked as "clean"
474      * (it does not need to be updated to the database).<p>
475      *
476      * This method is protected since only derived Data Objects (DO's)
477      * "<CODE>set</CODE>" methods will be calling it.<P>
478      */

479     protected void markClean() {
480         dirty = false;
481     }
482
483     /**
484      * <CODE>markNewValue()</CODE> with no arguments is used to indicate that
485      * this object is marked as "dirty" (in need of an update to the database).
486      * There is no way to mark this object as "clean";<BR> only the
487      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
488      * methods can make that so.<P>
489      *
490      * This method is protected since only derived Data Objects (DO's)
491      * "<CODE>set</CODE>" methods will be calling it.<P>
492      */

493     protected void markNewValue() {
494         dirty = true;
495     }
496
497     /**
498      * If the current data member value differs from the new value,
499      * this object is marked as "dirty" (in need of an update to the database).
500      * There is no way to mark this object as "clean";<BR> only the
501      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
502      * methods can make that so.<P>
503      *
504      * This method is protected since only derived Data Objects (DO's)
505      * "<CODE>set</CODE>" methods will be calling it.<P>
506      *
507      * This method returns the new value as a convenience to the calling
508      * "<CODE>set</CODE>" method. The usage is:
509      * <CODE>this.field = markNewValue( this.field, new_field_value,
510      * max_length, nullOK )</CODE>
511      *
512      * If <CODE>nullOK</CODE> is false and <CODE>new_field_value</CODE>
513      * is null, <CODE>this.field</CODE> is set to <CODE>""</CODE>.
514      *
515      * @param current_string The current value of the String data member.
516      * @param new_string The new value of the String data member.
517      * @param max_length The maximum allowed length of the String value.
518      * If the new_string is longer than max_length, new_string is truncated.
519      * If max_length is less than 1, no maximum is imposed.
520      * @return new_string if it is not null, otherwise "".
521      */

522     protected String JavaDoc markNewValue(String JavaDoc current_string, String JavaDoc new_string,
523             int max_length,
524             boolean nullOK) {
525
526         /*
527          if ( new_string == null )
528          if ( ! nullOK )
529          return current_string;
530          else
531          new_string = "";
532          if ((max_length > 00) && (new_string.length() > max_length)) {
533          new_string = new_string.substring( 0, max_length );
534          }
535          if (!new_string.equals(current_string)) {
536          dirty = true;
537          }
538          return new_string;
539          */

540         // FIX delete stuff above after testing line below
541
return markNewValue(current_string, new_string, 0, max_length, nullOK);
542     }
543
544     /**
545      * If the current data member value differs from the new value,
546      * this object is marked as "dirty" (in need of an update to the database).
547      * There is no way to mark this object as "clean";<BR> only the
548      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
549      * methods can make that so.<P>
550      *
551      * This method is protected since only derived Data Objects (DO's)
552      * "<CODE>set</CODE>" methods will be calling it.<P>
553      *
554      * This method returns the new value as a convenience to the calling
555      * "<CODE>set</CODE>" method. The usage is:
556      * <CODE>this.field = markNewValue( this.field, new_field_value,
557      * min_length, max_length, nullOK )</CODE>
558      *
559      * If <CODE>min_length > 0</CODE> and
560      * <CODE>nullOK</CODE> is false and
561      * <CODE>new_field_value</CODE> is null,
562      * <CODE>this.field</CODE> is returned
563      * (the <CODE>new_field_value</CODE> is ignored.)
564      *
565      * @param current_string The current value of the String data member.
566      * @param new_string The new value of the String data member.
567      * @param min_length The minimum allowed length of the String value.
568      * If the new_string is shorter than min_length, new_string is ignored.
569      * If min_length is less than 0, no minimum is imposed.
570      * @param max_length The maximum allowed length of the String value.
571      * If the new_string is longer than max_length, new_string is truncated.
572      * If max_length is less than 1, no maximum is imposed.
573      * @return new_string if it is not null, otherwise "".
574      */

575     protected String JavaDoc markNewValue(String JavaDoc current_string, String JavaDoc new_string,
576             int min_length, int max_length,
577             boolean nullOK) {
578         colChanged = false;
579         if (!nullOK && current_string == null) { // fix bogus current value
580
current_string = "";
581         }
582         if (new_string == null) {
583             if (!nullOK) { // reject new value
584
return current_string;
585             } else {
586                 if (current_string != null) {
587                     colChanged = dirty = true;
588                 }
589                 return null;
590             }
591         }
592         if (min_length >= 0 && new_string.length() < min_length) {
593             new_string = current_string;
594         } // reject new_string
595
if (max_length > 00 && new_string.length() > max_length) {
596             new_string = new_string.substring(0, max_length);
597         }
598         if (!new_string.equals(current_string)) {
599             colChanged = dirty = true;
600         }
601         return new_string;
602     }
603     protected boolean colChanged = false;
604     /**
605      * If the current data member value differs from the new value,
606      * this object is marked as "dirty" (in need of an update to the database).
607      * There is no way to mark this object as "clean";<BR> only the
608      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
609      * methods can make that so.<P>
610      *
611      * This method is protected since only derived Data Objects (DO's)
612      * "<CODE>set</CODE>" methods will be calling it.<P>
613      *
614      * This method returns the new value as a convenience to the calling
615      * "<CODE>set</CODE>" method. The usage is:
616      * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
617      *
618      * @param current_OId The current value of the ObjectId data member.
619      * @param new_OId The new value of the ObjectId data member.
620      * @return new_OId
621      */

622     protected ObjectId markNewValue(ObjectId current_OId, ObjectId new_OId) {
623         colChanged = false;
624         if (current_OId == null) {
625             if (new_OId != null) {
626                 colChanged = dirty = true;
627             }
628         } else {
629             if (new_OId == null) {
630                 colChanged = dirty = true;
631             } else if (!current_OId.toString().equals(new_OId.toString())) {
632                 colChanged = dirty = true;
633             }
634         }
635         return new_OId;
636     }
637
638     /**
639      * If the current data member value differs from the new value,
640      * this object is marked as "dirty" (in need of an update to the database).
641      * There is no way to mark this object as "clean";<BR> only the
642      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
643      * methods can make that so.<P>
644      *
645      * This method is protected since only derived Data Objects (DO's)
646      * "<CODE>set</CODE>" methods will be calling it.<P>
647      *
648      * This method returns the new value as a convenience to the calling
649      * "<CODE>set</CODE>" method. The usage is:
650      * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
651      *
652      * @param current_date The current value of the Date data member.
653      * @param new_date The new value of the Date data member.
654      * @return new_date
655      */

656     protected java.util.Date JavaDoc markNewValue(
657             java.util.Date JavaDoc current_date, java.util.Date JavaDoc new_date) {
658         colChanged = false;
659         if (current_date == null) {
660             if (new_date != null) {
661                 colChanged = dirty = true;
662             }
663         } else {
664             if (new_date == null) {
665                 colChanged = dirty = true;
666             } else if (!current_date.toString().equals(new_date.toString())) {
667                 colChanged = dirty = true;
668             }
669         }
670         return new_date;
671     }
672
673     /**
674      * If the current data member value differs from the new value,
675      * this object is marked as "dirty" (in need of an update to the database).
676      * There is no way to mark this object as "clean";<BR> only the
677      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
678      * methods can make that so.<P>
679      *
680      * This method is protected since only derived Data Objects (DO's)
681      * "<CODE>set</CODE>" methods will be calling it.<P>
682      *
683      * This method returns the new value as a convenience to the calling
684      * "<CODE>set</CODE>" method. The usage is:
685      * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
686      *
687      * @param current_bd The current value of the BigDecimal data member.
688      * @param new_bd The new value of the BigDecimal data member.
689      * @return new_bd
690      */

691     protected BigDecimal JavaDoc markNewValue(BigDecimal JavaDoc current_bd, BigDecimal JavaDoc new_bd) {
692         colChanged = false;
693         if (current_bd == null) {
694             if (new_bd != null) {
695                 colChanged = dirty = true;
696             }
697         } else {
698             if (new_bd == null) {
699                 colChanged = dirty = true;
700             } else if (!current_bd.equals(new_bd)) {
701                 colChanged = dirty = true;
702             }
703         }
704         return new_bd;
705     }
706
707     /**
708      * If the current data member value differs from the new value,
709      * this object is marked as "dirty" (in need of an update to the database).
710      * There is no way to mark this object as "clean";<BR> only the
711      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
712      * methods can make that so.<P>
713      *
714      * This method is protected since only derived Data Objects (DO's)
715      * "<CODE>set</CODE>" methods will be calling it.<P>
716      *
717      * This method returns the new value as a convenience to the calling
718      * "<CODE>set</CODE>" method. The usage is:
719      * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
720      *
721      * @param current_val The current value of the byte array data member.
722      * @param new_val The new value of the byte array data member.
723      * @return new_val
724      */

725     protected byte[] markNewValue(byte[] current_val, byte[] new_val) {
726         colChanged = false;
727         if (current_val == null) {
728             if (new_val != null) {
729                 colChanged = dirty = true;
730             }
731         } else {
732             if (new_val == null) {
733                 colChanged = dirty = true;
734             } else {
735                 if (current_val.length != new_val.length) {// FIX what to do?
736
colChanged = dirty = true;
737                 } else {
738                     for (int i = 0; i < current_val.length; i++) {
739                         if (current_val[i] != new_val[i]) {
740                             colChanged = dirty = true;
741                             break;
742                         }
743                     }
744                 }
745             }
746         }
747         return new_val;
748     }
749
750     /**
751      * If the current data member value differs from the new value,
752      * this object is marked as "dirty" (in need of an update to the database).
753      * There is no way to mark this object as "clean";<BR> only the
754      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
755      * methods can make that so.<P>
756      *
757      * This method is protected since only derived Data Objects (DO's)
758      * "<CODE>set</CODE>" methods will be calling it.<P>
759      *
760      * This method returns the new value as a convenience to the calling
761      * "<CODE>set</CODE>" method. The usage is:
762      * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
763      *
764      * @param current_val The current value of the java.sql.Date data member.
765      * @param new_val The new value of the java.sql.Date data member.
766      * @return new_val
767      */

768     protected java.sql.Date JavaDoc markNewValue(
769             java.sql.Date JavaDoc current_val, java.sql.Date JavaDoc new_val) {
770         colChanged = false;
771         if (current_val == null) {
772             if (new_val != null) {
773                 colChanged = dirty = true;
774             }
775         } else {
776             if (new_val == null) {
777                 colChanged = dirty = true;
778             } else if (!current_val.equals(new_val)) {
779                 colChanged = dirty = true;
780             }
781         }
782         return new_val;
783     }
784
785     /**
786      * If the current data member value differs from the new value,
787      * this object is marked as "dirty" (in need of an update to the database).
788      * There is no way to mark this object as "clean";<BR> only the
789      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
790      * methods can make that so.<P>
791      *
792      * This method is protected since only derived Data Objects (DO's)
793      * "<CODE>set</CODE>" methods will be calling it.<P>
794      *
795      * This method returns the new value as a convenience to the calling
796      * "<CODE>set</CODE>" method. The usage is:
797      * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
798      *
799      * @param current_val The current value of the java.sql.Time data member.
800      * @param new_val The new value of the java.sql.Time data member.
801      * @return new_val
802      */

803     protected java.sql.Time JavaDoc markNewValue(
804             java.sql.Time JavaDoc current_val, java.sql.Time JavaDoc new_val) {
805         colChanged = false;
806         if (current_val == null) {
807             if (new_val != null) {
808                 colChanged = dirty = true;
809             }
810         } else {
811             if (new_val == null) {
812                 colChanged = dirty = true;
813             } else if (!current_val.equals(new_val)) {
814                 colChanged = dirty = true;
815             }
816         }
817         return new_val;
818     }
819
820     /**
821      * If the current data member value differs from the new value,
822      * this object is marked as "dirty" (in need of an update to the database).
823      * There is no way to mark this object as "clean";<BR> only the
824      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
825      * methods can make that so.<P>
826      *
827      * This method is protected since only derived Data Objects (DO's)
828      * "<CODE>set</CODE>" methods will be calling it.<P>
829      *
830      * This method returns the new value as a convenience to the calling
831      * "<CODE>set</CODE>" method. The usage is:
832      * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
833      *
834      * @param current_val The current value of the java.sql.Timestamp data member.
835      * @param new_val The new value of the java.sql.Timestamp data member.
836      * @return new_val
837      */

838     protected java.sql.Timestamp JavaDoc markNewValue(
839             java.sql.Timestamp JavaDoc current_val, java.sql.Timestamp JavaDoc new_val) {
840         colChanged = false;
841         if (current_val == null) {
842             if (new_val != null) {
843                 colChanged = dirty = true;
844             }
845         } else {
846             if (new_val == null) {
847                 colChanged = dirty = true;
848             } else if (!current_val.equals(new_val)) {
849                 colChanged = dirty = true;
850             }
851         }
852         return new_val;
853     }
854
855     /**
856      * If the current data member value differs from the new value,
857      * this object is marked as "dirty" (in need of an update to the database).
858      * There is no way to mark this object as "clean";<BR> only the
859      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
860      * methods can make that so.<P>
861      *
862      * This method is protected since only derived Data Objects (DO's)
863      * "<CODE>set</CODE>" methods will be calling it.<P>
864      *
865      * This method returns the new value as a convenience to the calling
866      * "<CODE>set</CODE>" method. The usage is:
867      * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
868      *
869      * @param current_int The current value of the int data member.
870      * @param new_int The new value of the int data member.
871      * @return new_int
872      */

873     protected int markNewValue(int current_int, int new_int) {
874         colChanged = false;
875         if (current_int != new_int) {
876             colChanged = dirty = true;
877         }
878         return new_int;
879     }
880
881     /**
882      * If the current data member value differs from the new value,
883      * this object is marked as "dirty" (in need of an update to the database).
884      * There is no way to mark this object as "clean";<BR> only the
885      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
886      * methods can make that so.<P>
887      *
888      * This method is protected since only derived Data Objects (DO's)
889      * "<CODE>set</CODE>" methods will be calling it.<P>
890      *
891      * This method returns the new value as a convenience to the calling
892      * "<CODE>set</CODE>" method. The usage is:
893      * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
894      *
895      * @param current_float The current value of the float data member.
896      * @param new_float The new value of the float data member.
897      * @return new_float
898      */

899     protected float markNewValue(float current_float, float new_float) {
900         colChanged = false;
901         if (current_float != new_float) {
902             colChanged = dirty = true;
903         }
904         return new_float;
905     }
906
907     /**
908      * If the current data member value differs from the new value,
909      * this object is marked as "dirty" (in need of an update to the database).
910      * There is no way to mark this object as "clean";<BR> only the
911      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
912      * methods can make that so.<P>
913      *
914      * This method is protected since only derived Data Objects (DO's)
915      * "<CODE>set</CODE>" methods will be calling it.<P>
916      *
917      * This method returns the new value as a convenience to the calling
918      * "<CODE>set</CODE>" method. The usage is:
919      * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
920      *
921      * @param current_double The current value of the double data member.
922      * @param new_double The new value of the double data member.
923      * @return new_double
924      */

925     protected double markNewValue(double current_double, double new_double) {
926         colChanged = false;
927         if (current_double != new_double) {
928             colChanged = dirty = true;
929         }
930         return new_double;
931     }
932
933     /**
934      * If the current data member value differs from the new value,
935      * this object is marked as "dirty" (in need of an update to the database).
936      * There is no way to mark this object as "clean";<BR> only the
937      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
938      * methods can make that so.<P>
939      *
940      * This method is protected since only derived Data Objects (DO's)
941      * "<CODE>set</CODE>" methods will be calling it.<P>
942      *
943      * This method returns the new value as a convenience to the calling
944      * "<CODE>set</CODE>" method. The usage is:
945      * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
946      *
947      * @param current_boolean The current value of the boolean data member.
948      * @param new_boolean The new value of the boolean data member.
949      * @return new_boolean
950      */

951     protected boolean markNewValue(boolean current_boolean, boolean new_boolean) {
952         colChanged = false;
953         if (current_boolean != new_boolean) {
954             colChanged = dirty = true;
955         }
956         return new_boolean;
957     }
958
959     /**
960      * If the current data member value differs from the new value,
961      * this object is marked as "dirty" (in need of an update to the database).
962      * There is no way to mark this object as "clean";<BR> only the
963      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
964      * methods can make that so.<P>
965      *
966      * This method is protected since only derived Data Objects (DO's)
967      * "<CODE>set</CODE>" methods will be calling it.<P>
968      *
969      * This method returns the new value as a convenience to the calling
970      * "<CODE>set</CODE>" method. The usage is:
971      * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
972      *
973      * @param current_char The current value of the char data member.
974      * @param new_char The new value of the char data member.
975      * @return new_char
976      */

977     protected char markNewValue(char current_char, char new_char) {
978         colChanged = false;
979         if (current_char != new_char) {
980             colChanged = dirty = true;
981         }
982         return new_char;
983     }
984
985     /**
986      * If the current data member value differs from the new value,
987      * this object is marked as "dirty" (in need of an update to the database).
988      * There is no way to mark this object as "clean";<BR> only the
989      * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
990      * methods can make that so.<P>
991      *
992      * This method is protected since only derived Data Objects (DO's)
993      * "<CODE>set</CODE>" methods will be calling it.<P>
994      *
995      * This method returns the new value as a convenience to the calling
996      * "<CODE>set</CODE>" method. The usage is:
997      * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
998      *
999      * @param current_byte The current value of the byte data member.
1000     * @param new_byte The new value of the byte data member.
1001     * @return new_byte
1002     */

1003    protected byte markNewValue(byte current_byte, byte new_byte) {
1004        colChanged = false;
1005        if (current_byte != new_byte) {
1006            colChanged = dirty = true;
1007        }
1008        return new_byte;
1009    }
1010
1011    /**
1012     * If the current data member value differs from the new value,
1013     * this object is marked as "dirty" (in need of an update to the database).
1014     * There is no way to mark this object as "clean";<BR> only the
1015     * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
1016     * methods can make that so.<P>
1017     *
1018     * This method is protected since only derived Data Objects (DO's)
1019     * "<CODE>set</CODE>" methods will be calling it.<P>
1020     *
1021     * This method returns the new value as a convenience to the calling
1022     * "<CODE>set</CODE>" method. The usage is:
1023     * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
1024     *
1025     * @param current_short The current value of the short data member.
1026     * @param new_short The new value of the short data member.
1027     * @return new_short
1028     */

1029    protected short markNewValue(short current_short, short new_short) {
1030        colChanged = false;
1031        if (current_short != new_short) {
1032            colChanged = dirty = true;
1033        }
1034        return new_short;
1035    }
1036
1037    /**
1038     * If the current data member value differs from the new value,
1039     * this object is marked as "dirty" (in need of an update to the database).
1040     * There is no way to mark this object as "clean";<BR> only the
1041     * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
1042     * methods can make that so.<P>
1043     *
1044     * This method is protected since only derived Data Objects (DO's)
1045     * "<CODE>set</CODE>" methods will be calling it.<P>
1046     *
1047     * This method returns the new value as a convenience to the calling
1048     * "<CODE>set</CODE>" method. The usage is:
1049     * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
1050     *
1051     * @param current_long The current value of the long data member.
1052     * @param new_long The new value of the long data member.
1053     * @return new_long
1054     */

1055    protected long markNewValue(long current_long, long new_long) {
1056        colChanged = false;
1057        if (current_long != new_long) {
1058            colChanged = dirty = true;
1059        }
1060        return new_long;
1061    }
1062
1063    /**
1064     * If the current data member value differs from the new value,
1065     * this object is marked as "dirty" (in need of an update to the database).
1066     * There is no way to mark this object as "clean";<BR> only the
1067     * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
1068     * methods can make that so.<P>
1069     *
1070     * This method is protected since only derived Data Objects (DO's)
1071     * "<CODE>set</CODE>" methods will be calling it.<P>
1072     *
1073     * This method returns the new value as a convenience to the calling
1074     * "<CODE>set</CODE>" method. The usage is:
1075     * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
1076     *
1077     * @param current_DO Curent data object.
1078     * @param new_DO New data object.
1079     * @return new_long
1080     */

1081    protected GenericDO markNewValue(GenericDO current_DO, GenericDO new_DO) {
1082        colChanged = false;
1083        if (current_DO != new_DO) {
1084            colChanged = dirty = true;
1085        }
1086        return new_DO;
1087    }
1088
1089    /**
1090     * If the current data member value differs from the new value,
1091     * this object is marked as "dirty" (in need of an update to the database).
1092     * There is no way to mark this object as "clean";<BR> only the
1093     * <CODE>executeInsert()</CODE> and <CODE>executeUpdate()</CODE>
1094     * methods can make that so.<P>
1095     *
1096     * This method is protected since only derived Data Objects (DO's)
1097     * "<CODE>set</CODE>" methods will be calling it.<P>
1098     *
1099     * This method returns the new value as a convenience to the calling
1100     * "<CODE>set</CODE>" method. The usage is:
1101     * <CODE>this.field = markNewValue( this.field, new_field_value )</CODE>
1102     *
1103     * @return new_ts
1104     */

1105
1106    /*
1107     protected Timestamp markNewValue(Timestamp current_ts, Timestamp new_ts)
1108     {
1109     if ( ! current_ts.equals( new_ts ) )
1110     dirty = true;
1111     return new_ts;
1112     }
1113     */

1114    protected void setPrepStmtParam_DO(
1115            PreparedStatement JavaDoc stmt, int[] paramIndex, GenericDO value)
1116        throws java.sql.SQLException JavaDoc {
1117        if (null == value) {
1118            if (isSetNullAsVarchar()) {
1119                stmt.setNull(paramIndex[0]++, Types.VARCHAR);
1120            }else {
1121                stmt.setNull(paramIndex[0]++, Types.DECIMAL);
1122            }
1123        } else {
1124            ObjectId oid = value.get_OId();
1125
1126            if (null == oid) {
1127                 if (isSetNullAsVarchar()) {
1128                     stmt.setNull(paramIndex[0]++, Types.VARCHAR);
1129                 }else {
1130                     stmt.setNull(paramIndex[0]++, Types.DECIMAL);
1131                 }
1132            } else {
1133                setPrepStmtParam_BigDecimal(stmt, paramIndex, oid.toBigDecimal());
1134            }
1135        }
1136    }
1137
1138    static protected boolean isNewDataDifferent_DO(GenericDO oldData, GenericDO newData) {
1139        return (null == oldData)
1140                ? (null != newData)
1141                : (null == newData)
1142                        ? true
1143                        : isNewDataDifferent_BigDecimal(oldData.get_OId().toBigDecimal(),
1144                                newData.get_OId().toBigDecimal());
1145    }
1146
1147    protected void setPrepStmtParam_String(
1148            PreparedStatement JavaDoc stmt, int[] paramIndex, String JavaDoc value)
1149        throws java.sql.SQLException JavaDoc {
1150        if (null == value) {
1151            stmt.setNull(paramIndex[0]++, Types.VARCHAR);
1152        } else {
1153            // WebDocWf fix for JTurbo Problem
1154
stmt.setString(paramIndex[0]++, value);
1155        }
1156        // end of WebDocWf fix for JTurbo Problem
1157
}
1158
1159    static protected boolean isNewDataDifferent_String(String JavaDoc oldData, String JavaDoc newData) {
1160        return (null == oldData) ? (null != newData) : !oldData.equals(newData);
1161    }
1162
1163    protected void setPrepStmtParam_float(
1164            PreparedStatement JavaDoc stmt, int[] paramIndex, float value)
1165        throws java.sql.SQLException JavaDoc {
1166        stmt.setFloat(paramIndex[0]++, value);
1167    }
1168
1169    static protected boolean isNewDataDifferent_float(float oldData, float newData) {
1170        return oldData != newData;
1171    }
1172
1173    protected void setPrepStmtParam_int(
1174            PreparedStatement JavaDoc stmt, int[] paramIndex, int value)
1175        throws java.sql.SQLException JavaDoc {
1176        stmt.setInt(paramIndex[0]++, value);
1177    }
1178
1179    static protected boolean isNewDataDifferent_int(int oldData, int newData) {
1180        return oldData != newData;
1181    }
1182
1183    protected void setPrepStmtParam_java_math_BigDecimal(
1184            PreparedStatement JavaDoc stmt, int[] paramIndex, BigDecimal JavaDoc value)
1185        throws java.sql.SQLException JavaDoc {
1186        if (null == value) {
1187            if (isSetNullAsVarchar()) {
1188                stmt.setNull(paramIndex[0]++, Types.VARCHAR);
1189             }else {
1190                stmt.setNull(paramIndex[0]++, Types.DECIMAL);
1191             }
1192        } else {
1193            stmt.setBigDecimal(paramIndex[0]++, value);
1194        }
1195    }
1196
1197    static protected boolean isNewDataDifferent_java_math_BigDecimal(BigDecimal JavaDoc oldData, BigDecimal JavaDoc newData) {
1198        return (null == oldData)
1199                ? (null != newData)
1200                : (null == newData) ? true : !oldData.equals(newData);
1201    }
1202
1203    protected void setPrepStmtParam_BigDecimal(
1204            PreparedStatement JavaDoc stmt, int[] paramIndex, BigDecimal JavaDoc value)
1205        throws java.sql.SQLException JavaDoc {
1206        if (null == value) {
1207             if (isSetNullAsVarchar()) {
1208                 stmt.setNull(paramIndex[0]++, Types.VARCHAR);
1209             }else {
1210                 stmt.setNull(paramIndex[0]++, Types.DECIMAL);
1211             }
1212        } else {
1213            stmt.setBigDecimal(paramIndex[0]++, value);
1214        }
1215    }
1216
1217    static protected boolean isNewDataDifferent_BigDecimal(BigDecimal JavaDoc oldData, BigDecimal JavaDoc newData) {
1218        return isNewDataDifferent_java_math_BigDecimal(oldData, newData);
1219    }
1220
1221    protected void setPrepStmtParam_java_sql_Date(
1222            PreparedStatement JavaDoc stmt, int[] paramIndex, java.sql.Date JavaDoc value)
1223        throws java.sql.SQLException JavaDoc {
1224        if (null == value) {
1225             if (isSetNullAsVarchar()) {
1226                 stmt.setNull(paramIndex[0]++, Types.VARCHAR);
1227             }else {
1228                 stmt.setNull(paramIndex[0]++, Types.DATE);
1229             }
1230        } else {
1231            stmt.setDate(paramIndex[0]++, value);
1232        }
1233    }
1234
1235    static protected boolean isNewDataDifferent_java_sql_Date(java.sql.Date JavaDoc oldData, java.sql.Date JavaDoc newData) {
1236        return (null == oldData) ? (null != newData) : !oldData.equals(newData);
1237    }
1238
1239    protected void setPrepStmtParam_java_sql_Time(
1240            PreparedStatement JavaDoc stmt, int[] paramIndex, java.sql.Time JavaDoc value)
1241        throws java.sql.SQLException JavaDoc {
1242        if (null == value) {
1243             if (isSetNullAsVarchar()) {
1244                 stmt.setNull(paramIndex[0]++, Types.VARCHAR);
1245             }else {
1246                 stmt.setNull(paramIndex[0]++, Types.TIME);
1247             }
1248        } else {
1249            stmt.setTime(paramIndex[0]++, value);
1250        }
1251    }
1252
1253    static protected boolean isNewDataDifferent_java_sql_Time(java.sql.Time JavaDoc oldData, java.sql.Time JavaDoc newData) {
1254        return (null == oldData) ? (null != newData) : !oldData.equals(newData);
1255    }
1256
1257    protected void setPrepStmtParam_java_sql_Timestamp(
1258            PreparedStatement JavaDoc stmt, int[] paramIndex, java.sql.Timestamp JavaDoc value)
1259        throws java.sql.SQLException JavaDoc {
1260        if (null == value) {
1261            if (isSetNullAsVarchar()) {
1262                stmt.setNull(paramIndex[0]++, Types.VARCHAR);
1263             }else {
1264                stmt.setNull(paramIndex[0]++, Types.TIMESTAMP);
1265             }
1266        } else {
1267            stmt.setTimestamp(paramIndex[0]++, value);
1268        }
1269    }
1270
1271    static protected boolean isNewDataDifferent_java_sql_Timestamp(java.sql.Timestamp JavaDoc oldData, java.sql.Timestamp JavaDoc newData) {
1272        return (null == oldData) ? (null != newData) : !oldData.equals(newData);
1273    }
1274
1275    protected void setPrepStmtParam_bytes(
1276            PreparedStatement JavaDoc stmt, int[] paramIndex, byte[] value)
1277        throws java.sql.SQLException JavaDoc {
1278        if (null == value) {
1279            if (isSetNullAsVarchar()) {
1280                stmt.setNull(paramIndex[0]++, Types.VARCHAR);
1281            }else {
1282                stmt.setNull(paramIndex[0]++, Types.VARBINARY);
1283            }
1284        } else {
1285            if(isSetBytesAsBinaryStream()) {
1286                ByteArrayInputStream JavaDoc newBAIS = new ByteArrayInputStream JavaDoc(value);
1287                stmt.setBinaryStream(paramIndex[0]++,newBAIS,value.length);
1288                try {
1289                    newBAIS.close();
1290                } catch (IOException JavaDoc e) {
1291                    e.printStackTrace();
1292                }
1293            }else if(isSetBytesAsLongvarbinary()) {
1294                String JavaDoc psValue = new String JavaDoc(value);
1295                stmt.setObject(paramIndex[0]++, psValue, Types.LONGVARBINARY);
1296            }else {
1297                // WebDocWf fix for JTurbo Problem
1298
stmt.setBytes(paramIndex[0]++, value);
1299                // end of WebDocWf fix for JTurbo Problem
1300
}
1301        }
1302        
1303    }
1304
1305    static protected boolean isNewDataDifferent_bytes(byte[] oldData, byte[] newData) {
1306        if (null == oldData) {
1307            return null != newData;
1308        } else if (oldData.length == newData.length) {
1309            for (int i = 0; i < oldData.length; ++i) {
1310                if (oldData[i] != newData[i]) {
1311                    return true;
1312                }
1313            }
1314            return false;
1315        }
1316        return true;
1317    }
1318
1319    protected void setPrepStmtParam_double(
1320            PreparedStatement JavaDoc stmt, int[] paramIndex, double value)
1321        throws java.sql.SQLException JavaDoc {
1322        stmt.setDouble(paramIndex[0]++, value);
1323    }
1324
1325    static protected boolean isNewDataDifferent_double(double oldData, double newData) {
1326        return oldData != newData;
1327    }
1328
1329    protected void setPrepStmtParam_long(
1330            PreparedStatement JavaDoc stmt, int[] paramIndex, long value)
1331        throws java.sql.SQLException JavaDoc {
1332        stmt.setLong(paramIndex[0]++, value);
1333    }
1334
1335    static protected boolean isNewDataDifferent_long(long oldData, long newData) {
1336        return oldData != newData;
1337    }
1338
1339    protected void setPrepStmtParam_short(
1340            PreparedStatement JavaDoc stmt, int[] paramIndex, short value)
1341        throws java.sql.SQLException JavaDoc {
1342        stmt.setShort(paramIndex[0]++, value);
1343    }
1344
1345    static protected boolean isNewDataDifferent_short(short oldData, short newData) {
1346        return oldData != newData;
1347    }
1348
1349    protected void setPrepStmtParam_byte(
1350            PreparedStatement JavaDoc stmt, int[] paramIndex, byte value)
1351        throws java.sql.SQLException JavaDoc {
1352        stmt.setByte(paramIndex[0]++, value);
1353    }
1354
1355    static protected boolean isNewDataDifferent_byte(byte oldData, byte newData) {
1356        return oldData != newData;
1357    }
1358
1359    protected void setPrepStmtParam_boolean(PreparedStatement JavaDoc stmt, int[] paramIndex, boolean value)
1360    throws java.sql.SQLException JavaDoc {
1361        if(isSetBooleanAsString()) {
1362            stmt.setString(paramIndex[0]++, value ? "1" : "0");
1363        }else {
1364            stmt.setBoolean(paramIndex[0]++, value);
1365        }
1366    }
1367
1368    static protected boolean isNewDataDifferent_boolean(boolean oldData, boolean newData) {
1369        return oldData != newData;
1370    }
1371
1372    public String JavaDoc toString(int x) {
1373        return super.toString();
1374    }
1375
1376    public void delete()
1377        throws SQLException JavaDoc, DatabaseManagerException,
1378                DataObjectException, RefAssertionException,
1379                DBRowUpdateException, QueryException {
1380        if (false) {
1381            throw new SQLException JavaDoc("");
1382        }
1383        if (false) {
1384            throw new DatabaseManagerException("");
1385        }
1386        if (false) {
1387            throw new DataObjectException("");
1388        }
1389        if (false) {
1390            throw new RefAssertionException("");
1391        }
1392        if (false) {
1393            throw new DBRowUpdateException("");
1394        }
1395        if (false) {
1396            throw new QueryException("");
1397        }
1398    }
1399
1400    // Copy routines used by the duplicate() method in generated DataStruct classes.
1401
// If a null is passed, a null is returned.
1402
static public byte[] copyByteArray(byte[] source) {
1403        if (null == source) {
1404            return null;
1405        }
1406        byte[] dest = new byte[ source.length ];
1407
1408        System.arraycopy(source, 0, dest, 0, source.length);
1409        return dest;
1410    }
1411
1412    static public String JavaDoc copyString(String JavaDoc source) {
1413        if (null == source) {
1414            return null;
1415        }
1416        return source + "";
1417    }
1418
1419    static public BigDecimal JavaDoc copyBigDecimal(BigDecimal JavaDoc source) {
1420        if (null == source) {
1421            return null;
1422        }
1423        return new java.math.BigDecimal JavaDoc(source.toString());
1424    }
1425
1426    static public java.sql.Date JavaDoc copyDate(java.sql.Date JavaDoc source) {
1427        if (null == source) {
1428            return null;
1429        }
1430        return new java.sql.Date JavaDoc(source.getTime());
1431    }
1432
1433    static public java.sql.Time JavaDoc copyTime(java.sql.Time JavaDoc source) {
1434        if (null == source) {
1435            return null;
1436        }
1437        return new java.sql.Time JavaDoc(source.getTime());
1438    }
1439
1440    static public java.sql.Timestamp JavaDoc copyTimestamp(java.sql.Timestamp JavaDoc source) {
1441        if (null == source) {
1442            return null;
1443        }
1444        return new java.sql.Timestamp JavaDoc(source.getTime());
1445    }
1446
1447    /**
1448     * Subclass should override this method if wants to use it.
1449     * This method checks if this data object satisfies query conditions
1450     * cond.
1451     *
1452     * @param cond conditions of the query.
1453     * @return true if this data object satisfies conditions of this query,
1454     * otherwise false.
1455     */

1456    public boolean compareCond(Condition cond) {
1457        return false;
1458    }
1459
1460    /**
1461     * Subclass should override this method if wants to use it.
1462     * Sets DO's data.
1463     *
1464     * @deprecated Use set_Data()
1465     * @param data DO's data.
1466     */

1467    public void setData(Object JavaDoc data) {}
1468
1469    /**
1470     * Subclass should override this method if wants to use it.
1471     * Sets DO's data.
1472     *
1473     * @param data DO's data.
1474     */

1475    public void set_Data(Object JavaDoc data) {}
1476
1477    /**
1478     * Subclass should override this method if wants to use it.
1479     * Sets original DO's data.
1480     */

1481    public void originalData_set(Object JavaDoc data) {}
1482
1483    /**
1484     * @deprecated Use get_Data()
1485     * @return DO's data.
1486     */

1487    public Object JavaDoc getData() {
1488        return getData();
1489    }
1490
1491    /**
1492     * Subclass should override this method if wants to use it.
1493     * Returns DO's data.
1494     *
1495     * @return DO's data.
1496     */

1497    public Object JavaDoc get_Data() {
1498        return null;
1499    }
1500
1501    /**
1502     * Subclass should override this method if wants to use it.
1503     * Returns DO's handle.
1504     *
1505     * @return DO's handle.
1506     */

1507    public String JavaDoc get_Handle() throws DatabaseManagerException {
1508        return null;
1509    }
1510
1511    /**
1512     * Subclass should override this method if wants to use it.
1513     * Returns DO's handle.
1514     *
1515     * @return DO's handle.
1516     * @deprecated Use get_Handle() instead.
1517     */

1518    public String JavaDoc getHandle() throws DatabaseManagerException {
1519        return null;
1520    }
1521     
1522    /**
1523     * Subclass should override this method if wants to use it.
1524     * Returns DO's cache handle.
1525     *
1526     * @return DO's cache handle.
1527     */

1528    public String JavaDoc get_CacheHandle() throws DatabaseManagerException {
1529        return null;
1530    }
1531
1532    /**
1533     * Subclass should override this method if wants to use it.
1534     * Returns copy of DO (with the same id).
1535     *
1536     * @param obj DO which will be copied.
1537     * @return copy of DO (with the same id).
1538     */

1539    public GenericDO createDO(GenericDO obj) {
1540        return null;
1541    }
1542
1543    /**
1544     * Subclass should override this method if wants to use it.
1545     * Created DO with specified OID.
1546     *
1547     * @param oid DO(by oid) which will be copied.
1548     * @return copy of DO (with the same id).
1549     */

1550    public static GenericDO createDO(ObjectId oid) throws java.sql.SQLException JavaDoc, com.lutris.appserver.server.sql.ObjectIdException, com.lutris.dods.builder.generator.query.DataObjectException, com.lutris.appserver.server.sql.DatabaseManagerException {
1551        return null;
1552    }
1553
1554    /**
1555     * @deprecated Use get_OriginDatabase()
1556     * @return origin logical database name.
1557     */

1558    public String JavaDoc getOriginDatabase() {
1559        return null;
1560    }
1561
1562    /**
1563     * Subclass should override this method if wants to use it.
1564     * Returns the name of the logical database for which DO was created.
1565     *
1566     * @return origin logical database name.
1567     */

1568    public String JavaDoc get_OriginDatabase() {
1569        return null;
1570    }
1571
1572    private boolean executePartially;
1573
1574    public void setExecutePartially(boolean _ep) {
1575        executePartially = _ep;
1576    }
1577
1578    public boolean isExecutePartially() {
1579        return executePartially;
1580    }
1581}
1582
Popular Tags