KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > ojb > OjbTagsHandler


1 package xdoclet.modules.ojb;
2
3 /* Copyright 2003-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 import java.util.*;
19
20 import xjavadoc.*;
21 import xdoclet.XDocletException;
22 import xdoclet.XDocletTagSupport;
23 import xdoclet.modules.ojb.constraints.*;
24 import xdoclet.modules.ojb.model.*;
25 import xdoclet.util.Translator;
26 import xdoclet.util.TypeConversionUtil;
27
28 /**
29  * Provides functions for the XDoclet template.
30  *
31  * @author <a HREF="mailto:tomdz@users.sourceforge.net">Thomas Dudziak (tomdz@users.sourceforge.net)</a>
32  * @xdoclet.taghandler namespace="Ojb"
33  */

34 public class OjbTagsHandler extends XDocletTagSupport
35 {
36     private static final String JavaDoc CONFIG_PARAM_CHECKS = "checks";
37     private static final String JavaDoc CONFIG_PARAM_VERBOSE = "verbose";
38     private static final String JavaDoc CONFIG_PARAM_DATABASENAME = "databaseName";
39
40     private static final String JavaDoc ATTRIBUTE_CLASS = "class";
41     private static final String JavaDoc ATTRIBUTE_CONSTANT = "constant";
42     private static final String JavaDoc ATTRIBUTE_DEFAULT = "default";
43     private static final String JavaDoc ATTRIBUTE_DEFAULT_RIGHT = "default-right";
44     private static final String JavaDoc ATTRIBUTE_LEVEL = "level";
45     private static final String JavaDoc ATTRIBUTE_NAME = "name";
46     private static final String JavaDoc ATTRIBUTE_TYPE = "type";
47     private static final String JavaDoc ATTRIBUTE_UNIQUE = "unique";
48     private static final String JavaDoc ATTRIBUTE_VALUE = "value";
49
50     private static final String JavaDoc LEVEL_CLASS = "class";
51     private static final String JavaDoc LEVEL_COLLECTION = "collection";
52     private static final String JavaDoc LEVEL_COLUMN = "column";
53     private static final String JavaDoc LEVEL_FIELD = "field";
54     private static final String JavaDoc LEVEL_FOREIGNKEY = "foreignkey";
55     private static final String JavaDoc LEVEL_INDEX = "index";
56     private static final String JavaDoc LEVEL_INDEX_DESC = "index-desc";
57     private static final String JavaDoc LEVEL_OBJECT_CACHE = "object-cache";
58     private static final String JavaDoc LEVEL_PROCEDURE = "procedure";
59     private static final String JavaDoc LEVEL_PROCEDURE_ARGUMENT = "procedure-argument";
60     private static final String JavaDoc LEVEL_REFERENCE = "reference";
61     private static final String JavaDoc LEVEL_TABLE = "table";
62     
63     /** The ojb model */
64     private ModelDef _model = new ModelDef();
65     /** The torque model */
66     private TorqueModelDef _torqueModel = null;
67     /** The current class definition */
68     private ClassDescriptorDef _curClassDef = null;
69     /** The current field definition */
70     private FieldDescriptorDef _curFieldDef = null;
71     /** The current reference definition */
72     private ReferenceDescriptorDef _curReferenceDef = null;
73     /** The current collection definition */
74     private CollectionDescriptorDef _curCollectionDef = null;
75     /** The current extending class of the current extent */
76     private ClassDescriptorDef _curExtent = null;
77     /** The current obejct cache definition */
78     private ObjectCacheDef _curObjectCacheDef = null;
79     /** The current index descriptor definition */
80     private IndexDescriptorDef _curIndexDescriptorDef = null;
81     /** The current procedure definition */
82     private ProcedureDef _curProcedureDef = null;
83     /** The current procedure argument definition */
84     private ProcedureArgumentDef _curProcedureArgumentDef = null;
85     /** The name of the current index column */
86     private String JavaDoc _curIndexColumn = null;
87     /** The current table definition */
88     private TableDef _curTableDef = null;
89     /** The current column definition */
90     private ColumnDef _curColumnDef = null;
91     /** The current foreignkey definition */
92     private ForeignkeyDef _curForeignkeyDef = null;
93     /** The current index definition */
94     private IndexDef _curIndexDef = null;
95     /** The name of the current attribute */
96     private String JavaDoc _curPairLeft = null;
97     /** The value of the current attribute */
98     private String JavaDoc _curPairRight = null;
99
100     //
101
// XDt methods
102
//
103

104     // Class-related
105

106     /**
107      * Sets the current class definition derived from the current class, and optionally some attributes.
108      *
109      * @param template The template
110      * @param attributes The attributes of the tag
111      * @exception XDocletException if an error occurs
112      * @doc.tag type="block"
113      * @doc.param name="accept-locks" optional="true" description="The accept locks setting" values="true,false"
114      * @doc.param name="attributes" optional="true" description="Attributes of the class as name-value pairs 'name=value',
115      * separated by commas"
116      * @doc.param name="determine-extents" optional="true" description="Whether to determine
117      * persistent direct sub types automatically" values="true,false"
118      * @doc.param name="documentation" optional="true" description="Documentation on the class"
119      * @doc.param name="factory-method" optional="true" description="Specifies a no-argument factory method that is
120      * used to create instances (not yet implemented !)"
121      * @doc.param name="factory-class" optional="true" description="Specifies a factory class to be used for creating
122      * objects of this class"
123      * @doc.param name="factory-method" optional="true" description="Specifies a static no-argument method in the factory class"
124      * @doc.param name="generate-repository-info" optional="true" description="Whether repository data should be
125      * generated for the class" values="true,false"
126      * @doc.param name="generate-table-info" optional="true" description="Whether table data should be
127      * generated for the class" values="true,false"
128      * @doc.param name="include-inherited" optional="true" description="Whether to include
129      * fields/references/collections of supertypes" values="true,false"
130      * @doc.param name="initialization-method" optional="true" description="Specifies a no-argument instance method that is
131      * called right after an instance has been read from the database"
132      * @doc.param name="isolation-level" optional="true" description="The isolation level setting"
133      * @doc.param name="proxy" optional="true" description="The proxy setting for this class"
134      * @doc.param name="proxy-prefetching-limit" optional="true" description="Specifies the amount of objects of
135      * objects of this class to prefetch in collections"
136      * @doc.param name="refresh" optional="true" description="Can be set to force OJB to refresh instances when
137      * loaded from the cache" values="true,false"
138      * @doc.param name="row-reader" optional="true" description="The row reader for the class"
139      * @doc.param name="schema" optional="true" description="The schema for the type"
140      * @doc.param name="table" optional="true" description="The table for the class"
141      * @doc.param name="table-documentation" optional="true" description="Documentation on the table"
142      */

143     public void processClass(String JavaDoc template, Properties attributes) throws XDocletException
144     {
145         if (!_model.hasClass(getCurrentClass().getQualifiedName()))
146         {
147             // we only want to output the log message once
148
LogHelper.debug(true, OjbTagsHandler.class, "processClass", "Type "+getCurrentClass().getQualifiedName());
149         }
150
151         ClassDescriptorDef classDef = ensureClassDef(getCurrentClass());
152         String JavaDoc attrName;
153
154         for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
155         {
156             attrName = (String JavaDoc)attrNames.nextElement();
157             classDef.setProperty(attrName, attributes.getProperty(attrName));
158         }
159         _curClassDef = classDef;
160         generate(template);
161         _curClassDef = null;
162     }
163
164     /**
165      * Processes the template for all class definitions.
166      *
167      * @param template The template
168      * @param attributes The attributes of the tag
169      * @exception XDocletException if an error occurs
170      * @doc.tag type="block"
171      */

172     public void forAllClassDefinitions(String JavaDoc template, Properties attributes) throws XDocletException
173     {
174         for (Iterator it = _model.getClasses(); it.hasNext(); )
175         {
176             _curClassDef = (ClassDescriptorDef)it.next();
177             generate(template);
178         }
179         _curClassDef = null;
180
181         LogHelper.debug(true, OjbTagsHandler.class, "forAllClassDefinitions", "Processed "+_model.getNumClasses()+" types");
182     }
183
184     /**
185      * Processes the original class rather than the current class definition.
186      *
187      * @param template The template
188      * @param attributes The attributes of the tag
189      * @exception XDocletException if an error occurs
190      * @doc.tag type="block"
191      */

192     public void originalClass(String JavaDoc template, Properties attributes) throws XDocletException
193     {
194         pushCurrentClass(_curClassDef.getOriginalClass());
195         generate(template);
196         popCurrentClass();
197     }
198
199     /**
200      * Processes all classes (flattens the hierarchy such that every class has declarations for all fields,
201      * references,collections that it will have in the descriptor) and applies modifications (removes ignored
202      * features, changes declarations).
203      *
204      * @return An empty string
205      * @doc.tag type="content"
206      */

207     public String JavaDoc prepare() throws XDocletException
208     {
209         String JavaDoc checkLevel = (String JavaDoc)getDocletContext().getConfigParam(CONFIG_PARAM_CHECKS);
210         ArrayList queue = new ArrayList();
211         ClassDescriptorDef classDef, baseDef;
212         XClass original;
213         boolean isFinished;
214
215         // determine inheritance relationships
216
for (Iterator it = _model.getClasses(); it.hasNext();)
217         {
218             classDef = (ClassDescriptorDef)it.next();
219             original = classDef.getOriginalClass();
220             isFinished = false;
221             queue.clear();
222             while (!isFinished)
223             {
224                 if (original == null)
225                 {
226                     isFinished = true;
227                     for (Iterator baseIt = queue.iterator(); baseIt.hasNext();)
228                     {
229                         original = (XClass)baseIt.next();
230                         baseDef = _model.getClass(original.getQualifiedName());
231                         baseIt.remove();
232                         if (baseDef != null)
233                         {
234                             classDef.addDirectBaseType(baseDef);
235                         }
236                         else
237                         {
238                             isFinished = false;
239                             break;
240                         }
241                     }
242                 }
243                 if (!isFinished)
244                 {
245                     if (original.getInterfaces() != null)
246                     {
247                         for (Iterator baseIt = original.getInterfaces().iterator(); baseIt.hasNext();)
248                         {
249                             queue.add(baseIt.next());
250                         }
251                     }
252                     if (original.getSuperclass() != null)
253                     {
254                         queue.add(original.getSuperclass());
255                     }
256                     original = null;
257                 }
258             }
259         }
260         try
261         {
262             _model.process();
263             _model.checkConstraints(checkLevel);
264         }
265         catch (ConstraintException ex)
266         {
267             throw new XDocletException(ex.getMessage());
268         }
269         return "";
270     }
271
272     // Extent-related
273

274     /**
275      * The <code>forAllSubClasses</code> method iterates through all sub types of the current type (classes if it is a
276      * class or classes and interfaces for an interface).
277      *
278      * @param template The template
279      * @param attributes The attributes of the tag
280      * @exception XDocletException if an error occurs
281      * @doc.tag type="block"
282      */

283     public void forAllSubClasses(String JavaDoc template, Properties attributes) throws XDocletException
284     {
285         ArrayList subTypes = new ArrayList();
286         XClass type = getCurrentClass();
287
288         addDirectSubTypes(type, subTypes);
289
290         int pos = 0;
291         ClassDescriptorDef classDef;
292
293         while (pos < subTypes.size())
294         {
295             type = (XClass)subTypes.get(pos);
296             classDef = _model.getClass(type.getQualifiedName());
297             if ((classDef != null) && classDef.hasProperty(PropertyHelper.OJB_PROPERTY_OJB_PERSISTENT))
298             {
299                 pos++;
300             }
301             else
302             {
303                 subTypes.remove(pos);
304                 addDirectSubTypes(type, subTypes);
305             }
306         }
307         for (Iterator it = subTypes.iterator(); it.hasNext(); )
308         {
309             pushCurrentClass((XClass)it.next());
310             generate(template);
311             popCurrentClass();
312         }
313     }
314
315     /**
316      * Adds an extent relation to the current class definition.
317      *
318      * @param attributes The attributes of the tag
319      * @return An empty string
320      * @exception XDocletException If an error occurs
321      * @doc.tag type="content"
322      * @doc.param name="name" optional="false" description="The fully qualified name of the extending
323      * class"
324      */

325     public String JavaDoc addExtent(Properties attributes) throws XDocletException
326     {
327         String JavaDoc name = attributes.getProperty(ATTRIBUTE_NAME);
328
329         if (!_model.hasClass(name))
330         {
331             throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
332                                        XDocletModulesOjbMessages.COULD_NOT_FIND_TYPE,
333                                        new String JavaDoc[]{name}));
334         }
335         _curClassDef.addExtentClass(_model.getClass(name));
336         return "";
337     }
338
339     /**
340      * Processes the template for all extents of the current class.
341      *
342      * @param template The template
343      * @param attributes The attributes of the tag
344      * @exception XDocletException if an error occurs
345      * @doc.tag type="block"
346      */

