KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jcorporate > expresso > core > dataobjects > jdbc > JoinedDataObjectMetaData


1 /* ====================================================================
2 * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
3 *
4 * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * 3. The end-user documentation included with the redistribution,
19 * if any, must include the following acknowledgment:
20 * "This product includes software developed by Jcorporate Ltd.
21 * (http://www.jcorporate.com/)."
22 * Alternately, this acknowledgment may appear in the software itself,
23 * if and wherever such third-party acknowledgments normally appear.
24 *
25 * 4. "Jcorporate" and product names such as "Expresso" must
26 * not be used to endorse or promote products derived from this
27 * software without prior written permission. For written permission,
28 * please contact info@jcorporate.com.
29 *
30 * 5. Products derived from this software may not be called "Expresso",
31 * or other Jcorporate product names; nor may "Expresso" or other
32 * Jcorporate product names appear in their name, without prior
33 * written permission of Jcorporate Ltd.
34 *
35 * 6. No product derived from this software may compete in the same
36 * market space, i.e. framework, without prior written permission
37 * of Jcorporate Ltd. For written permission, please contact
38 * partners@jcorporate.com.
39 *
40 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
41 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
42 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43 * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
44 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
46 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
47 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
50 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This software consists of voluntary contributions made by many
55 * individuals on behalf of the Jcorporate Ltd. Contributions back
56 * to the project(s) are encouraged when you make modifications.
57 * Please send them to support@jcorporate.com. For more information
58 * on Jcorporate Ltd. and its products, please see
59 * <http://www.jcorporate.com/>.
60 *
61 * Portions of this software are based upon other open source
62 * products and are subject to their respective licenses.
63  */

64 package com.jcorporate.expresso.core.dataobjects.jdbc;
65
66 import com.jcorporate.expresso.core.dataobjects.DataException;
67 import com.jcorporate.expresso.core.dataobjects.DataFieldMetaData;
68 import com.jcorporate.expresso.core.dataobjects.DataObject;
69 import com.jcorporate.expresso.core.dataobjects.DataObjectMetaData;
70 import com.jcorporate.expresso.core.dataobjects.Defineable;
71 import com.jcorporate.expresso.core.db.DBException;
72 import com.jcorporate.expresso.core.i18n.Messages;
73 import com.jcorporate.expresso.core.misc.StringUtil;
74
75 import java.util.ArrayList JavaDoc;
76 import java.util.Collections JavaDoc;
77 import java.util.HashMap JavaDoc;
78 import java.util.Iterator JavaDoc;
79 import java.util.List JavaDoc;
80 import java.util.Locale JavaDoc;
81 import java.util.Map JavaDoc;
82 import java.util.Set JavaDoc;
83 import java.util.StringTokenizer JavaDoc;
84
85 /**
86  * Not yet released - do not use in your own code yet.
87  * This object provides an implementation of DataObjectMetaData that is used
88  * for the various join operations. It's job is to provide the descriptive
89  * services required for applications such as DBMaint to generically access
90  * the JoinedDataObject.
91  *
92  * @author Michael Rimov
93  * <p/>
94  * Modify by Yves Henri AMAIZO <amy_amaizo@compuserve.com>
95  * @since $DatabaseSchema $Date: 2004/11/18 02:03:27 $
96  */

