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 (!cu