347     public void forAllExtents(String JavaDoc template, Properties attributes) throws XDocletException
348     {
349         for (Iterator it = _curClassDef.getExtentClasses(); it.hasNext(); )
350         {
351             _curExtent = (ClassDescriptorDef)it.next();
352             generate(template);
353         }
354         _curExtent = null;
355     }
356
357     /**
358      * Returns the qualified name of the current extent.
359      *
360      * @param attributes The attributes of the tag
361      * @return The qualified name of the extent class
362      * @exception XDocletException If an error occurs
363      * @doc.tag type="content"
364      */

365     public String JavaDoc extent(Properties attributes) throws XDocletException
366     {
367         return _curExtent.getName();
368     }
369
370     // Index-related
371

372     /**
373      * Processes an index descriptor tag.
374      *
375      * @param template The template
376      * @param attributes The attributes of the tag
377      * @exception XDocletException If an error occurs
378      * @doc.tag type="content"
379      * @doc.param name="documentation" optional="true" description="Documentation on the index"
380      * @doc.param name="fields" optional="false" description="The fields making up the index separated by commas"
381      * @doc.param name="name" optional="false" description="The name of the index descriptor"
382      * @doc.param name="unique" optional="true" description="Whether the index descriptor is unique" values="true,false"
383      */

384     public String JavaDoc processIndexDescriptor(Properties attributes) throws XDocletException
385     {
386         String JavaDoc name = attributes.getProperty(ATTRIBUTE_NAME);
387         IndexDescriptorDef indexDef = _curClassDef.getIndexDescriptor(name);
388         String JavaDoc attrName;
389         
390         if (indexDef == null)
391         {
392             indexDef = new IndexDescriptorDef(name);
393             _curClassDef.addIndexDescriptor(indexDef);
394         }
395
396         if ((indexDef.getName() == null) || (indexDef.getName().length() == 0))
397         {
398             throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
399                                        XDocletModulesOjbMessages.INDEX_NAME_MISSING,
400                                        new String JavaDoc[]{_curClassDef.getName()}));
401         }
402         attributes.remove(ATTRIBUTE_NAME);
403         for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
404         {
405             attrName = (String JavaDoc)attrNames.nextElement();
406             indexDef.setProperty(attrName, attributes.getProperty(attrName));
407         }
408         return "";
409     }
410
411     /**
412      * Processes the template for all index descriptors of the current class definition.
413      *
414      * @param template The template
415      * @param attributes The attributes of the tag
416      * @exception XDocletException if an error occurs
417      * @doc.tag type="block"
418      */

419     public void forAllIndexDescriptorDefinitions(String JavaDoc template, Properties attributes) throws XDocletException
420     {
421         for (Iterator it = _curClassDef.getIndexDescriptors(); it.hasNext(); )
422         {
423             _curIndexDescriptorDef = (IndexDescriptorDef)it.next();
424             generate(template);
425         }
426         _curIndexDescriptorDef = null;
427     }
428
429     /**
430      * Processes the template for all index columns for the current index descriptor.
431      *
432      * @param template The template
433      * @param attributes The attributes of the tag
434      * @exception XDocletException if an error occurs
435      * @doc.tag type="block"
436      */

437     public void forAllIndexDescriptorColumns(String JavaDoc template, Properties attributes) throws XDocletException
438     {
439         String JavaDoc fields = _curIndexDescriptorDef.getProperty(PropertyHelper.OJB_PROPERTY_FIELDS);
440         FieldDescriptorDef fieldDef;
441         String JavaDoc name;
442
443         for (CommaListIterator it = new CommaListIterator(fields); it.hasNext();)
444         {
445             name = it.getNext();
446             fieldDef = _curClassDef.getField(name);
447             if (fieldDef == null)
448             {
449                 throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
450                                            XDocletModulesOjbMessages.INDEX_FIELD_MISSING,
451                                            new String JavaDoc[]{name, _curIndexDescriptorDef.getName(), _curClassDef.getName()}));
452             }
453             _curIndexColumn = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN);
454             generate(template);
455         }
456         _curIndexColumn = null;
457     }
458
459     /**
460      * Returns the current index column.
461      *
462      * @param attributes The attributes of the tag
463      * @return The index column
464      * @exception XDocletException If an error occurs
465      * @doc.tag type="content"
466      */

467     public String JavaDoc indexColumn(Properties attributes) throws XDocletException
468     {
469         return _curIndexColumn;
470     }
471
472
473     // Object-cache related
474

475     /**
476      * Processes an object cache tag.
477      *
478      * @param template The template
479      * @param attributes The attributes of the tag
480      * @exception XDocletException If an error occurs
481      * @doc.tag type="content"
482      * @doc.param name="attributes" optional="true" description="Attributes of the object-cache as name-value pairs 'name=value',
483      * @doc.param name="class" optional="false" description="The object cache implementation"
484      * @doc.param name="documentation" optional="true" description="Documentation on the object cache"
485      */

486     public String JavaDoc processObjectCache(Properties attributes) throws XDocletException
487     {
488         ObjectCacheDef objCacheDef = _curClassDef.setObjectCache(attributes.getProperty(ATTRIBUTE_CLASS));
489         String JavaDoc attrName;
490
491         attributes.remove(ATTRIBUTE_CLASS);
492         for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
493         {
494             attrName = (String JavaDoc)attrNames.nextElement();
495             objCacheDef.setProperty(attrName, attributes.getProperty(attrName));
496         }
497         return "";
498     }
499
500     /**
501      * Processes the template for the object cache of the current class definition.
502      *
503      * @param template The template
504      * @param attributes The attributes of the tag
505      * @exception XDocletException if an error occurs
506      * @doc.tag type="block"
507      */