97 public class JoinedDataObjectMetaData implements DataObjectMetaData {
98
99     /**
100      * Hash that contains the DB objects that relate to make up this query,
101      * indexed by the "short" name provided by the user.
102      */

103     private HashMap JavaDoc myDataObjects = new HashMap JavaDoc();
104
105     /**
106      * A list of dataobjects as they were added to the join
107      */

108     private List JavaDoc dataObjects = new ArrayList JavaDoc();
109
110     /**
111      * Gives the order of the aliases An arrayList of Strings
112      */

113     private List JavaDoc aliasesInOrder = new ArrayList JavaDoc();
114
115     /**
116      * Fields to retrieve for each DataObject
117      */

118     private Map JavaDoc fieldsToRetrieve = new HashMap JavaDoc();
119
120     /**
121      * Friendly display name of this join.
122      */

123     private String JavaDoc description = "Joined Data Object";
124
125     /**
126      * Use a DISTINCT keyword right after SELECT keyword
127      */

128     private boolean selectDistinct = false;
129
130     /**
131      * List of all the field names for all the data objects.
132      */

133     private ArrayList JavaDoc allFieldList = null;
134
135     /**
136      * List of all the key field names for the data object.
137      */

138     private ArrayList JavaDoc keyFieldList = null;
139
140     /**
141      * Permission overrides
142      */

143     private Map JavaDoc permissions = null;
144
145     /**
146      * List of all fields in a key -> metadata method.
147      */

148     HashMap JavaDoc allFieldMap = null;
149
150     /**
151      * A map keyed by 'foreigndbobj.foreignprimarykey' and pointing to the
152      * 'local alias'.'foreign key'
153      */

154     HashMap JavaDoc primaryToForeignKeyMap = new HashMap JavaDoc();
155
156     /**
157      * Another map, this time in reverse. Given the local key, get the foreign
158      * key
159      */

160     HashMap JavaDoc foreignKeyToPrimaryKeyMap = new HashMap JavaDoc();
161
162     /**
163      * Lookup Map of all the relations
164      */

165     HashMap JavaDoc relations = new HashMap JavaDoc();
166
167     private List JavaDoc sqlRelationList = new ArrayList JavaDoc();
168
169     /**
170      * Details
171      */

172     private Set JavaDoc allDetails = null;
173
174     /**
175      * The name of the metadata
176      */

177     private String JavaDoc name = "";
178
179     /**
180      * Default constructor
181      */

182     public JoinedDataObjectMetaData() {
183     }
184
185     public Map JavaDoc getDataObjects() {
186         return Collections.unmodifiableMap(myDataObjects);
187     }
188
189     /**
190      * Retrieves a list of DataObjects that were used in Order
191      *
192      * @return java.util.List of JDBCDataObjects
193      */

194     public List JavaDoc getDataObjectsInOrder() {
195         return this.dataObjects;
196     }
197
198     /**
199      * Retrieves a list of Aliases in order that they were added
200      *
201      * @return java.util.List of Strings
202      */

203     public List JavaDoc getAliasesInOrder() {
204         return this.aliasesInOrder;
205     }
206
207     /**
208      * Retrieve the default value for the specified
209      *
210      * @param fieldName the name of the field to check
211      * @return java.lang.String
212      */

213     public String JavaDoc getDefaultValue(String JavaDoc fieldName) {
214         String JavaDoc values[] = this.getObjectAndField(fieldName);
215         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
216         DataObjectMetaData metadata = oneObj.getMetaData();
217         return metadata.getDefaultValue(values[1]);
218     }
219
220     /**
221      * Add a DB Object to the objects being used for this multidbobj query. The
222      * object is specified with a full classname, then a "short" name used to
223      * refer to it in this object. For example, the class name might be
224      * com.jcorporate.expresso.services.dbobj.SchemaList, the short name might
225      * be "schema".
226      *
227      * @param dataObjectClass java.lang.String
228      * @param alias java.lang.String
229      * @param definitionName [optional] The definition name if the DataObject is
230      * Defineable
231      * @param fieldExpressionList [optional] pipe-delimited list of fields to
232      * retrieve for this DataObject
233      * @throws IllegalArgumentException if the Class is inappropriate for the system.
234      */

235     public void addDataObject(Class JavaDoc dataObjectClass, String JavaDoc definitionName,
236                               String JavaDoc alias, String JavaDoc fieldExpressionList)
237             throws DataException, IllegalArgumentException JavaDoc {
238         if (dataObjectClass == null) {
239             throw new IllegalArgumentException JavaDoc("Must specify a class name");
240         }
241
242         if (StringUtil.notNull(alias).equals("")) {
243             throw new IllegalArgumentException JavaDoc("Must specify a short name");
244         }
245
246         DataObject oneDBObj = null;
247
248         try {
249             oneDBObj = (DataObject) dataObjectClass.newInstance();
250         } catch (InstantiationException JavaDoc ie) {
251             throw new DataException(":DBObject '" + dataObjectClass.getName() +
252                     "' cannot be instantiated", ie);
253         } catch (IllegalAccessException JavaDoc iae) {
254             throw new DataException(":Illegal access loading DBObject '" +
255                     dataObjectClass.getName() + "'", iae);
256         }
257
258         if (oneDBObj instanceof Defineable) {
259             ((Defineable) oneDBObj).setDefinitionName(definitionName);
260         }
261
262         oneDBObj.setAttribute("shortName", alias);
263         myDataObjects.put(alias, oneDBObj);
264         this.dataObjects.add(oneDBObj);
265         this.aliasesInOrder.add(alias);
266
267         if (fieldExpressionList != null) {
268             ArrayList JavaDoc fields = new ArrayList JavaDoc();
269             StringTokenizer JavaDoc stok = new StringTokenizer JavaDoc(fieldExpressionList, "|");
270             while (stok.hasMoreTokens()) {
271                 String JavaDoc fieldExpression = (String JavaDoc) stok.nextToken();
272                 // test for parentheses. If we find any we are dealing with a
273
// column expression, e.g SUM(fieldName)
274
int lastOpen = fieldExpression.lastIndexOf("(");
275                 if (lastOpen == -1) {
276                     fields.add(new FieldList(fieldExpression, fieldExpression, false));
277                     continue;
278                 }
279                 int firstClosed = fieldExpression.indexOf(")");
280                 if (firstClosed == -1) {
281                     throw new DataException(":Invalid expression for DBObject '" +
282                             dataObjectClass.getName());
283                 }
284
285                 String JavaDoc fieldName = fieldExpression.substring(lastOpen + 1,
286                         firstClosed);
287                 int comma = fieldName.indexOf(",");
288                 if (comma != -1) {
289                     fieldName = fieldName.substring(comma);
290                 }
291                 JDBCDataObject JDBObj = (JDBCDataObject) oneDBObj;
292                 fieldExpression =
293                         StringUtil.replaceStringOnce(fieldExpression, fieldName,
294                                 JDBObj.getJDBCMetaData().
295                         getTargetTable() + "." +
296                         fieldName);
297                 fields.add(new FieldList(fieldExpression, fieldName, true));
298             }
299             fieldsToRetrieve.put(alias, fields);
300         }
301     }
302
303     /**
304      * Returns the detail set for the primary data object
305      *
306      * @return java.util.Set
307      */

308     public synchronized Set JavaDoc getDetailSet() {
309         if (allDetails == null) {
310             allDetails = new java.util.HashSet JavaDoc();
311             for (Iterator JavaDoc i = this.dataObjects.iterator(); i.hasNext();) {
312                 JDBCDataObject oneDataObject = (JDBCDataObject) i.next();
313                 allDetails.addAll(oneDataObject.getMetaData().getDetailSet());
314             }
315         }
316
317         return allDetails;
318     }
319
320     /**
321      * Retrieve the local key fields.
322      *
323      * @param detailName the name of the detail dbobject
324      * @return java.lang.String
325      */

326     public String JavaDoc getDetailFieldsLocal(String JavaDoc detailName) {
327         if (allDetails == null) {
328             return "";
329         }
330
331         int index = 0;
332         for (Iterator JavaDoc i = this.dataObjects.iterator(); i.hasNext(); index++) {
333             JDBCDataObject oneDataObject = (JDBCDataObject) i.next();
334             String JavaDoc detailFields = oneDataObject.getMetaData().getDetailFieldsLocal(detailName);
335
336             if (detailFields != null && detailFields.length() > 0) {
337                 String JavaDoc prefix = (String JavaDoc) this.getAliasesInOrder().get(index) + ".";
338                 java.lang.StringBuffer JavaDoc returnValue = new java.lang.StringBuffer JavaDoc(64);
339                 java.util.StringTokenizer JavaDoc stok = new java.util.StringTokenizer JavaDoc(detailFields, "|");
340                 boolean needPipe = false;
341                 while (stok.hasMoreTokens()) {
342                     if (needPipe) {
343                         returnValue.append("|");
344                     } else {
345                         needPipe = true;
346                     }
347                     String JavaDoc oneField = stok.nextToken();
348                     returnValue.append(prefix);
349                     returnValue.append(oneField);
350                 }
351
352                 return returnValue.toString();
353             }
354         }
355
356         return "";
357     }
358
359     /**
360      * Retrieve the foreign key fields
361      *
362      * @param detailName the name of the detail dbobject
363      * @return java.lang.String
364      */

365     public synchronized String JavaDoc getDetailFieldsForeign(String JavaDoc detailName) {
366         if (allDetails == null) {
367             return "";
368         }
369
370         for (Iterator JavaDoc i = this.dataObjects.iterator(); i.hasNext();) {
371             JDBCDataObject oneDataObject = (JDBCDataObject) i.next();
372             String JavaDoc detailFields = oneDataObject.getMetaData().getDetailFieldsForeign(detailName);
373
374             if (detailFields != null && detailFields.length() > 0) {
375                 return detailFields;
376 // String prefix = (String)this.getAliasesInOrder().get(index) + ".";
377
// java.lang.StringBuffer returnValue = new java.lang.StringBuffer(64);
378
// java.util.StringTokenizer stok = new java.util.StringTokenizer(detailFields,"|");
379
// boolean needPipe = false;
380
// while (stok.hasMoreTokens()) {
381
// if (needPipe) {
382
// returnValue.append("|");
383
// } else {
384
// needPipe = true;
385
// }
386
// String oneField = stok.nextToken();
387
// returnValue.append(prefix);
388
// returnValue.append(oneField);
389
// }
390
//
391
// return returnValue.toString();
392
}
393         }
394
395         return "";
396     }
397
398     /**
399      * Retrieves whether the value is null
400      *
401      * @param fieldName the name of the field to check
402      * @return boolean true if it allows null
403      */

404     public boolean isAllowsNull(String JavaDoc fieldName) throws DBException {
405         String JavaDoc values[] = this.getObjectAndField(fieldName);
406         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
407         DataObjectMetaData metadata = oneObj.getMetaData();
408         return metadata.isAllowsNull(values[1]);
409     }
410
411
412     /**
413      * Removes the attribute specified by field name and attrib name
414      *
415      * @param fieldName the name of the field to modify
416      * @param attribName the attribute to remove
417      */

418     public void removeAttribute(String JavaDoc fieldName, String JavaDoc attribName) {
419         String JavaDoc values[] = this.getObjectAndField(fieldName);
420         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
421         DataObjectMetaData metadata = oneObj.getMetaData();
422         metadata.removeAttribute(values[1], attribName);
423     }
424
425     /**
426      * Sets the attribute for the particular field
427      *
428      * @param fieldName the name of the field to modify
429      * @param attribName the attribute to set
430      * @param attribValue the value to set the attribute for.
431      * @throws DBException upon error
432      */

433     public void setAttribute(String JavaDoc fieldName, String JavaDoc attribName, Object JavaDoc attribValue) throws DBException {
434         String JavaDoc values[] = this.getObjectAndField(fieldName);
435         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
436         DataObjectMetaData metadata = oneObj.getMetaData();
437         metadata.setAttribute(values[1], attribName, attribValue);
438     }
439
440     /**
441      * Retrieve the attribute for the field
442      *
443      * @param fieldName the field name to get the attribute for
444      * @param attribName the attribute name
445      * @return Object the attribute value. [May be null]
446      * @throws DBException upon error
447      */

448     public Object JavaDoc getAttribute(String JavaDoc fieldName, String JavaDoc attribName) throws DBException {
449         String JavaDoc values[] = this.getObjectAndField(fieldName);
450         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
451         DataObjectMetaData metadata = oneObj.getMetaData();
452         return metadata.getAttribute(values[1], attribName);
453     }
454
455     /**
456      * Disable change logging of all objects of this type
457      */

458     public void disableLogging() {
459         for (Iterator JavaDoc i = this.myDataObjects.keySet().iterator(); i.hasNext();) {
460             String JavaDoc key = (String JavaDoc) i.next();
461             DataObject value = (DataObject) myDataObjects.get(key);
462             value.getMetaData().disableLogging();
463         }
464     }
465
466     /**
467      * Enable logging of changes to this object. Change logging writes an entry to
468      * the ChangeLog object every time an add, update, or delete is made to this
469      * object. It is used to track important tables, such as user information,
470      * account information, etc.
471      */

472     public void enableLogging() {
473         for (Iterator JavaDoc i = this.myDataObjects.keySet().iterator(); i.hasNext();) {
474             String JavaDoc key = (String JavaDoc) i.next();
475             DataObject value = (DataObject) myDataObjects.get(key);
476             value.getMetaData().enableLogging();
477         }
478     }
479
480     /**
481      * Retrieves whether or not change logging is enabled for a particular
482      * data object
483      *
484      * @return boolean true if logging is enabled.
485      */

486     public boolean isLoggingEnabled() {
487         return this.getPrimaryDataObject().getMetaData().isLoggingEnabled();
488     }
489
490     /**
491      * Check if a certain name is a field (of any kind) in this DBOBject
492      * since SQL is case insensitive, ignore case of field name for match,
493      * this method takes longer, so use isField if the field name is known precisely
494      *
495      * @param fieldName the name of the field to check
496      * @return internal format for field name if matched, or null if no match
497      */

498     public String JavaDoc isFieldIgnoreCase(String JavaDoc fieldName) {
499         String JavaDoc values[] = this.getObjectAndField(fieldName);
500         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
501         DataObjectMetaData metadata = oneObj.getMetaData();
502         return metadata.isFieldIgnoreCase(values[1]);
503     }
504
505     /**
506      * Check if a certain name is a field (of any kind) in this DBOBject
507      *
508      * @param fieldName the name of the field to check
509      * @return true if the field name exists
510      */

511     public boolean isField(String JavaDoc fieldName) {
512         String JavaDoc values[] = this.getObjectAndField(fieldName);
513         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
514         DataObjectMetaData metadata = oneObj.getMetaData();
515         return metadata.isField(values[1]);
516     }
517
518
519     /**
520      * Return the "allFields" Hashtable, which contains all of the DBField objects
521      * that make up this DB object. The field names are of the format [objectalias].[fieldname]
522      * <p/>
523      * This does not return foreign fields that are keyed to local fields. They are automatically
524      * set whenever a foreign key in the local object is set.
525      *
526      * @return java.util.HashMap
527      */

528     public synchronized HashMap JavaDoc getAllFieldsMap() {
529         if (this.allFieldMap == null) {
530             for (Iterator JavaDoc i = this.myDataObjects.keySet().iterator(); i.hasNext();) {
531                 String JavaDoc key = (String JavaDoc) i.next();
532
533                 DataObject oneObj = (DataObject) myDataObjects.get(key);
534                 HashMap JavaDoc fieldMap = oneObj.getMetaData().getAllFieldsMap();
535                 for (Iterator JavaDoc j = fieldMap.keySet().iterator(); j.hasNext();) {
536                     String JavaDoc fieldName = (String JavaDoc) j.next();
537                     DataObjectMetaData metadata = (DataObjectMetaData) fieldMap.get(fieldName);
538                     String JavaDoc fullFieldName = key + "." + fieldName;
539                     if (this.foreignKeyToPrimaryKeyMap.containsKey(fullFieldName)) {
540                         continue;
541                     } else if (metadata.getFieldMetadata(fieldName).isCharacterLongObjectType()) {
542                         continue;
543                     } else {
544                         this.allFieldMap.put(key + "." + fieldName, metadata);
545                     }
546                 }
547
548             }
549         }
550
551         return this.allFieldMap;
552     }
553
554     /**
555      * Return the List containing the details of fields to retrieve
556      * for the DataObject with the given alias
557      *
558      * @param alias
559      * @return the list of FieldList objects with field details
560      */

561     public List JavaDoc getFieldsToRetrieve(String JavaDoc alias) {
562         return (List JavaDoc) this.fieldsToRetrieve.get(alias);
563     }
564
565     /**
566      * Return the "allKeys" hash, containing the DBField objects that make up
567      * the primary key for this db object.
568      *
569      * @return java.util.HashMap
570      */

571     public HashMap JavaDoc getAllKeysMap() {
572         return this.getPrimaryDataObject().getMetaData().getAllKeysMap();
573     }
574
575     /**
576      * return the current object's character set
577      *
578      * @return java.lang.String
579      */

580     public String JavaDoc getCharset() {
581         DataObject oneObj = this.getPrimaryDataObject();
582         return oneObj.getMetaData().getCharset();
583     }
584
585     /**
586      * Retrieves the cache size for the primary object
587      *
588      * @return int the size of the cache for the object
589      */

590     public int getCacheSize() {
591         DataObject oneObj = this.getPrimaryDataObject();
592         return oneObj.getMetaData().getCacheSize();
593     }
594
595
596     /**
597      * Sets the cache size for this DBObject
598      *
599      * @param newValue the new value. Must be >= -2
600      * @throws IllegalArgumentException if newValue < -2
601      */

602     public void setCacheSize(int newValue) {
603         DataObject oneObj = this.getPrimaryDataObject();
604         oneObj.getMetaData().setCacheSize(newValue);
605     }
606
607
608     /**
609      * Retrieve the description of the dataobject join
610      *
611      * @return java.lang.String
612      */

613     public String JavaDoc getDescription() {
614         return this.description;
615     }
616
617     /**
618      * Retrieve an i18n'ized description as per the locale defined for the
619      * 'client'
620      *
621      * @param l the Locale to use. If null, will use the System default Locale
622      * @param fieldName the name of the field to retrieve the i18n'ized description
623      * for.
624      * @return an i18n'ized string.
625      */

626     public String JavaDoc getDescription(java.util.Locale JavaDoc l, String JavaDoc fieldName) {
627         String JavaDoc values[] = this.getObjectAndField(fieldName);
628         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
629         DataObjectMetaData metadata = oneObj.getMetaData();
630         return metadata.getDescription(l, values[1]);
631     }
632
633     /**
634      * Get the unlocalized description for a field name
635      *
636      * @param fieldName name of the field
637      * @return java.lang.String
638      * @throws DBException upon error
639      */

640     public String JavaDoc getDescription(String JavaDoc fieldName) throws DBException {
641         String JavaDoc values[] = this.getObjectAndField(fieldName);
642         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
643         DataObjectMetaData metadata = oneObj.getMetaData();
644         return metadata.getDescription(values[1]);
645     }
646
647     /**
648      * Retrieve the metadata for the particular field
649      *
650      * @param fieldName the name of the field to retrieve the metadata
651      * @return the Field metadata.
652      */

653     public DataFieldMetaData getFieldMetadata(String JavaDoc fieldName) {
654         String JavaDoc values[] = this.getObjectAndField(fieldName);
655         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
656         DataObjectMetaData metadata = oneObj.getMetaData();
657         return metadata.getFieldMetadata(values[1]);
658     }
659
660
661     /**
662      * Retrieve a list of all the field names
663      *
664      * @return java.util.ArrayList
665      */

666     public synchronized ArrayList JavaDoc getFieldListArray() {
667
668         //
669
//Check if we need to build the all field list.
670
//
671
if (this.allFieldList == null) {
672             ArrayList JavaDoc newList = new ArrayList JavaDoc(10);
673             for (Iterator JavaDoc i = this.dataObjects.iterator(); i.hasNext();) {
674                 DataObject oneObj = (DataObject) i.next();
675                 ArrayList JavaDoc fieldList = oneObj.getMetaData().getFieldListArray();
676                 String JavaDoc dbobjName = null;
677
678                 //
679
//Find the key for this data object
680
//
681
for (Iterator JavaDoc k = this.myDataObjects.keySet().iterator(); k.hasNext();) {
682                     String JavaDoc key = (String JavaDoc) k.next();
683                     JDBCDataObject obj = (JDBCDataObject) myDataObjects.get(key);
684                     //
685
//We only want to check if it was the same instance we put
686
//on the map.. we don't care if the objects themselves are
687
//equal
688
//
689
if (oneObj == obj) {
690                         dbobjName = key;
691                         break;
692                     }
693                 }
694
695                 //
696
//
697
//
698
if (dbobjName == null) {
699                     throw new IllegalStateException JavaDoc("Unable to find short name for: "
700                             + oneObj.getClass().getName());
701                 }
702
703                 //
704
//Iterate through the fields and add them as long as it is a primary
705
//key in another field.
706
//
707
for (Iterator JavaDoc j = fieldList.iterator(); j.hasNext();) {
708                     String JavaDoc fieldName = (String JavaDoc) j.next();
709                     String JavaDoc completeFieldName = dbobjName + "." + fieldName;
710                     if (this.foreignKeyToPrimaryKeyMap.containsKey(completeFieldName)) {
711                         continue;
712                     } else if (oneObj.getMetaData().getFieldMetadata(fieldName).isCharacterLongObjectType()) {
713                         continue;
714                     } else {
715                         newList.add(completeFieldName);
716                     }
717                 }
718
719             }
720
721             this.allFieldList = newList;
722         }
723         return allFieldList;
724     }
725
726
727     /**
728      * Retrieves the key field list array... which in reality is the key fields
729      * of the primary data object
730      *
731      * @return java.util.ArrayList
732      */

733     public synchronized ArrayList JavaDoc getKeyFieldListArray() {
734         if (this.keyFieldList == null) {
735             keyFieldList = new ArrayList JavaDoc(this.getPrimaryDataObject().getMetaData().getKeyFieldListArray());
736             String JavaDoc primaryAlias = this.getPrimaryAlias();
737             for (int i = 0; i < keyFieldList.size(); i++) {
738                 keyFieldList.set(i, primaryAlias + "." + (String JavaDoc) keyFieldList.get(i));
739             }
740         }
741         return keyFieldList;
742     }
743
744
745     /**
746      * Return the length of a field
747      *
748      * @param fieldName The name of the field
749      * @return String: The length of the field
750      * @throws DBException If there is no such field in this object
751      */

752     public String JavaDoc getLength(String JavaDoc fieldName) throws DBException {
753         String JavaDoc values[] = this.getObjectAndField(fieldName);
754         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
755         DataObjectMetaData metadata = oneObj.getMetaData();
756         return metadata.getLength(values[1]);
757     }
758
759     /**
760      * Return the length of a field as an integer
761      *
762      * @param fieldName The name of the field
763      * @return integer: The length of the field
764      * @throws DBException If there is no such field in this object
765      */

766     public int getLengthInt(String JavaDoc fieldName) throws DBException {
767         String JavaDoc values[] = this.getObjectAndField(fieldName);
768         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
769         DataObjectMetaData metadata = oneObj.getMetaData();
770         return metadata.getLengthInt(values[1]);
771     }
772
773     /**
774      * Retrieve the precision of a particular field
775      *
776      * @param fieldName The name of the field
777      * @return integer for demcimal precision of the field
778      */

779     public int getPrecision(String JavaDoc fieldName) throws DBException {
780         String JavaDoc values[] = this.getObjectAndField(fieldName);
781         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
782         DataObjectMetaData metadata = oneObj.getMetaData();
783         return metadata.getPrecision(values[1]);
784     }
785
786     /**
787      * Get a field's lookup object - this is the name of another database
788      * object that can be used to look up valid values for this object. The lookup
789      * object for a field is set in the db objects setupFields method, and is used
790      * by the DBMaint servlet to provide automatic lookup links for fields.
791      *
792      * @param fieldName Field name to check
793      * @return String specifying the className of the lookup object
794      * @throws DBException If the specified field does not exist.
795      */

796     public String JavaDoc getLookupObject(String JavaDoc fieldName) throws DBException {
797         String JavaDoc values[] = this.getObjectAndField(fieldName);
798         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
799         DataObjectMetaData metadata = oneObj.getMetaData();
800         return metadata.getLookupObject(values[1]);
801     }
802
803     /**
804      * When you get a lookup object, to perform a complete mapping between the
805      * two, you need to know what field name in the remote object maps to this
806      * field.
807      *
808      * @param fieldName the name of the field to look up.
809      * @return java.lang.String or null if there is no lookup field
810      * @throws IllegalArgumentException if the field name does not exist
811      */

812     public String JavaDoc getLookupField(String JavaDoc fieldName) {
813         String JavaDoc values[] = this.getObjectAndField(fieldName);
814         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
815         DataObjectMetaData metadata = oneObj.getMetaData();
816         return metadata.getLookupField(values[1]);
817     }
818
819
820     /**
821      * Get the name of this object
822      *
823      * @return String The database object name, or the table name if none
824      * has been assigned
825      */

826     public String JavaDoc getName() {
827         return this.name;
828     }
829
830
831     /**
832      * Return the type of a field - this method returns the internal Expresso type
833      *
834      * @param fieldName The name of the field
835      * @return String: The type of the field
836      * @throws DBException If there is no such field in this object
837      */

838     public String JavaDoc getType(String JavaDoc fieldName) throws DBException {
839         String JavaDoc values[] = this.getObjectAndField(fieldName);
840         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
841         DataObjectMetaData metadata = oneObj.getMetaData();
842         return metadata.getType(values[1]);
843     }
844
845
846     /**
847      * This method will return a boolean true if the field is defined in the DBOBject,
848      * false otherwise.
849      * Creation date: (8/8/00 11:04:32 AM)
850      *
851      * @param fieldName java.lang.String
852      * @return boolean
853      */

854     public boolean hasField(String JavaDoc fieldName) {
855         String JavaDoc values[] = this.getObjectAndField(fieldName);
856         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
857         DataObjectMetaData metadata = oneObj.getMetaData();
858         return metadata.hasField(values[1]);
859     }
860
861
862     /**
863      * Method called to determine if a particular field is multi-valued,
864      * that is does it have a set of specific values and descriptions
865      *
866      * @param fieldName Name of the field
867      * @return boolean True if the field is multi-valued, false if not
868      * @throws DBException If there is no such field
869      */

870     public boolean isMultiValued(String JavaDoc fieldName) throws DBException {
871         String JavaDoc values[] = this.getObjectAndField(fieldName);
872         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
873         DataObjectMetaData metadata = oneObj.getMetaData();
874         return metadata.isMultiValued(values[1]);
875     }
876
877     /**
878      * Is a given field readOnly - these fields are not offered for entry
879      * when a form is produced by the generic database maintenance servlet
880      *
881      * @param fieldName name of the field to check
882      * @return true of the field is "read only", false if it is not
883      * @throws DBException Ff there is no such field
884      */

885     public boolean isReadOnly(String JavaDoc fieldName) throws DBException {
886         String JavaDoc values[] = this.getObjectAndField(fieldName);
887         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
888         DataObjectMetaData metadata = oneObj.getMetaData();
889         return metadata.isReadOnly(values[1]);
890     }
891
892     /**
893      * Is a given field 'secret' - these fields are not shown
894      * when a list is produced by the generic database maintenance servlet (DBMaint).
895      * This means that only users with update permission to the record can see the
896      * value of the specified field.
897      * <p/>
898      * see #setSecret(String)
899      *
900      * @param fieldName The name of the field to check
901      * @return True if the field is 'secret', false if it is not
902      * @throws DBException If there is no such field.
903      */

904     public boolean isSecret(String JavaDoc fieldName) throws DBException {
905         String JavaDoc values[] = this.getObjectAndField(fieldName);
906         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
907         DataObjectMetaData metadata = oneObj.getMetaData();
908         return metadata.isSecret(values[1]);
909     }
910
911     /**
912      * Is a given field virtual? A virtual field is not stored in the target table
913      * for this object - it may be computed, or stored in another table.
914      *
915      * @param fieldName The name of the field to check
916      * see #addVirtualField(String, String, int, String)
917      * @return True of the field is virtual, false if it is not
918      * @throws DBException If there is no such field
919      */

920     public boolean isVirtual(String JavaDoc fieldName) throws DBException {
921         String JavaDoc values[] = this.getObjectAndField(fieldName);
922         DataObject oneObj = (DataObject) myDataObjects.get(values[0]);
923         DataObjectMetaData metadata = oneObj.getMetaData();
924         return metadata.isVirtual(values[1]);
925     }
926
927     /**
928      * Turn on or off the facility to verify that when an update is made that at
929      * least one record got updated. If this flag is on, and no records get updated,
930      * the update() method throws an Exception. Note that for some databases, if the
931      * existing record is not changed (e.g. it was already identical to what
932      * was being updated) this counts "no update" (notably, mySQL does this).
933      *
934      * @param newFlag True to turn on checking, false to turn it off
935      */

936     public void setCheckZeroUpdate(boolean newFlag) {
937         for (Iterator JavaDoc i = this.myDataObjects.values().iterator(); i.hasNext();) {
938             DataObject oneObj = (DataObject) i.next();
939             oneObj.getMetaData().setCheckZeroUpdate(newFlag);
940         }
941     }
942
943     /**
944      * Retrieves whether or not checkZeroUpdate is enabled for this data object
945      *
946      * @return true if checkZeroUpdate() is enabled
947      */

948     public boolean checkZeroUpdate() {
949         return this.getPrimaryDataObject().getMetaData().checkZeroUpdate();
950     }
951
952     /**
953      * Sets the description for the data object join
954      *
955      * @param newDescription the description to set for the Join
956      */

957     public void setDescription(String JavaDoc newDescription) {
958         description = newDescription;
959     }
960
961
962     /**
963      * Sets the name for this joined data object metadata... in this case
964      * the definition name
965      *
966      * @param theName the name of the join [Usually =='s the definition]
967      */

968     public void setName(String JavaDoc theName) {
969         this.name = theName;
970     }
971
972
973     /**
974      * Retrieve the schema class name
975      *
976      * @return the schema class of for the join
977      */

978     public String JavaDoc getSchema() {
979         return this.getPrimaryDataObject().getMetaData().getSchema();
980     }
981
982     /**
983      * Return the Schema Name of the current database object.
984      *
985      * @return String: Schema name of the target table of this database object
986      * @throws DataException upon error
987      * <p/>
988      * author Yves Henri AMAIZO <amy_amaizo@compuserve.com>
989      */

990     public String JavaDoc getTargetDbSchema() {
991         return ((JDBCObjectMetaData) this.getPrimaryDataObject()
992                 .getMetaData()).getTargetDbSchema();
993     } /* getTargetDbSchema() */
994
995     /**
996      * Return the Schema Name of the current database object.
997      *
998      * @return String: Schema name of the target table of this database object
999      * @throws DataException upon error
1000     * <p/>
1001     * author Yves Henri AMAIZO <amy_amaizo@compuserve.com>
1002     */

1003    public String JavaDoc getTargetDbCatalog() {
1004        return ((JDBCObjectMetaData) this.getPrimaryDataObject()
1005                .getMetaData()).getTargetDbCatalog();
1006    } /* getTargetDbSchema() */
1007
1008    /**
1009     * Set the target table for this DBObject. Note that an object
1010     * can span tables by the use of virtual fields, but that this table
1011     * is the default table for the object.
1012     *
1013     * @param theTable Table for this object
1014     * @throws DBException author Yves Henri AMAIZO <amy_amaizo@compuserve.com>
1015     */

1016    public String JavaDoc getTargetSQLTable(String JavaDoc dataContext) throws DataException {
1017        return ((JDBCObjectMetaData) this.getPrimaryDataObject()
1018                .getMetaData()).getTargetSQLTable(this
1019                .getPrimaryDataObject().getDataContext());
1020    }
1021
1022    /**
1023     * <p>This convenience method iterates through all the
1024     * fields belonging to this <code>DBObject</code>
1025     * returns an array of field names ( <code>String</code> ).</p>
1026     *
1027     * @return String array of all field names in this object.
1028     * <p/>
1029     * author Peter Pilgrim <peter.pilgrim@db.com>
1030     */

1031    public String JavaDoc[] getFields() {
1032        ArrayList JavaDoc list = this.getFieldListArray();
1033
1034        String JavaDoc returnValue[] = new String JavaDoc[list.size()];
1035
1036        return (String JavaDoc[]) list.toArray(returnValue);
1037    }
1038
1039    /**
1040     * Retrieve the table description in a localized way. If l == null, the
1041     * function uses the system locale to generate the value. If unable to
1042     * locate the key in the message bundle, the key becomes the return value.
1043     *
1044     * @param l the Locale to use for rendering the table description
1045     * @return java.lang.String
1046     */

1047    public String JavaDoc getDescription(Locale JavaDoc l) {
1048        String JavaDoc key = this.getDescription();
1049
1050        if (key == null || key.length() == 0) {
1051            return "Unknown Table";
1052        }
1053
1054        if (l == null) {
1055            l = Locale.getDefault();
1056        }
1057
1058        String JavaDoc schema = this.getSchema();
1059        if (schema == null || schema.length() == 0) {
1060            schema = com.jcorporate.expresso.core.ExpressoSchema.class.getName();
1061        }
1062
1063        String JavaDoc returnValue;
1064        try {
1065            returnValue = Messages.getString(schema, l, key);
1066        } catch (IllegalArgumentException JavaDoc ex) {
1067            returnValue = key;
1068        }
1069
1070        return returnValue;
1071
1072    }
1073
1074    /**
1075     * Specify that the DISTINCT keyword for unique rows must be specified
1076     * right after the SELECT keyword
1077     *
1078     * @param flag true if DISTINCT supported right after SELECT, false
1079     * (default) otherwise.
1080     */

1081    public void setSelectDistinct(boolean flag) {
1082        selectDistinct = flag;
1083    }
1084
1085    /**
1086     * Retrieve all the attributes so you can iterate through them.
1087     *
1088     * @param fieldName the name of the field's attributes to retrieve
1089     * @return Set of all attributes
1090     */

1091    public java.util.Set JavaDoc getAllAttributes(String JavaDoc fieldName) {
1092        /**@todo Implement this com.jcorporate.expresso.core.dataobjects.DataObjectMetaData method*/
1093        throw new java.lang.UnsupportedOperationException JavaDoc("Method getTransitionsIterator() not yet implemented.");
1094    }
1095
1096    /**
1097     * Retrieve whether or not the Join should be distinct or not
1098     *
1099     * @return true if the join should be distinct.
1100     */

1101    public boolean isSelectDistinct() {
1102        return selectDistinct;
1103    }
1104
1105
1106    /**
1107     * Sets how the various dataobjects are connected, key-wise
1108     *
1109     * @param shortName java.lang.String the local short name
1110     * @param foreignKey java.lang.String the local key
1111     * @param shortName2 java.lang.String the foreign short name
1112     * @param primaryKey java.lang.String the foreign key
1113     * @param joinType the type of Join
1114     * @throws DBException upon error
1115     * <p/>
1116     * Modify by Yves Henri AMAIZO <amy_amaizo@compuserve.com>
1117     * @since $DatabaseSchema $Date: 2004/11/18 02:03:27 $
1118     */

1119    public void setForeignKey(String JavaDoc shortName, String JavaDoc foreignKey,
1120                              String JavaDoc shortName2, String JavaDoc primaryKey, int joinType) throws DBException {
1121        JDBCDataObject foreignDBObj = (JDBCDataObject) myDataObjects.get(shortName);
1122
1123        if (foreignDBObj == null) {
1124            throw new DBException("DB Object with short name '" +
1125                    shortName + "' is not part of this query");
1126        }
1127
1128        JDBCDataObject primaryDBObj = (JDBCDataObject) myDataObjects.get(shortName2);
1129
1130        if (primaryDBObj == null) {
1131            throw new DBException("DB Object with short name '" +
1132                    shortName2 + "' is not part of this query");
1133        }
1134
1135
1136        Relation r = new JoinedDataObjectMetaData.Relation();
1137        r.setLocalAlias(shortName);
1138        r.setLocalKey(foreignKey);
1139        r.setForeignAlias(shortName2);
1140        r.setForeignKey(primaryKey);
1141        r.setJoinType(joinType);
1142
1143        this.relations.put(shortName + "|" + shortName2, r);
1144
1145
1146        if (joinType == JoinedDataObject.UNSPECIFIED_JOIN) {
1147            sqlRelationList.add(foreignDBObj.getJDBCMetaData().getTargetSQLTable(foreignDBObj.getDataContext()) + "." + foreignKey +
1148                    " = " + primaryDBObj.getJDBCMetaData().getTargetSQLTable(foreignDBObj.getDataContext()) + "." +
1149                    primaryKey);
1150        }
1151
1152
1153        String JavaDoc localField = shortName + "." + foreignKey;
1154        String JavaDoc remoteField = shortName2 + "." + primaryKey;
1155
1156
1157        this.primaryToForeignKeyMap.put(remoteField, localField);
1158        this.foreignKeyToPrimaryKeyMap.put(localField, remoteField);
1159
1160    }
1161    /* setForeignKey(String, String, String, String) */
1162
1163    /**
1164     * Retrieve the relation bean for between two aliases
1165     *
1166     * @param aliaslocal the local alias
1167     * @param aliasJoined the foreign alias
1168     * @return JoinedDataObjectMetaData.Relation or null if the relation doesn't
1169     * exist.
1170     */

1171    public Relation getRelation(String JavaDoc aliaslocal, String JavaDoc aliasJoined) {
1172        return (Relation) relations.get(aliaslocal + "|" + aliasJoined);
1173    }
1174
1175    /**
1176     * Retrieve a list of all relations
1177     *
1178     * @return java.util.Map
1179     */

1180    public Map JavaDoc getAllRelations() {
1181        return Collections.unmodifiableMap(relations);
1182    }
1183
1184    /**
1185     * Retrieve a list of precalculated relations for the where clauses.
1186     *
1187     * @return java.util.List
1188     */

1189    public List JavaDoc getSQLRelationList() {
1190        return this.sqlRelationList;
1191    }
1192
1193
1194    /**
1195     * Creates a new copy of blank data objects for use in the main objects
1196     *
1197     * @return java.util.HashMap
1198     * @throws DataException upon construction error
1199     */

1200    public synchronized HashMap JavaDoc createNestedDataObjects() throws DataException {
1201        HashMap JavaDoc returnMap = new HashMap JavaDoc(this.myDataObjects.size());
1202
1203        for (Iterator JavaDoc i = myDataObjects.keySet().iterator(); i.hasNext();) {
1204            String JavaDoc key = (String JavaDoc) i.next();
1205            JDBCDataObject oneObj = (JDBCDataObject) myDataObjects.get(key);
1206
1207            try {
1208                JDBCDataObject newObj = (JDBCDataObject) oneObj.getClass().newInstance();
1209                if (newObj instanceof Defineable) {
1210                    ((Defineable) newObj).setDefinitionName(((Defineable) oneObj).getDefinitionName());
1211                }
1212                returnMap.put(key, newObj);
1213            } catch (InstantiationException JavaDoc ex) {
1214                throw new DataException("Unable to instantiate new Data Object", ex);
1215            } catch (IllegalAccessException JavaDoc ex) {
1216                throw new DataException("Target Class " + oneObj.getClass()
1217                        + " does not have a public default constructor");
1218            }
1219        }
1220
1221        return returnMap;
1222    }
1223
1224
1225    /**
1226     * Retrieve the short name of the primary data object. It is the primary
1227     * alias that we set the keys for to form the join.
1228     *
1229     * @return java.lang.String
1230     * @throws IllegalStateException if there are improperly described relations in
1231     * the metadata
1232     */

1233    public String JavaDoc getPrimaryAlias() {
1234        List JavaDoc l = this.getAliasesInOrder();
1235        if (l.size() == 0) {
1236            throw new IllegalArgumentException JavaDoc("No 'primary' alias defined!");
1237        }
1238
1239        return (String JavaDoc) l.get(0);
1240    }
1241
1242    /**
1243     * Retrieve the primary data object
1244     *
1245     * @return the primary data object
1246     */

1247    private JDBCDataObject getPrimaryDataObject() {
1248        String JavaDoc shortName = this.getPrimaryAlias();
1249        return (JDBCDataObject) this.myDataObjects.get(shortName);
1250    }
1251
1252    /**
1253     * Utility method Retrieve the object name and the field name
1254     *
1255     * @param fieldName the [dataobject].field
1256     * @return Array of Strings. String[0] = object alias String[1] = Object's Field Name
1257     */

1258    public final String JavaDoc[] getObjectAndField(String JavaDoc fieldName) {
1259        String JavaDoc returnValue[] = new String JavaDoc[2];
1260
1261        int dotPos = fieldName.indexOf(".");
1262        if (dotPos <= 0 || dotPos == (fieldName.length() - 1)) {
1263            throw new IllegalArgumentException JavaDoc("Field name must be of format [dataobject alias].[fieldname]");
1264        }
1265
1266        returnValue[0] = fieldName.substring(0, dotPos);
1267        DataObject oneObj = (DataObject) myDataObjects.get(returnValue[0]);
1268
1269        if (oneObj == null) {
1270            throw new IllegalArgumentException JavaDoc("Unable to locate dataobject: " + returnValue[0]);
1271        }
1272
1273        returnValue[1] = fieldName.substring(dotPos + 1);
1274        return returnValue;
1275    }
1276
1277    // getter methods for derived classes to retrieve
1278
protected Set JavaDoc getAllDetails() {
1279        return allDetails;
1280    }
1281
1282
1283    protected HashMap JavaDoc getForeignKeyToPrimaryKeyMap() {
1284        return foreignKeyToPrimaryKeyMap;
1285    }
1286
1287
1288    //retrieve the 'mydataobjects' table
1289
protected HashMap JavaDoc getMyDataObjects() {
1290        return myDataObjects;
1291    }
1292
1293    public Map JavaDoc getPermissions() {
1294        return Collections.unmodifiableMap(permissions);
1295    }
1296
1297    public void setPermissions(Map JavaDoc newPermissions) {
1298        permissions = new HashMap JavaDoc(newPermissions);
1299    }
1300
1301    protected HashMap JavaDoc getPrimaryToForeignKeyMap() {
1302        return primaryToForeignKeyMap;
1303    }
1304
1305    protected HashMap JavaDoc getRelations() {
1306        return relations;
1307    }
1308
1309    protected List JavaDoc getSqlRelationList() {
1310        return sqlRelationList;
1311    }
1312
1313    /**
1314     * Bean-like class for keeping track of relations
1315     *
1316     * @author Michael Rimov
1317     */

1318    public class Relation {
1319        private String JavaDoc localAlias;
1320        private String JavaDoc foreignAlias;
1321        private String JavaDoc localField;
1322        private String JavaDoc foreignField;
1323        private int joinType = JoinedDataObject.UNSPECIFIED_JOIN;
1324
1325        /**
1326         * Sets the local alias value
1327         *
1328         * @param newValue java.lang.String an alias name
1329         */

1330        public void setLocalAlias(String JavaDoc newValue) {
1331            this.localAlias = newValue;
1332        }
1333
1334        /**
1335         * Sets the foreign alias value
1336         *
1337         * @param newValue java.lang.String an alias name
1338         */

1339        public void setForeignAlias(String JavaDoc newValue) {
1340            this.foreignAlias = newValue;
1341        }
1342
1343        /**
1344         * Set the local key field name
1345         *
1346         * @param newValue java.lang.String
1347         */

1348        public void setLocalKey(String JavaDoc newValue) {
1349            this.localField = newValue;
1350        }
1351
1352        /**
1353         * Set the foreign key field
1354         *
1355         * @param newValue the new Key field name
1356         */

1357        public void setForeignKey(String JavaDoc newValue) {
1358            this.foreignField = newValue;
1359        }
1360
1361        public void setJoinType(int newValue) {
1362            this.joinType = newValue;
1363        }
1364
1365        /**
1366         * Retrieve the local alias
1367         *
1368         * @return the local alias
1369         */

1370        public String JavaDoc getLocalAlias() {
1371            return localAlias;
1372        }
1373
1374        /**
1375         * Retrieve the foreign alias
1376         *
1377         * @return java.lang.String
1378         */

1379        public String JavaDoc getForeignAlias() {
1380            return this.foreignAlias;
1381        }
1382
1383        /**
1384         * Retrieve the local field
1385         *
1386         * @return java.lang.String
1387         */

1388        public String JavaDoc getLocalField() {
1389            return this.localField;
1390        }
1391
1392        /**
1393         * Retrieve the foreign field
1394         *
1395         * @return java.lang.String
1396         */

1397        public String JavaDoc getForeignField() {
1398            return this.foreignField;
1399        }
1400
1401        public int getJoinType() {
1402            return joinType;
1403        }
1404
1405    }
1406
1407    /**
1408     * Bean-like class for keeping track of required fields
1409     *
1410     * @author Malcolm Wise
1411     */

1412    public class FieldList {
1413        private String JavaDoc fieldExpression;
1414        private String JavaDoc fieldName;
1415        private boolean isExpression;
1416
1417        public FieldList(String JavaDoc fieldExpression, String JavaDoc fieldName,
1418                         boolean isExpression) {
1419            this.fieldExpression = fieldExpression;
1420            this.fieldName = fieldName;
1421            this.isExpression = isExpression;
1422        }
1423
1424        public String JavaDoc getFieldExpression() {
1425            return fieldExpression;
1426        }
1427
1428        public String JavaDoc getFieldName() {
1429            return fieldName;
1430        }
1431
1432        public boolean isExpression() {
1433            return isExpression;
1434        }
1435
1436    }
1437
1438}
1439
Popular Tags