508     public void forObjectCache(String JavaDoc template, Properties attributes) throws XDocletException
509     {
510         _curObjectCacheDef = _curClassDef.getObjectCache();
511         if (_curObjectCacheDef != null)
512         {
513             generate(template);
514             _curObjectCacheDef = null;
515         }
516     }
517
518     // Procedure-related
519

520     /**
521      * Processes a procedure tag.
522      *
523      * @param template The template
524      * @param attributes The attributes of the tag
525      * @exception XDocletException If an error occurs
526      * @doc.tag type="content"
527      * @doc.param name="arguments" optional="true" description="The arguments of the procedure as a comma-separated
528      * list of names of procedure attribute tags"
529      * @doc.param name="attributes" optional="true" description="Attributes of the procedure as name-value pairs 'name=value',
530      * separated by commas"
531      * @doc.param name="documentation" optional="true" description="Documentation on the procedure"
532      * @doc.param name="include-all-fields" optional="true" description="For insert/update: whether all fields of the current
533      * class shall be included (arguments is ignored then)" values="true,false"
534      * @doc.param name="include-pk-only" optional="true" description="For delete: whether all primary key fields
535      * shall be included (arguments is ignored then)" values="true,false"
536      * @doc.param name="name" optional="false" description="The name of the procedure"
537      * @doc.param name="return-field-ref" optional="true" description="Identifies the field that receives the return value"
538      * @doc.param name="type" optional="false" description="The type of the procedure" values="delete,insert,update"
539      */

540     public String JavaDoc processProcedure(Properties attributes) throws XDocletException
541     {
542         String JavaDoc type = attributes.getProperty(ATTRIBUTE_TYPE);
543         ProcedureDef procDef = _curClassDef.getProcedure(type);
544         String JavaDoc attrName;
545
546         if (procDef == null)
547         {
548             procDef = new ProcedureDef(type);
549             _curClassDef.addProcedure(procDef);
550         }
551
552         for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
553         {
554             attrName = (String JavaDoc)attrNames.nextElement();
555             procDef.setProperty(attrName, attributes.getProperty(attrName));
556         }
557         return "";
558     }
559
560     /**
561      * Processes the template for all procedures of the current class definition.
562      *
563      * @param template The template
564      * @param attributes The attributes of the tag
565      * @exception XDocletException if an error occurs
566      * @doc.tag type="block"
567      */

568     public void forAllProcedures(String JavaDoc template, Properties attributes) throws XDocletException
569     {
570         for (Iterator it = _curClassDef.getProcedures(); it.hasNext(); )
571         {
572             _curProcedureDef = (ProcedureDef)it.next();
573             generate(template);
574         }
575         _curProcedureDef = null;
576     }
577
578     /**
579      * Processes a runtime procedure argument tag.
580      *
581      * @param template The template
582      * @param attributes The attributes of the tag
583      * @exception XDocletException If an error occurs
584      * @doc.tag type="content"
585      * @doc.param name="attributes" optional="true" description="Attributes of the procedure as name-value pairs 'name=value',
586      * separated by commas"
587      * @doc.param name="documentation" optional="true" description="Documentation on the procedure"
588      * @doc.param name="field-ref" optional="true" description="Identifies the field that provides the value
589      * if a runtime argument; if not set, then null is used"
590      * @doc.param name="name" optional="false" description="The identifier of the argument tag"
591      * @doc.param name="return" optional="true" description="Whether this is a return value (if a runtime argument)"
592      * values="true,false"
593      * @doc.param name="value" optional="false" description="The value if a constant argument"
594      */

595     public String JavaDoc processProcedureArgument(Properties attributes) throws XDocletException
596     {
597         String JavaDoc id = attributes.getProperty(ATTRIBUTE_NAME);
598         ProcedureArgumentDef argDef = _curClassDef.getProcedureArgument(id);
599         String JavaDoc attrName;
600         
601         if (argDef == null)
602         {
603             argDef = new ProcedureArgumentDef(id);
604             _curClassDef.addProcedureArgument(argDef);
605         }
606
607         attributes.remove(ATTRIBUTE_NAME);
608         for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
609         {
610             attrName = (String JavaDoc)attrNames.nextElement();
611             argDef.setProperty(attrName, attributes.getProperty(attrName));
612         }
613         return "";
614     }
615
616     /**
617      * Processes the template for all procedure arguments of the current procedure.
618      *
619      * @param template The template
620      * @param attributes The attributes of the tag
621      * @exception XDocletException if an error occurs
622      * @doc.tag type="block"
623      */

624     public void forAllProcedureArguments(String JavaDoc template, Properties attributes) throws XDocletException
625     {
626         String JavaDoc argNameList = _curProcedureDef.getProperty(PropertyHelper.OJB_PROPERTY_ARGUMENTS);
627
628         for (CommaListIterator it = new CommaListIterator(argNameList); it.hasNext();)
629         {
630             _curProcedureArgumentDef = _curClassDef.getProcedureArgument(it.getNext());
631             generate(template);
632         }
633         _curProcedureArgumentDef = null;
634     }
635
636     // Field-related
637

638     /**
639      * Processes an anonymous field definition specified at the class level.
640      *
641      * @param attributes The attributes of the tag
642      * @exception XDocletException if an error occurs
643      * @doc.tag type="content"
644      * @doc.param name="attributes" optional="true" description="Attributes of the field as name-value pairs 'name=value',
645      * separated by commas"
646      * @doc.param name="autoincrement" optional="true" description="Whether the field is
647      * auto-incremented" values="true,false"
648      * @doc.param name="column" optional="true" description="The column for the field"
649      * @doc.param name="conversion" optional="true" description="The fully qualified name of the
650      * conversion for the field"
651      * @doc.param name="default-fetch" optional="true" description="The default-fetch setting"
652      * values="true,false"
653      * @doc.param name="documentation" optional="true" description="Documentation on the field"
654      * @doc.param name="id" optional="true" description="The position of the field in the class
655      * descriptor"
656      * @doc.param name="indexed" optional="true" description="Whether the field is indexed"
657      * values="true,false"
658      * @doc.param name="jdbc-type" optional="true" description="The jdbc type of the column"
659      * @doc.param name="length" optional="true" description="The length of the column"
660      * @doc.param name="locking" optional="true" description="Whether the field supports locking"
661      * values="true,false"
662      * @doc.param name="name" optional="false" description="The name of the field"
663      * @doc.param name="nullable" optional="true" description="Whether the field is nullable"
664      * values="true,false"
665      * @doc.param name="precision" optional="true" description="The precision of the column"
666      * @doc.param name="primarykey" optional="true" description="Whether the field is a primarykey"
667      * values="true,false"
668      * @doc.param name="scale" optional="true" description="The scale of the column"
669      * @doc.param name="sequence-name" optional="true" description="The name of the sequence for
670      * incrementing the field"
671      * @doc.param name="table" optional="true" description="The table of the field (not implemented
672      * yet)"
673      * @doc.param name="update-lock" optional="true" description="Can be set to false if the persistent attribute is
674      * used for optimistic locking AND the dbms should update the lock column itself (default is true). Can only be set for
675      * TIMESTAMP and INTEGER columns" values="true,false"
676      */

677     public void processAnonymousField(Properties attributes) throws XDocletException
678     {
679         if (!attributes.containsKey(ATTRIBUTE_NAME))
680         {
681             throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
682                                        XDocletModulesOjbMessages.PARAMETER_IS_REQUIRED,
683                                        new String JavaDoc[]{ATTRIBUTE_NAME}));
684         }
685
686         String JavaDoc name = attributes.getProperty(ATTRIBUTE_NAME);
687         FieldDescriptorDef fieldDef = _curClassDef.getField(name);
688         String JavaDoc attrName;
689
690         if (fieldDef == null)
691         {
692             fieldDef = new FieldDescriptorDef(name);
693             _curClassDef.addField(fieldDef);
694         }
695         fieldDef.setAnonymous();
696         LogHelper.debug(false, OjbTagsHandler.class, "processAnonymousField", " Processing anonymous field "+fieldDef.getName());
697
698         attributes.remove(ATTRIBUTE_NAME);
699         for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
700         {
701             attrName = (String JavaDoc)attrNames.nextElement();
702             fieldDef.setProperty(attrName, attributes.getProperty(attrName));
703         }
704         fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_ACCESS, "anonymous");
705     }
706
707     /**
708      * Sets the current field definition derived from the current member, and optionally some attributes.
709      *
710      * @param template The template
711      * @param attributes The attributes of the tag
712      * @exception XDocletException if an error occurs
713      * @doc.tag type="block"
714      * @doc.param name="access" optional="true" description="The accessibility of the column" values="readonly,readwrite"
715      * @doc.param name="attributes" optional="true" description="Attributes of the field as name-value pairs 'name=value',
716      * separated by commas"
717      * @doc.param name="autoincrement" optional="true" description="Whether the field is
718      * auto-incremented" values="none,ojb,database"
719      * @doc.param name="column" optional="true" description="The column for the field"
720      * @doc.param name="column-documentation" optional="true" description="Documentation on the column"
721      * @doc.param name="conversion" optional="true" description="The fully qualified name of the
722      * conversion for the field"
723      * @doc.param name="default-fetch" optional="true" description="The default-fetch setting"
724      * values="true,false"
725      * @doc.param name="documentation" optional="true" description="Documentation on the field"
726      * @doc.param name="id" optional="true" description="The position of the field in the class
727      * descriptor"
728      * @doc.param name="indexed" optional="true" description="Whether the field is indexed"
729      * values="true,false"
730      * @doc.param name="jdbc-type" optional="true" description="The jdbc type of the column"
731      * @doc.param name="length" optional="true" description="The length of the column"
732      * @doc.param name="locking" optional="true" description="Whether the field supports locking"
733      * values="true,false"
734      * @doc.param name="nullable" optional="true" description="Whether the field is nullable"
735      * values="true,false"
736      * @doc.param name="precision" optional="true" description="The precision of the column"
737      * @doc.param name="primarykey" optional="true" description="Whether the field is a primarykey"
738      * values="true,false"
739      * @doc.param name="scale" optional="true" description="The scale of the column"
740      * @doc.param name="sequence-name" optional="true" description="The name of the sequence for
741      * incrementing the field"
742      * @doc.param name="table" optional="true" description="The table of the field (not implemented
743      * yet)"
744      * @doc.param name="update-lock" optional="true" description="Can be set to false if the persistent attribute is
745      * used for optimistic locking AND the dbms should update the lock column itself (default is true). Can only be set for
746      * TIMESTAMP and INTEGER columns" values="true,false"
747      */

748     public void processField(String JavaDoc template, Properties attributes) throws XDocletException
749     {
750         String JavaDoc name = OjbMemberTagsHandler.getMemberName();
751         String JavaDoc defaultType = getDefaultJdbcTypeForCurrentMember();
752         String JavaDoc defaultConversion = getDefaultJdbcConversionForCurrentMember();
753         FieldDescriptorDef fieldDef = _curClassDef.getField(name);
754         String JavaDoc attrName;
755
756         if (fieldDef == null)
757         {
758             fieldDef = new FieldDescriptorDef(name);
759             _curClassDef.addField(fieldDef);
760         }
761         LogHelper.debug(false, OjbTagsHandler.class, "processField", " Processing field "+fieldDef.getName());
762
763         for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
764         {
765             attrName = (String JavaDoc)attrNames.nextElement();
766             fieldDef.setProperty(attrName, attributes.getProperty(attrName));
767         }
768         // storing additional info for later use
769
fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_JAVA_TYPE,
770                              OjbMemberTagsHandler.getMemberType().getQualifiedName());
771         fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_JDBC_TYPE, defaultType);
772         if (defaultConversion != null)
773         {
774             fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CONVERSION, defaultConversion);
775         }
776
777         _curFieldDef = fieldDef;
778         generate(template);
779         _curFieldDef = null;
780     }
781
782     /**
783      * Processes the template for all field definitions of the current class definition (including inherited ones if
784      * required)
785      *
786      * @param template The template
787      * @param attributes The attributes of the tag
788      * @exception XDocletException if an error occurs
789      * @doc.tag type="block"
790      */

791     public void forAllFieldDefinitions(String JavaDoc template, Properties attributes) throws XDocletException
792     {
793         for (Iterator it = _curClassDef.getFields(); it.hasNext(); )
794         {
795             _curFieldDef = (FieldDescriptorDef)it.next();
796             if (!isFeatureIgnored(LEVEL_FIELD) &&
797                 !_curFieldDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
798             {
799                 generate(template);
800             }
801         }
802         _curFieldDef = null;
803     }
804
805     /**
806      * Returns the constraint (length or precision+scale) for the jdbc type of the current field.
807      *
808      * @param attributes The attributes of the tag
809      * @return The constraint of the field
810      * @exception XDocletException If an error occurs
811      * @doc.tag type="content"
812      */

813     public String JavaDoc fieldConstraint(Properties attributes) throws XDocletException
814     {
815         return _curFieldDef.getSizeConstraint();
816     }
817
818     // Reference-related
819

820     /**
821      * Processes an anonymous reference definition.
822      *
823      * @param attributes The attributes of the tag
824      * @exception XDocletException If an error occurs
825      * @doc.tag type="content"
826      * @doc.param name="attributes" optional="true" description="Attributes of the reference as name-value pairs 'name=value',
827      * separated by commas"
828      * @doc.param name="auto-delete" optional="true" description="Whether to automatically delete the
829      * referenced object on object deletion"
830      * @doc.param name="auto-retrieve" optional="true" description="Whether to automatically retrieve
831      * the referenced object"
832      * @doc.param name="auto-update" optional="true" description="Whether to automatically update the
833      * referenced object"
834      * @doc.param name="class-ref" optional="false" description="The fully qualified name of the class
835      * owning the referenced field"
836      * @doc.param name="documentation" optional="true" description="Documentation on the reference"
837      * @doc.param name="foreignkey" optional="true" description="The fields in the current type used for
838      * implementing the reference"
839      * @doc.param name="otm-dependent" optional="true" description="Whether the reference is dependent on otm"
840      * @doc.param name="proxy" optional="true" description="Whether to use a proxy for the reference"
841      * @doc.param name="proxy-prefetching-limit" optional="true" description="Specifies the amount of objects to prefetch"
842      * @doc.param name="refresh" optional="true" description="Whether to automatically refresh the
843      * reference"
844      * @doc.param name="remote-foreignkey" optional="true" description="The fields in the referenced type
845      * corresponding to the local fields (is only used for the table definition)"
846      */

847     public void processAnonymousReference(Properties attributes) throws XDocletException
848     {
849         ReferenceDescriptorDef refDef = _curClassDef.getReference("super");
850         String JavaDoc attrName;
851
852         if (refDef == null)
853         {
854             refDef = new ReferenceDescriptorDef("super");
855             _curClassDef.addReference(refDef);
856         }
857         refDef.setAnonymous();
858         LogHelper.debug(false, OjbTagsHandler.class, "processAnonymousReference", " Processing anonymous reference");
859
860         for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
861         {
862             attrName = (String JavaDoc)attrNames.nextElement();
863             refDef.setProperty(attrName, attributes.getProperty(attrName));
864         }
865     }
866
867     /**
868      * Sets the current reference definition derived from the current member, and optionally some attributes.
869      *
870      * @param template The template
871      * @param attributes The attributes of the tag
872      * @exception XDocletException If an error occurs
873      * @doc.tag type="block"
874      * @doc.param name="attributes" optional="true" description="Attributes of the reference as name-value pairs 'name=value',
875      * separated by commas"
876      * @doc.param name="auto-delete" optional="true" description="Whether to automatically delete the
877      * referenced object on object deletion"
878      * @doc.param name="auto-retrieve" optional="true" description="Whether to automatically retrieve
879      * the referenced object"
880      * @doc.param name="auto-update" optional="true" description="Whether to automatically update the
881      * referenced object"
882      * @doc.param name="class-ref" optional="true" description="The fully qualified name of the class
883      * owning the referenced field"
884      * @doc.param name="database-foreignkey" optional="true" description="Whether a database foreignkey shall be created"
885      * values="true,false"
886      * @doc.param name="documentation" optional="true" description="Documentation on the reference"
887      * @doc.param name="foreignkey" optional="true" description="The fields in the current type used for
888      * implementing the reference"
889      * @doc.param name="otm-dependent" optional="true" description="Whether the reference is dependent on otm"
890      * @doc.param name="proxy" optional="true" description="Whether to use a proxy for the reference"
891      * @doc.param name="proxy-prefetching-limit" optional="true" description="Specifies the amount of objects to prefetch"
892      * @doc.param name="refresh" optional="true" description="Whether to automatically refresh the
893      * reference"
894      * @doc.param name="remote-foreignkey" optional="true" description="The fields in the referenced type
895      * corresponding to the local fields (is only used for the table definition)"
896      */

897     public void processReference(String JavaDoc template, Properties attributes) throws XDocletException
898     {
899         String JavaDoc name = OjbMemberTagsHandler.getMemberName();
900         XClass type = OjbMemberTagsHandler.getMemberType();
901         int dim = OjbMemberTagsHandler.getMemberDimension();
902         ReferenceDescriptorDef refDef = _curClassDef.getReference(name);
903         String JavaDoc attrName;
904
905         if (refDef == null)
906         {
907             refDef = new ReferenceDescriptorDef(name);
908             _curClassDef.addReference(refDef);
909         }
910         LogHelper.debug(false, OjbTagsHandler.class, "processReference", " Processing reference "+refDef.getName());
911
912         for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
913         {
914             attrName = (String JavaDoc)attrNames.nextElement();
915             refDef.setProperty(attrName, attributes.getProperty(attrName));
916         }
917         // storing default info for later use
918
if (type == null)
919         {
920             throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
921                                        XDocletModulesOjbMessages.COULD_NOT_DETERMINE_TYPE_OF_MEMBER,
922                                        new String JavaDoc[]{name}));
923         }
924         if (dim > 0)
925         {
926             throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
927                                        XDocletModulesOjbMessages.MEMBER_CANNOT_BE_A_REFERENCE,
928                                        new String JavaDoc[]{name, _curClassDef.getName()}));
929         }
930
931         refDef.setProperty(PropertyHelper.OJB_PROPERTY_VARIABLE_TYPE, type.getQualifiedName());
932
933         // searching for default type
934
String JavaDoc typeName = searchForPersistentSubType(type);
935
936         if (typeName != null)
937         {
938             refDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CLASS_REF, typeName);
939         }
940
941         _curReferenceDef = refDef;
942         generate(template);
943         _curReferenceDef = null;
944     }
945
946     /**
947      * Processes the template for all reference definitions of the current class definition.
948      *
949      * @param template The template
950      * @param attributes The attributes of the tag
951      * @exception XDocletException if an error occurs
952      * @doc.tag type="block"
953      */

954     public void forAllReferenceDefinitions(String JavaDoc template, Properties attributes) throws XDocletException
955     {
956         for (Iterator it = _curClassDef.getReferences(); it.hasNext(); )
957         {
958             _curReferenceDef = (ReferenceDescriptorDef)it.next();
959             // first we check whether it is an inherited anonymous reference
960
if (_curReferenceDef.isAnonymous() && (_curReferenceDef.getOwner() != _curClassDef))
961             {
962                 continue;
963             }
964             if (!isFeatureIgnored(LEVEL_REFERENCE) &&
965                 !_curReferenceDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
966             {
967                 generate(template);
968             }
969         }
970         _curReferenceDef = null;
971     }
972
973     // Collection-related
974

975     /**
976      * Sets the current collection definition derived from the current member, and optionally some attributes.
977      *
978      * @param template The template
979      * @param attributes The attributes of the tag
980      * @exception XDocletException If an error occurs
981      * @doc.tag type="block"
982      * @doc.param name="attributes" optional="true" description="Attributes of the collection as name-value pairs 'name=value',
983      * separated by commas"
984      * @doc.param name="auto-delete" optional="true" description="Whether to automatically delete the
985      * collection on object deletion"
986      * @doc.param name="auto-retrieve" optional="true" description="Whether to automatically retrieve
987      * the collection"
988      * @doc.param name="auto-update" optional="true" description="Whether to automatically update the
989      * collection"
990      * @doc.param name="collection-class" optional="true" description="The type of the collection if not a
991      * java.util type or an array"
992      * @doc.param name="database-foreignkey" optional="true" description="Whether a database foreignkey shall be created"
993      * values="true,false"
994      * @doc.param name="documentation" optional="true" description="Documentation on the collection"
995      * @doc.param name="element-class-ref" optional="true" description="The fully qualified name of
996      * the element type"
997      * @doc.param name="foreignkey" optional="true" description="The name of the
998      * foreign keys (columns when an indirection table is given)"
999      * @doc.param name="foreignkey-documentation" optional="true" description="Documentation
1000     * on the foreign keys as a comma-separated list if using an indirection table"
1001     * @doc.param name="indirection-table" optional="true" description="The name of the indirection
1002     * table for m:n associations"
1003     * @doc.param name="indirection-table-documentation" optional="true" description="Documentation
1004     * on the indirection table"
1005     * @doc.param name="indirection-table-primarykeys" optional="true" description="Whether the
1006     * fields referencing the collection and element classes, should also be primarykeys"
1007     * @doc.param name="otm-dependent" optional="true" description="Whether the collection is dependent on otm"
1008     * @doc.param name="proxy" optional="true" description="Whether to use a proxy for the collection"
1009     * @doc.param name="proxy-prefetching-limit" optional="true" description="Specifies the amount of objects to prefetch"
1010     * @doc.param name="query-customizer" optional="true" description="The query customizer for this collection"
1011     * @doc.param name="query-customizer-attributes" optional="true" description="Attributes for the query customizer"
1012     * @doc.param name="refresh" optional="true" description="Whether to automatically refresh the
1013     * collection"
1014     * @doc.param name="remote-foreignkey" optional="true" description="The name of the
1015     * foreign key columns pointing to the elements if using an indirection table"
1016     * @doc.param name="remote-foreignkey-documentation" optional="true" description="Documentation
1017     * on the remote foreign keys as a comma-separated list if using an indirection table"
1018     */

1019    public void processCollection(String JavaDoc template, Properties attributes) throws XDocletException
1020    {
1021        String JavaDoc name = OjbMemberTagsHandler.getMemberName();
1022        CollectionDescriptorDef collDef = _curClassDef.getCollection(name);
1023        String JavaDoc attrName;
1024
1025        if (collDef == null)
1026        {
1027            collDef = new CollectionDescriptorDef(name);
1028            _curClassDef.addCollection(collDef);
1029        }
1030        LogHelper.debug(false, OjbTagsHandler.class, "processCollection", " Processing collection "+collDef.getName());
1031
1032        for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
1033        {
1034            attrName = (String JavaDoc)attrNames.nextElement();
1035            collDef.setProperty(attrName, attributes.getProperty(attrName));
1036        }
1037        if (OjbMemberTagsHandler.getMemberDimension() > 0)
1038        {
1039            // we store the array-element type for later use
1040
collDef.setProperty(PropertyHelper.OJB_PROPERTY_ARRAY_ELEMENT_CLASS_REF,
1041                                OjbMemberTagsHandler.getMemberType().getQualifiedName());
1042        }
1043        else
1044        {
1045            collDef.setProperty(PropertyHelper.OJB_PROPERTY_VARIABLE_TYPE,
1046                                OjbMemberTagsHandler.getMemberType().getQualifiedName());
1047        }
1048
1049        _curCollectionDef = collDef;
1050        generate(template);
1051        _curCollectionDef = null;
1052    }
1053
1054    /**
1055     * Processes the template for all collection definitions of the current class definition.
1056     *
1057     * @param template The template
1058     * @param attributes The attributes of the tag
1059     * @exception XDocletException if an error occurs
1060     * @doc.tag type="block"
1061     */

1062    public void forAllCollectionDefinitions(String JavaDoc template, Properties attributes) throws XDocletException
1063    {
1064        for (Iterator it = _curClassDef.getCollections(); it.hasNext(); )
1065        {
1066            _curCollectionDef = (CollectionDescriptorDef)it.next();
1067            if (!isFeatureIgnored(LEVEL_COLLECTION) &&
1068                !_curCollectionDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
1069            {
1070                generate(template);
1071            }
1072        }
1073        _curCollectionDef = null;
1074    }
1075
1076    /**
1077     * Addes the current member as a nested object.
1078     *
1079     * @param template The template
1080     * @param attributes The attributes of the tag
1081     * @exception XDocletException If an error occurs
1082     * @doc.tag type="content"
1083     */

1084    public String JavaDoc processNested(Properties attributes) throws XDocletException
1085    {
1086        String JavaDoc name = OjbMemberTagsHandler.getMemberName();
1087        XClass type = OjbMemberTagsHandler.getMemberType();
1088        int dim = OjbMemberTagsHandler.getMemberDimension();
1089        NestedDef nestedDef = _curClassDef.getNested(name);
1090
1091        if (type == null)
1092        {
1093            throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
1094                                          XDocletModulesOjbMessages.COULD_NOT_DETERMINE_TYPE_OF_MEMBER,
1095                                          new String JavaDoc[]{name}));
1096        }
1097        if (dim > 0)
1098        {
1099            throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
1100                                          XDocletModulesOjbMessages.MEMBER_CANNOT_BE_NESTED,
1101                                          new String JavaDoc[]{name, _curClassDef.getName()}));
1102        }
1103
1104        ClassDescriptorDef nestedTypeDef = _model.getClass(type.getQualifiedName());
1105
1106        if (nestedTypeDef == null)
1107        {
1108            throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class,
1109                                          XDocletModulesOjbMessages.COULD_NOT_DETERMINE_TYPE_OF_MEMBER,
1110                                          new String JavaDoc[]{name}));
1111        }
1112        if (nestedDef == null)
1113        {
1114            nestedDef = new NestedDef(name, nestedTypeDef);
1115            _curClassDef.addNested(nestedDef);
1116        }
1117        LogHelper.debug(false, OjbTagsHandler.class, "processNested", " Processing nested object "+nestedDef.getName()+" of type "+nestedTypeDef.getName());
1118
1119        String JavaDoc attrName;
1120        
1121        for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); )
1122        {
1123            attrName = (String JavaDoc)attrNames.nextElement();
1124            nestedDef.setProperty(attrName, attributes.getProperty(attrName));
1125        }
1126        return "";
1127    }
1128    
1129    // Modifications
1130

1131    /**
1132     * Processes a modification tag containing changes to properties of an inherited field/reference/collection.
1133     *
1134     * @param template The template
1135     * @param attributes The attributes of the tag
1136     * @exception XDocletException If an error occurs
1137     * @doc.tag type="content"
1138     * @doc.param name="attributes" optional="true" description="Attributes of the field as name-value pairs 'name=value',
1139     * separated by commas"
1140     * @doc.param name="autoincrement" optional="true" description="Whether the field is
1141     * auto-incremented" values="true,false"
1142     * @doc.param name="auto-delete" optional="true" description="Whether to automatically delete the
1143     * referenced object/the collection on object deletion"
1144     * @doc.param name="auto-retrieve" optional="true" description="Whether to automatically retrieve
1145     * the referenced object/the collection"
1146     * @doc.param name="auto-update" optional="true" description="Whether to automatically update the
1147     * referenced object/the collection"
1148     * @doc.param name="class-ref" optional="true" description="The fully qualified name of the class
1149     * owning the referenced field"
1150     * @doc.param name="collection-class" optional="true" description="The type of the collection if not a
1151     * java.util type or an array"
1152     * @doc.param name="column" optional="true" description="The column for the field"
1153     * @doc.param name="column-documentation" optional="true" description="Documentation on the column"
1154     * @doc.param name="conversion" optional="true" description="The fully qualified name of the
1155     * conversion for the field"
1156     * @doc.param name="database-foreignkey" optional="true" description="Whether a database foreignkey shall be created"
1157     * values="true,false"
1158     * @doc.param name="default-fetch" optional="true" description="The default-fetch setting"
1159     * values="true,false"
1160     * @doc.param name="documentation" optional="true" description="Documentation on the field"
1161     * @doc.param name="element-class-ref" optional="true" description="The fully qualified name of
1162     * the element type"
1163     * @doc.param name="foreignkey" optional="true" description="The name of the
1164     * foreign key (a column when an indirection table is given)"
1165     * @doc.param name="id" optional="true" description="The position of the field in the class
1166     * descriptor"
1167     * @doc.param name="ignore" optional="true" description="Whether the feature shall be ignored"
1168     * values="true,false"
1169     * @doc.param name="indexed" optional="true" description="Whether the field is indexed"
1170     * values="true,false"
1171     * @doc.param name="jdbc-type" optional="true" description="The jdbc type of the column"
1172     * @doc.param name="length" optional="true" description="The length of the column"
1173     * @doc.param name="locking" optional="true" description="Whether the field supports locking"
1174     * values="true,false"
1175     * @doc.param name="name" optional="false" description="The name of the inherited field, reference or collection"
1176     * @doc.param name="nullable" optional="true" description="Whether the field is nullable"
1177     * values="true,false"
1178     * @doc.param name="precision" optional="true" description="The precision of the column"
1179     * @doc.param name="primarykey" optional="true" description="Whether the field is a primarykey"
1180     * values="true,false"
1181     * @doc.param name="proxy" optional="true" description="Whether to use a proxy for the reference/collection"
1182     * @doc.param name="query-customizer" optional="true" description="The query customizer for the collection"
1183     * @doc.param name="query-customizer-attributes" optional="true" description="Attributes for the query customizer for the collection"
1184     * @doc.param name="refresh" optional="true" description="Whether to automatically refresh the
1185     * reference/collection"
1186     * @doc.param name="scale" optional="true" description="The scale of the column"
1187     * @doc.param name="sequence-name" optional="true" description="The name of the sequence for
1188     * incrementing the field"
1189     * @doc.param name="table" optional="true" description="The table of the field (not implemented
1190     * yet)"
1191     */

1192    public String JavaDoc processModification(Properties attributes) throws XDocletException
1193    {
1194        String JavaDoc name = attributes.getProperty(ATTRIBUTE_NAME);
1195        Properties mods = _curClassDef.getModification(name);
1196        String JavaDoc key;
1197        String JavaDoc value;
1198
1199        if (mods == null)
1200        {
1201            mods = new Properties();
1202            _curClassDef.addModification(name, mods);
1203        }
1204
1205        attributes.remove(ATTRIBUTE_NAME);
1206        for (Enumeration en = attributes.keys(); en.hasMoreElements();)
1207        {
1208            key = (String JavaDoc)en.nextElement();
1209            value = attributes.getProperty(key);
1210            mods.setProperty(key, value);
1211        }
1212        return "";
1213    }
1214
1215    /**
1216     * Processes a modification tag containing changes to properties of an nested field/reference/collection.
1217     *
1218     * @param template The template
1219     * @param attributes The attributes of the tag
1220     * @exception XDocletException If an error occurs
1221     * @doc.tag type="content"
1222     * @doc.param name="attributes" optional="true" description="Attributes of the field as name-value pairs 'name=value',
1223     * separated by commas"
1224     * @doc.param name="autoincrement" optional="true" description="Whether the field is
1225     * auto-incremented" values="true,false"
1226     * @doc.param name="auto-delete" optional="true" description="Whether to automatically delete the
1227     * referenced object/the collection on object deletion"
1228     * @doc.param name="auto-retrieve" optional="true" description="Whether to automatically retrieve
1229     * the referenced object/the collection"
1230     * @doc.param name="auto-update" optional="true" description="Whether to automatically update the
1231     * referenced object/the collection"
1232     * @doc.param name="class-ref" optional="true" description="The fully qualified name of the class
1233     * owning the referenced field"
1234     * @doc.param name="collection-class" optional="true" description="The type of the collection if not a
1235     * java.util type or an array"
1236     * @doc.param name="column" optional="true" description="The column for the field"
1237     * @doc.param name="column-documentation" optional="true" description="Documentation on the column"
1238     * @doc.param name="conversion" optional="true" description="The fully qualified name of the
1239     * conversion for the field"
1240     * @doc.param name="database-foreignkey" optional="true" description="Whether a database foreignkey shall be created"
1241     * values="true,false"
1242     * @doc.param name="default-fetch" optional="true" description="The default-fetch setting"
1243     * values="true,false"
1244     * @doc.param name="documentation" optional="true" description="Documentation on the field"
1245     * @doc.param name="element-class-ref" optional="true" description="The fully qualified name of
1246     * the element type"
1247     * @doc.param name="foreignkey" optional="true" description="The name of the
1248     * foreign key (a column when an indirection table is given)"
1249     * @doc.param name="id" optional="true" description="The position of the field in the class
1250     * descriptor"
1251     * @doc.param name="ignore" optional="true" description="Whether the feature shall be ignored"
1252     * values="true,false"
1253     * @doc.param name="indexed" optional="true" description="Whether the field is indexed"
1254     * values="true,false"
1255     * @doc.param name="jdbc-type" optional="true" description="The jdbc type of the column"
1256     * @doc.param name="length" optional="true" description="The length of the column"
1257     * @doc.param name="locking" optional="true" description="Whether the field supports locking"
1258     * values="true,false"
1259     * @doc.param name="name" optional="false" description="The name of the inherited field, reference or collection"
1260     * @doc.param name="nullable" optional="true" description="Whether the field is nullable"
1261     * values="true,false"
1262     * @doc.param name="precision" optional="true" description="The precision of the column"
1263     * @doc.param name="primarykey" optional="true" description="Whether the field is a primarykey"
1264     * values="true,false"
1265     * @doc.param name="proxy" optional="true" description="Whether to use a proxy for the reference/collection"
1266     * @doc.param name="query-customizer" optional="true" description="The query customizer for the collection"
1267     * @doc.param name="query-customizer-attributes" optional="true" description="Attributes for the query customizer for the collection"
1268     * @doc.param name="refresh" optional="true" description="Whether to automatically refresh the
1269     * reference/collection"
1270     * @doc.param name="scale" optional="true" description="The scale of the column"
1271     * @doc.param name="sequence-name" optional="true" description="The name of the sequence for
1272     * incrementing the field"
1273     * @doc.param name="table" optional="true" description="The table of the field (not implemented
1274     * yet)"
1275     */

1276    public String JavaDoc processNestedModification(Properties attributes) throws XDocletException
1277    {
1278        String JavaDoc prefix = OjbMemberTagsHandler.getMemberName() + "::";
1279        String JavaDoc name = prefix + attributes.getProperty(ATTRIBUTE_NAME);
1280        Properties mods = _curClassDef.getModification(name);
1281        String JavaDoc key;
1282        String JavaDoc value;
1283
1284        if (mods == null)
1285        {
1286            mods = new Properties();
1287            _curClassDef.addModification(name, mods);
1288        }
1289
1290        attributes.remove(ATTRIBUTE_NAME);
1291        for (Enumeration en = attributes.keys(); en.hasMoreElements();)
1292        {
1293            key = (String JavaDoc)en.nextElement();
1294            value = attributes.getProperty(key);
1295            mods.setProperty(key, value);
1296        }
1297        return "";
1298    }
1299
1300    // Table related
1301

1302    /**
1303     * Generates a torque schema for the model.
1304     *
1305     * @param attributes The attributes of the tag
1306     * @return The property value
1307     * @exception XDocletException If an error occurs
1308     * @doc.tag type="content"
1309     */

1310    public String JavaDoc createTorqueSchema(Properties attributes) throws XDocletException
1311    {
1312        String JavaDoc dbName = (String JavaDoc)getDocletContext().getConfigParam(CONFIG_PARAM_DATABASENAME);
1313
1314        _torqueModel = new TorqueModelDef(dbName, _model);
1315        return "";
1316    }
1317
1318    /**
1319     * Processes the template for all table definitions in the torque model.
1320     *
1321     * @param template The template
1322     * @param attributes The attributes of the tag
1323     * @exception XDocletException if an error occurs
1324     * @doc.tag type="block"
1325     */

1326    public void forAllTables(String JavaDoc template, Properties attributes) throws XDocletException
1327    {
1328        for (Iterator it = _torqueModel.getTables(); it.hasNext(); )
1329        {
1330            _curTableDef = (TableDef)it.next();
1331            generate(template);
1332        }
1333        _curTableDef = null;
1334    }
1335
1336    /**
1337     * Processes the template for all column definitions of the current table.
1338     *
1339     * @param template The template
1340     * @param attributes The attributes of the tag
1341     * @exception XDocletException if an error occurs
1342     * @doc.tag type="block"
1343     */

1344    public void forAllColumns(String JavaDoc template, Properties attributes) throws XDocletException
1345    {
1346        for (Iterator it = _curTableDef.getColumns(); it.hasNext(); )
1347        {
1348            _curColumnDef = (ColumnDef)it.next();
1349            generate(template);
1350        }
1351        _curColumnDef = null;
1352    }
1353
1354    /**
1355     * Processes the template for all foreignkeys of the current table.
1356     *
1357     * @param template The template
1358     * @param attributes The attributes of the tag
1359     * @exception XDocletException if an error occurs
1360     * @doc.tag type="block"
1361     */

1362    public void forAllForeignkeys(String JavaDoc template, Properties attributes) throws XDocletException
1363    {
1364        for (Iterator it = _curTableDef.getForeignkeys(); it.hasNext(); )
1365        {
1366            _curForeignkeyDef = (ForeignkeyDef)it.next();
1367            generate(template);
1368        }
1369        _curForeignkeyDef = null;
1370    }
1371
1372    /**
1373     * Processes the template for all column pairs of the current foreignkey.
1374     *
1375     * @param template The template
1376     * @param attributes The attributes of the tag
1377     * @exception XDocletException if an error occurs
1378     * @doc.tag type="block"
1379     */

1380    public void forAllForeignkeyColumnPairs(String JavaDoc template, Properties attributes) throws XDocletException
1381    {
1382        for (int idx = 0; idx < _curForeignkeyDef.getNumColumnPairs(); idx++)
1383        {
1384            _curPairLeft = _curForeignkeyDef.getLocalColumn(idx);
1385            _curPairRight = _curForeignkeyDef.getRemoteColumn(idx);
1386            generate(template);
1387        }
1388        _curPairLeft = null;
1389        _curPairRight = null;
1390    }
1391
1392    /**
1393     * Processes the template for all indices of the current table.
1394     *
1395     * @param template The template
1396     * @param attributes The attributes of the tag
1397     * @exception XDocletException if an error occurs
1398     * @doc.tag type="block"
1399     * @doc.param name="unique" optional="true" description="Whether to process the unique indices or not"
1400     * values="true,false"
1401     */

1402    public void forAllIndices(String JavaDoc template, Properties attributes) throws XDocletException
1403    {
1404        boolean processUnique = TypeConversionUtil.stringToBoolean(attributes.getProperty(ATTRIBUTE_UNIQUE), false);
1405
1406        // first the default index
1407
_curIndexDef = _curTableDef.getIndex(null);
1408        if ((_curIndexDef != null) && (processUnique == _curIndexDef.isUnique()))
1409        {
1410            generate(template);
1411        }
1412        for (Iterator it = _curTableDef.getIndices(); it.hasNext(); )
1413        {
1414            _curIndexDef = (IndexDef)it.next();
1415            if (!_curIndexDef.isDefault() && (processUnique == _curIndexDef.isUnique()))
1416            {
1417                generate(template);
1418            }
1419        }
1420        _curIndexDef = null;
1421    }
1422
1423    /**
1424     * Processes the template for all columns of the current table index.
1425     *
1426     * @param template The template
1427     * @param attributes The attributes of the tag
1428     * @exception XDocletException if an error occurs
1429     * @doc.tag type="block"
1430     */

1431    public void forAllIndexColumns(String JavaDoc template, Properties attributes) throws XDocletException
1432    {
1433        for (Iterator it = _curIndexDef.getColumns(); it.hasNext(); )
1434        {
1435            _curColumnDef = _curTableDef.getColumn((String JavaDoc)it.next());
1436            generate(template);
1437        }
1438        _curColumnDef = null;
1439    }
1440
1441    // Other
1442

1443    /**
1444     * Returns the name of the current object on the specified level.
1445     *
1446     * @param attributes The attributes of the tag
1447     * @return The property value
1448     * @exception XDocletException If an error occurs
1449     * @doc.tag type="content"
1450     * @doc.param name="level" optional="false" description="The level for the current object"
1451     * values="class,field,reference,collection"
1452     */

1453    public String JavaDoc name(Properties attributes) throws XDocletException
1454    {
1455        return getDefForLevel(attributes.getProperty(ATTRIBUTE_LEVEL)).getName();
1456    }
1457
1458    /**
1459     * Processes the template if the current object on the specified level has a non-empty name.
1460     *
1461     * @param attributes The attributes of the tag
1462     * @return The property value
1463     * @exception XDocletException If an error occurs
1464     * @doc.tag type="block"
1465     * @doc.param name="level" optional="false" description="The level for the current object"
1466     * values="class,field,reference,collection"
1467     */

1468    public void ifHasName(String JavaDoc template, Properties attributes) throws XDocletException
1469    {
1470        String JavaDoc name = getDefForLevel(attributes.getProperty(ATTRIBUTE_LEVEL)).getName();
1471
1472        if ((name != null) && (name.length() > 0))
1473        {
1474            generate(template);
1475        }
1476    }
1477
1478    /**
1479     * Determines whether the current object on the specified level has a specific property, and if so, processes the
1480     * template
1481     *
1482     * @param template The template
1483     * @param attributes The attributes of the tag
1484     * @exception XDocletException If an error occurs
1485     * @doc.tag type="block"
1486     * @doc.param name="level" optional="false" description="The level for the current object"
1487     * values="class,field,reference,collection"
1488     * @doc.param name="name" optional="false" description="The name of the property"
1489     */

1490    public void ifHasProperty(String JavaDoc template, Properties attributes) throws XDocletException
1491    {
1492        String JavaDoc value = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), attributes.getProperty(ATTRIBUTE_NAME));
1493
1494        if (value != null)
1495        {
1496            generate(template);
1497        }
1498    }
1499
1500    /**
1501     * Determines whether the current object on the specified level does not have a specific property, and if so,
1502     * processes the template
1503     *
1504     * @param template The template
1505     * @param attributes The attributes of the tag
1506     * @exception XDocletException If an error occurs
1507     * @doc.tag type="block"
1508     * @doc.param name="level" optional="false" description="The level for the current object"
1509     * values="class,field,reference,collection"
1510     * @doc.param name="name" optional="false" description="The name of the property"
1511     */

1512    public void ifDoesntHaveProperty(String JavaDoc template, Properties attributes) throws XDocletException
1513    {
1514        String JavaDoc value = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), attributes.getProperty(ATTRIBUTE_NAME));
1515
1516        if (value == null)
1517        {
1518            generate(template);
1519        }
1520    }
1521
1522    /**
1523     * Returns the value of a property of the current object on the specified level.
1524     *
1525     * @param attributes The attributes of the tag
1526     * @return The property value
1527     * @exception XDocletException If an error occurs
1528     * @doc.tag type="content"
1529     * @doc.param name="level" optional="false" description="The level for the current object"
1530     * values="class,field,reference,collection"
1531     * @doc.param name="name" optional="false" description="The name of the property"
1532     * @doc.param name="default" optional="true" description="A default value to use if the property
1533     * is not defined"
1534     */

1535    public String JavaDoc propertyValue(Properties attributes) throws XDocletException
1536    {
1537        String JavaDoc value = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), attributes.getProperty(ATTRIBUTE_NAME));
1538
1539        if (value == null)
1540        {
1541            value = attributes.getProperty(ATTRIBUTE_DEFAULT);
1542        }
1543        return value;
1544    }
1545
1546    /**
1547     * Processes the template if the property value of the current object on the specified level equals the given value.
1548     *
1549     * @param template The template
1550     * @param attributes The attributes of the tag
1551     * @exception XDocletException If an error occurs
1552     * @doc.tag type="block"
1553     * @doc.param name="level" optional="false" description="The level for the current object"
1554     * values="class,field,reference,collection"
1555     * @doc.param name="name" optional="false" description="The name of the property"
1556     * @doc.param name="value" optional="false" description="The value to check for"
1557     * @doc.param name="default" optional="true" description="A default value to use if the property
1558     * is not defined"
1559     */

1560    public void ifPropertyValueEquals(String JavaDoc template, Properties attributes) throws XDocletException
1561    {
1562        String JavaDoc value = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), attributes.getProperty(ATTRIBUTE_NAME));
1563        String JavaDoc expected = attributes.getProperty(ATTRIBUTE_VALUE);
1564
1565        if (value == null)
1566        {
1567            value = attributes.getProperty(ATTRIBUTE_DEFAULT);
1568        }
1569        if (expected.equals(value))
1570        {
1571            generate(template);
1572        }
1573    }
1574
1575    /**
1576     * Processes the template if the property value of the current object on the specified level does not equal the given value.
1577     *
1578     * @param template The template
1579     * @param attributes The attributes of the tag
1580     * @exception XDocletException If an error occurs
1581     * @doc.tag type="block"
1582     * @doc.param name="level" optional="false" description="The level for the current object"
1583     * values="class,field,reference,collection"
1584     * @doc.param name="name" optional="false" description="The name of the property"
1585     * @doc.param name="value" optional="false" description="The value to check for"
1586     * @doc.param name="default" optional="true" description="A default value to use if the property
1587     * is not defined"
1588     */

1589    public void ifPropertyValueDoesntEqual(String JavaDoc template, Properties attributes) throws XDocletException
1590    {
1591        String JavaDoc value = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), attributes.getProperty(ATTRIBUTE_NAME));
1592        String JavaDoc expected = attributes.getProperty(ATTRIBUTE_VALUE);
1593
1594        if (value == null)
1595        {
1596            value = attributes.getProperty(ATTRIBUTE_DEFAULT);
1597        }
1598        if (!expected.equals(value))
1599        {
1600            generate(template);
1601        }
1602    }
1603
1604    /**
1605     * Processes the template for the comma-separated value pairs in an attribute of the current object on the specified level.
1606     *
1607     * @param template The template
1608     * @param attributes The attributes of the tag
1609     * @exception XDocletException if an error occurs
1610     * @doc.tag type="block"
1611     * @doc.param name="level" optional="false" description="The level for the current object"
1612     * values="class,field,reference,collection"
1613     * @doc.param name="name" optional="true" description="The name of the attribute containg attributes (defaults to 'attributes')"
1614     * @doc.param name="default-right" optional="true" description="The default right value if none is given (defaults to empty value)"
1615     */

1616    public void forAllValuePairs(String JavaDoc template, Properties attributes) throws XDocletException
1617    {
1618        String JavaDoc name = attributes.getProperty(ATTRIBUTE_NAME, "attributes");
1619        String JavaDoc defaultValue = attributes.getProperty(ATTRIBUTE_DEFAULT_RIGHT, "");
1620        String JavaDoc attributePairs = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), name);
1621
1622        if ((attributePairs == null) || (attributePairs.length() == 0))
1623        {
1624            return;
1625        }
1626
1627        String JavaDoc token;
1628        int pos;
1629
1630        for (CommaListIterator it = new CommaListIterator(attributePairs); it.hasNext();)
1631        {
1632            token = it.getNext();
1633            pos = token.indexOf('=');
1634            if (pos >= 0)
1635            {
1636                _curPairLeft = token.substring(0, pos);
1637                _curPairRight = (pos < token.length() - 1 ? token.substring(pos + 1) : defaultValue);
1638            }
1639            else
1640            {
1641                _curPairLeft = token;
1642                _curPairRight = defaultValue;
1643            }
1644            if (_curPairLeft.length() > 0)
1645            {
1646                generate(template);
1647            }
1648        }
1649        _curPairLeft = null;
1650        _curPairRight = null;
1651    }
1652
1653    /**
1654     * Returns the left part of the current pair.
1655     *
1656     * @param attributes The attributes of the tag
1657     * @return The property value
1658     * @exception XDocletException If an error occurs
1659     * @doc.tag type="content"
1660     */

1661    public String JavaDoc pairLeft(Properties attributes) throws XDocletException
1662    {
1663        return _curPairLeft;
1664    }
1665
1666    /**
1667     * Returns the right part of the current pair.
1668     *
1669     * @param attributes The attributes of the tag
1670     * @return The property value
1671     * @exception XDocletException If an error occurs
1672     * @doc.tag type="content"
1673     */

1674    public String JavaDoc pairRight(Properties attributes) throws XDocletException
1675    {
1676        return _curPairRight;
1677    }
1678
1679    //
1680
// Helper methods
1681
//
1682

1683    // Class-related and Modification-related
1684

1685    /**
1686     * Makes sure that there is a class definition for the given qualified name, and returns it.
1687     *
1688     * @param original The XDoclet class object
1689     * @return The class definition
1690     */

1691    private ClassDescriptorDef ensureClassDef(XClass original)
1692    {
1693        String JavaDoc name = original.getQualifiedName();
1694        ClassDescriptorDef classDef = _model.getClass(name);
1695
1696        if (classDef == null)
1697        {
1698            classDef = new ClassDescriptorDef(original);
1699            _model.addClass(classDef);
1700        }
1701        return classDef;
1702    }
1703
1704    /**
1705     * Adds all direct subtypes to the given list.
1706     *
1707     * @param type The type for which to determine the direct subtypes
1708     * @param subTypes The list to receive the subtypes
1709     */

1710    private void addDirectSubTypes(XClass type, ArrayList subTypes)
1711    {
1712        if (type.isInterface())
1713        {
1714            if (type.getExtendingInterfaces() != null)
1715            {
1716                subTypes.addAll(type.getExtendingInterfaces());
1717            }
1718            // we have to traverse the implementing classes as these array contains all classes that
1719
// implement the interface, not only those who have an "implement" declaration
1720
// note that for whatever reason the declared interfaces are not exported via the XClass interface
1721
// so we have to get them via the underlying class which is hopefully a subclass of AbstractClass
1722
if (type.getImplementingClasses() != null)
1723            {
1724                Collection declaredInterfaces = null;
1725                XClass subType;
1726
1727                for (Iterator it = type.getImplementingClasses().iterator(); it.hasNext(); )
1728                {
1729                    subType = (XClass)it.next();
1730                    if (subType instanceof AbstractClass)
1731                    {
1732                        declaredInterfaces = ((AbstractClass)subType).getDeclaredInterfaces();
1733                        if ((declaredInterfaces != null) && declaredInterfaces.contains(type))
1734                        {
1735                            subTypes.add(subType);
1736                        }
1737                    }
1738                    else
1739                    {
1740                        // Otherwise we have to live with the bug
1741
subTypes.add(subType);
1742                    }
1743                }
1744            }
1745        }
1746        else
1747        {
1748            subTypes.addAll(type.getDirectSubclasses());
1749        }
1750    }
1751
1752
1753    // Field-related
1754

1755    /**
1756     * Determines the default mapping for the type of the current member. If the current member is a field, the type of
1757     * the field is used. If the current member is an accessor, then the return type (get/is) or parameter type (set) is
1758     * used.
1759     *
1760     * @return The jdbc type
1761     * @exception XDocletException If an error occurs
1762     */

1763    public static String JavaDoc getDefaultJdbcTypeForCurrentMember() throws XDocletException
1764    {
1765        if (OjbMemberTagsHandler.getMemberDimension() > 0)
1766        {
1767            return JdbcTypeHelper.JDBC_DEFAULT_TYPE_FOR_ARRAY;
1768        }
1769
1770        String JavaDoc type = OjbMemberTagsHandler.getMemberType().getQualifiedName();
1771
1772        return JdbcTypeHelper.getDefaultJdbcTypeFor(type);
1773    }
1774
1775    /**
1776     * Determines the default conversion for the type of the current member. If the current member is a field, the type of
1777     * the field is used. If the current member is an accessor, then the return type (get/is) or parameter type (set) is
1778     * used.
1779     *
1780     * @return The jdbc type
1781     * @exception XDocletException If an error occurs
1782     */

1783    private static String JavaDoc getDefaultJdbcConversionForCurrentMember() throws XDocletException
1784    {
1785        if (OjbMemberTagsHandler.getMemberDimension() > 0)
1786        {
1787            return JdbcTypeHelper.JDBC_DEFAULT_CONVERSION;
1788        }
1789
1790        String JavaDoc type = OjbMemberTagsHandler.getMemberType().getQualifiedName();
1791
1792        return JdbcTypeHelper.getDefaultConversionFor(type);
1793    }
1794
1795    /**
1796     * Searches the type and its sub types for the nearest ojb-persistent type and returns its name.
1797     *
1798     * @param type The type to search
1799     * @return The qualified name of the found type or <code>null</code> if no type has been found
1800     */

1801    private String JavaDoc searchForPersistentSubType(XClass type)
1802    {
1803        ArrayList queue = new ArrayList();
1804        XClass subType;
1805
1806        queue.add(type);
1807        while (!queue.isEmpty())
1808        {
1809            subType = (XClass)queue.get(0);
1810            queue.remove(0);
1811            if (_model.hasClass(subType.getQualifiedName()))
1812            {
1813                return subType.getQualifiedName();
1814            }
1815            addDirectSubTypes(subType, queue);
1816        }
1817        return null;
1818    }
1819
1820    
1821    /**
1822     * Returns the current definition on the indicated level.
1823     *
1824     * @param level The level
1825     * @return The definition
1826     */

1827    private DefBase getDefForLevel(String JavaDoc level)
1828    {
1829        if (LEVEL_CLASS.equals(level))
1830        {
1831            return _curClassDef;
1832        }
1833        else if (LEVEL_FIELD.equals(level))
1834        {
1835            return _curFieldDef;
1836        }
1837        else if (LEVEL_REFERENCE.equals(level))
1838        {
1839            return _curReferenceDef;
1840        }
1841        else if (LEVEL_COLLECTION.equals(level))
1842        {
1843            return _curCollectionDef;
1844        }
1845        else if (LEVEL_OBJECT_CACHE.equals(level))
1846        {
1847            return _curObjectCacheDef;
1848        }
1849        else if (LEVEL_INDEX_DESC.equals(level))
1850        {
1851            return _curIndexDescriptorDef;
1852        }
1853        else if (LEVEL_TABLE.equals(level))
1854        {
1855            return _curTableDef;
1856        }
1857        else if (LEVEL_COLUMN.equals(level))
1858        {
1859            return _curColumnDef;
1860        }
1861        else if (LEVEL_FOREIGNKEY.equals(level))
1862        {
1863            return _curForeignkeyDef;
1864        }
1865        else if (LEVEL_INDEX.equals(level))
1866        {
1867            return _curIndexDef;
1868        }
1869        else if (LEVEL_PROCEDURE.equals(level))
1870        {
1871            return _curProcedureDef;
1872        }
1873        else if (LEVEL_PROCEDURE_ARGUMENT.equals(level))
1874        {
1875            return _curProcedureArgumentDef;
1876        }
1877        else
1878        {
1879            return null;
1880        }
1881    }
1882
1883    /**
1884     * Determines whether the current feature on the given level is ignored.
1885     *
1886     * @param level The level
1887     * @return <code>true</code> if this feature is ignored
1888     */

1889    private boolean isFeatureIgnored(String JavaDoc level)
1890    {
1891        return getDefForLevel(level).getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false);
1892    }
1893
1894    /**
1895     * Returns the value of the indicated property of the current object on the specified level.
1896     *
1897     * @param level The level
1898     * @param name The name of the property
1899     * @return The property value
1900     */

1901    private String JavaDoc getPropertyValue(String JavaDoc level, String JavaDoc name)
1902    {
1903        return getDefForLevel(level).getProperty(name);
1904    }
1905
1906}
1907
Popular Tags