KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectstyle > cayenne > gen > MapClassGenerator


1 /* ====================================================================
2  *
3  * The ObjectStyle Group Software License, version 1.1
4  * ObjectStyle Group - http://objectstyle.org/
5  *
6  * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
7  * of the software. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution, if any,
22  * must include the following acknowlegement:
23  * "This product includes software developed by independent contributors
24  * and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
25  * Alternately, this acknowlegement may appear in the software itself,
26  * if and wherever such third-party acknowlegements normally appear.
27  *
28  * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
29  * or promote products derived from this software without prior written
30  * permission. For written permission, email
31  * "andrus at objectstyle dot org".
32  *
33  * 5. Products derived from this software may not be called "ObjectStyle"
34  * or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
35  * names without prior written permission.
36  *
37  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40  * DISCLAIMED. IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
41  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48  * SUCH DAMAGE.
49  * ====================================================================
50  *
51  * This software consists of voluntary contributions made by many
52  * individuals and hosted on ObjectStyle Group web site. For more
53  * information on the ObjectStyle Group, please see
54  * <http://objectstyle.org/>.
55  */

56
57 package org.objectstyle.cayenne.gen;
58
59 import java.io.Writer JavaDoc;
60 import java.util.ArrayList JavaDoc;
61 import java.util.Collections JavaDoc;
62 import java.util.Iterator JavaDoc;
63 import java.util.List JavaDoc;
64
65 import org.objectstyle.cayenne.CayenneDataObject;
66 import org.objectstyle.cayenne.CayenneRuntimeException;
67 import org.objectstyle.cayenne.PersistentObject;
68 import org.objectstyle.cayenne.map.DataMap;
69 import org.objectstyle.cayenne.map.ObjEntity;
70
71 import foundrylogic.vpp.VPPConfig;
72
73 /**
74  * Generates Java source code for ObjEntities in the DataMap. This class is
75  * abstract and does not deal with filesystem issues directly. Concrete
76  * subclasses should provide ways to store generated files by implementing
77  * {@link #openWriter(ObjEntity, String, String)} and
78  * {@link #closeWriter(Writer)}methods.
79  *
80  * @author Andrei Adamchik
81  */

82 public abstract class MapClassGenerator {
83
84     public static final String JavaDoc SINGLE_CLASS_TEMPLATE_1_1 = "dotemplates/singleclass.vm";
85     public static final String JavaDoc SUBCLASS_TEMPLATE_1_1 = "dotemplates/subclass.vm";
86     public static final String JavaDoc SUPERCLASS_TEMPLATE_1_1 = "dotemplates/superclass.vm";
87     
88     public static final String JavaDoc SINGLE_CLASS_TEMPLATE_1_2 = "dotemplates/v1_2/singleclass.vm";
89     public static final String JavaDoc SUBCLASS_TEMPLATE_1_2 = "dotemplates/v1_2/subclass.vm";
90     public static final String JavaDoc SUPERCLASS_TEMPLATE_1_2 = "dotemplates/v1_2/superclass.vm";
91     
92     /**
93      * @since 1.2
94      */

95     public static final String JavaDoc CLIENT_SUBCLASS_TEMPLATE_1_2 = "dotemplates/v1_2/client-subclass.vm";
96     
97     /**
98      * @since 1.2
99      */

100     public static final String JavaDoc CLIENT_SUPERCLASS_TEMPLATE_1_2 = "dotemplates/v1_2/client-superclass.vm";
101     
102     public static final String JavaDoc SINGLE_CLASS_TEMPLATE = SINGLE_CLASS_TEMPLATE_1_1;
103     public static final String JavaDoc SUBCLASS_TEMPLATE = SUBCLASS_TEMPLATE_1_1;
104     public static final String JavaDoc SUPERCLASS_TEMPLATE = SUPERCLASS_TEMPLATE_1_1;
105     
106     public static final String JavaDoc SUPERCLASS_PREFIX = "_";
107
108     protected static final String JavaDoc VERSION_1_1 = ClassGenerator.VERSION_1_1;
109     protected static final String JavaDoc VERSION_1_2 = ClassGenerator.VERSION_1_2;
110
111     protected static final String JavaDoc DEFAULT_VERSION = VERSION_1_1;
112     
113     protected static final String JavaDoc MODE_DATAMAP = "datamap";
114     protected static final String JavaDoc MODE_ENTITY = "entity";
115
116     protected String JavaDoc versionString = DEFAULT_VERSION;
117
118     protected List JavaDoc objEntities;
119     protected String JavaDoc superPkg;
120     protected DataMap dataMap;
121     protected VPPConfig vppConfig;
122     protected String JavaDoc mode = MODE_ENTITY;
123     protected boolean client;
124
125     public MapClassGenerator() {}
126
127     public MapClassGenerator(DataMap dataMap) {
128         this(dataMap, new ArrayList JavaDoc(dataMap.getObjEntities()));
129     }
130
131     public MapClassGenerator(DataMap dataMap, List JavaDoc selectedObjEntities) {
132         this.dataMap = dataMap;
133         this.objEntities = selectedObjEntities;
134     }
135
136     /**
137      * @deprecated Since 1.2 use MapClassGenerator(DataMap, List) to provide support for
138      * v1.2 templates.
139      */

140     public MapClassGenerator(List JavaDoc selectedObjEntities) {
141         this.objEntities = selectedObjEntities;
142     }
143
144     protected String JavaDoc defaultSingleClassTemplate() {
145         // there is no default single class client template at the moment
146
if (client) {
147             throw new IllegalStateException JavaDoc(
148                     "Default generation for single classes on the client is not supported...");
149         }
150         else if (VERSION_1_1.equals(versionString)) {
151             return SINGLE_CLASS_TEMPLATE_1_1;
152         }
153         else if (VERSION_1_2.equals(versionString)) {
154             return SINGLE_CLASS_TEMPLATE_1_2;
155         }
156         return SINGLE_CLASS_TEMPLATE;
157     }
158
159     protected String JavaDoc defaultSubclassTemplate() {
160         // client templates are always 1.2
161
if(client) {
162             return CLIENT_SUBCLASS_TEMPLATE_1_2;
163         }
164         else if (VERSION_1_1.equals(versionString)) {
165             return SUBCLASS_TEMPLATE_1_1;
166         }
167         else if (VERSION_1_2.equals(versionString)) {
168             return SUBCLASS_TEMPLATE_1_2;
169         }
170         return SUBCLASS_TEMPLATE;
171     }
172
173     protected String JavaDoc defaultSuperclassTemplate() {
174         // client templates are always 1.2
175
if (client) {
176             return CLIENT_SUPERCLASS_TEMPLATE_1_2;
177         }
178         else if (VERSION_1_1.equals(versionString)) {
179             return SUPERCLASS_TEMPLATE_1_1;
180         }
181         else if (VERSION_1_2.equals(versionString)) {
182             return SUPERCLASS_TEMPLATE_1_2;
183         }
184         return SUPERCLASS_TEMPLATE;
185     }
186
187     /**
188      * Creates a Writer to output source code for a given ObjEntity and Java
189      * class.
190      *
191      * @return Writer to store generated class source code or null if this class
192      * generation should be skipped.
193      */

194     public abstract Writer JavaDoc openWriter(
195         ObjEntity entity,
196         String JavaDoc pkgName,
197         String JavaDoc className)
198         throws Exception JavaDoc;
199
200     /**
201      * Closes writer after class code has been successfully written by
202      * ClassGenerationInfo.
203      */

204     public abstract void closeWriter(Writer JavaDoc out) throws Exception JavaDoc;
205
206     /**
207      * Runs class generation. Produces a pair of Java classes for each ObjEntity
208      * in the map. Uses default Cayenne templates for classes.
209      */

210     public void generateClassPairs() throws Exception JavaDoc {
211         generateClassPairs(defaultSubclassTemplate(), defaultSuperclassTemplate(), SUPERCLASS_PREFIX);
212     }
213
214     /**
215      * Runs class generation. Produces a pair of Java classes for each ObjEntity
216      * in the map. This allows developers to use generated <b>subclass </b> for
217      * their custom code, while generated <b>superclass </b> will contain
218      * Cayenne code. Superclass will be generated in the same package, its class
219      * name will be derived from the class name by adding a
220      * <code>superPrefix</code>.
221      */

222     public void generateClassPairs(
223         String JavaDoc classTemplate,
224         String JavaDoc superTemplate,
225         String JavaDoc superPrefix)
226         throws Exception JavaDoc {
227         
228         // note - client templates ignore version and unconditionally use 1.2
229
if(client) {
230             generateClientClassPairs_1_2(classTemplate, superTemplate, superPrefix);
231         }
232         else if (VERSION_1_1.equals(versionString)) {
233             generateClassPairs_1_1(classTemplate, superTemplate, superPrefix);
234         }
235         else if (VERSION_1_2.equals(versionString)) {
236             generateClassPairs_1_2(classTemplate, superTemplate, superPrefix);
237         }
238         else {
239             throw new IllegalStateException JavaDoc("Illegal Version in generateClassPairs: " + versionString);
240         }
241     }
242
243     /**
244      * Runs class generation. Produces a pair of Java classes for each ObjEntity
245      * in the map. This allows developers to use generated <b>subclass </b> for
246      * their custom code, while generated <b>superclass </b> will contain
247      * Cayenne code. Superclass will be generated in the same package, its class
248      * name will be derived from the class name by adding a
249      * <code>superPrefix</code>.
250      */

251     private void generateClassPairs_1_1(
252         String JavaDoc classTemplate,
253         String JavaDoc superTemplate,
254         String JavaDoc superPrefix)
255         throws Exception JavaDoc {
256
257         ClassGenerator mainGenSetup = new ClassGenerator(classTemplate, versionString);
258         ClassGenerator superGenSetup = new ClassGenerator(superTemplate, versionString);
259
260         ClassGenerationInfo mainGen = mainGenSetup.getClassGenerationInfo();
261         ClassGenerationInfo superGen = superGenSetup.getClassGenerationInfo();
262
263         // prefix is needed for both generators
264
mainGen.setSuperPrefix(superPrefix);
265         superGen.setSuperPrefix(superPrefix);
266         
267         // Iterate only once if this is datamap mode
268
Iterator JavaDoc it = objEntities.iterator();
269         if (MODE_ENTITY.equals(mode))
270         {
271             it = objEntities.iterator();
272         }
273         else
274         {
275             if (objEntities.isEmpty())
276             {
277                 it = objEntities.iterator();
278             }
279             else
280             {
281                 it = Collections.singleton(objEntities.get(0)).iterator();
282             }
283         }
284         
285         while (it.hasNext()) {
286             ObjEntity ent = (ObjEntity) it.next();
287
288             // 1. do the superclass
289
initClassGenerator_1_1(superGen, ent, true);
290
291             Writer JavaDoc superOut =
292                 openWriter(
293                     ent,
294                     superGen.getPackageName(),
295                     superPrefix + superGen.getClassName());
296
297             if (superOut != null) {
298                 superGenSetup.generateClass(superOut, ent);
299                 closeWriter(superOut);
300             }
301
302             // 2. do the main class
303
initClassGenerator_1_1(mainGen, ent, false);
304             Writer JavaDoc mainOut =
305                 openWriter(ent, mainGen.getPackageName(), mainGen.getClassName());
306             if (mainOut != null) {
307                 mainGenSetup.generateClass(mainOut, ent);
308                 closeWriter(mainOut);
309             }
310         }
311     }
312     
313     private void generateClientClassPairs_1_2(
314             String JavaDoc classTemplate,
315             String JavaDoc superTemplate,
316             String JavaDoc superPrefix) throws Exception JavaDoc {
317         
318         ClassGenerator mainGenSetup = new ClassGenerator(
319                 classTemplate,
320                 ClassGenerator.VERSION_1_2,
321                 vppConfig);
322         ClassGenerator superGenSetup = new ClassGenerator(
323                 superTemplate,
324                 ClassGenerator.VERSION_1_2,
325                 vppConfig);
326
327         // Iterate only once if this is datamap mode
328
Iterator JavaDoc it = objEntities.iterator();
329         if (MODE_ENTITY.equals(mode)) {
330             it = objEntities.iterator();
331         }
332         else {
333             if (objEntities.isEmpty()) {
334                 it = objEntities.iterator();
335             }
336             else {
337                 it = Collections.singleton(objEntities.get(0)).iterator();
338             }
339         }
340
341         while (it.hasNext()) {
342             ObjEntity ent = (ObjEntity) it.next();
343
344             // use client name, and if not specified use regular class name
345
String JavaDoc fqnSubClass = ent.getClientClassName();
346             if (fqnSubClass == null) {
347                 fqnSubClass = ent.getClassName();
348             }
349
350             // use PersistentObject instead of CayenneDataObject as base ...
351
// TODO: for now custom superclass will be shared between server and client
352
// need to address that
353
String JavaDoc fqnBaseClass = (null != ent.getSuperClassName()) ? ent
354                     .getSuperClassName() : PersistentObject.class.getName();
355
356             StringUtils stringUtils = StringUtils.getInstance();
357
358             String JavaDoc subClassName = stringUtils.stripPackageName(fqnSubClass);
359             String JavaDoc subPackageName = stringUtils.stripClass(fqnSubClass);
360
361             String JavaDoc superClassName = superPrefix
362                     + stringUtils.stripPackageName(fqnSubClass);
363
364             String JavaDoc superPackageName = this.superPkg;
365             String JavaDoc fqnSuperClass = superPackageName + "." + superClassName;
366
367             Writer JavaDoc superOut = openWriter(ent, superPackageName, superClassName);
368
369             if (superOut != null) {
370                 superGenSetup.generateClass(superOut,
371                         dataMap,
372                         ent,
373                         fqnBaseClass,
374                         fqnSuperClass,
375                         fqnSubClass);
376                 closeWriter(superOut);
377             }
378
379             Writer JavaDoc mainOut = openWriter(ent, subPackageName, subClassName);
380             if (mainOut != null) {
381                 mainGenSetup.generateClass(mainOut,
382                         dataMap,
383                         ent,
384                         fqnBaseClass,
385                         fqnSuperClass,
386                         fqnSubClass);
387                 closeWriter(mainOut);
388             }
389         }
390     }
391
392     /**
393      * Runs class generation. Produces a pair of Java classes for each ObjEntity in the
394      * map. This allows developers to use generated <b>subclass </b> for their custom
395      * code, while generated <b>superclass </b> will contain Cayenne code. Superclass will
396      * be generated in the same package, its class name will be derived from the class
397      * name by adding a <code>superPrefix</code>.
398      */

399     private void generateClassPairs_1_2(
400         String JavaDoc classTemplate,
401         String JavaDoc superTemplate,
402         String JavaDoc superPrefix)
403         throws Exception JavaDoc {
404
405         ClassGenerator mainGenSetup = new ClassGenerator(
406                 classTemplate,
407                 versionString,
408                 vppConfig);
409         ClassGenerator superGenSetup = new ClassGenerator(
410                 superTemplate,
411                 versionString,
412                 vppConfig);
413
414         // Iterate only once if this is datamap mode
415
Iterator JavaDoc it = objEntities.iterator();
416         if (MODE_ENTITY.equals(mode)) {
417             it = objEntities.iterator();
418         }
419         else {
420             if (objEntities.isEmpty()) {
421                 it = objEntities.iterator();
422             }
423             else {
424                 it = Collections.singleton(objEntities.get(0)).iterator();
425             }
426         }
427
428         while (it.hasNext()) {
429             ObjEntity ent = (ObjEntity) it.next();
430
431             String JavaDoc fqnSubClass = ent.getClassName();
432             String JavaDoc fqnBaseClass = (null != ent.getSuperClassName()) ? ent
433                     .getSuperClassName() : CayenneDataObject.class.getName();
434
435             StringUtils stringUtils = StringUtils.getInstance();
436
437             String JavaDoc subClassName = stringUtils.stripPackageName(fqnSubClass);
438             String JavaDoc subPackageName = stringUtils.stripClass(fqnSubClass);
439
440             String JavaDoc superClassName = superPrefix
441                     + stringUtils.stripPackageName(fqnSubClass);
442
443             String JavaDoc superPackageName = this.superPkg;
444             String JavaDoc fqnSuperClass = superPackageName + "." + superClassName;
445
446             Writer JavaDoc superOut = openWriter(ent, superPackageName, superClassName);
447
448             if (superOut != null) {
449                 superGenSetup.generateClass(superOut,
450                         dataMap,
451                         ent,
452                         fqnBaseClass,
453                         fqnSuperClass,
454                         fqnSubClass);
455                 closeWriter(superOut);
456             }
457
458             Writer JavaDoc mainOut = openWriter(ent, subPackageName, subClassName);
459             if (mainOut != null) {
460                 mainGenSetup.generateClass(mainOut,
461                         dataMap,
462                         ent,
463                         fqnBaseClass,
464                         fqnSuperClass,
465                         fqnSubClass);
466                 closeWriter(mainOut);
467             }
468         }
469     }
470
471     /**
472      * Runs class generation. Produces a single Java class for
473      * each ObjEntity in the map. Uses default Cayenne templates for classes.
474      */

475     public void generateSingleClasses() throws Exception JavaDoc {
476         generateSingleClasses(defaultSingleClassTemplate(), SUPERCLASS_PREFIX);
477     }
478
479     /**
480      * Runs class generation. Produces a single Java class for
481      * each ObjEntity in the map.
482      */

483     private void generateSingleClasses_1_1(String JavaDoc classTemplate) throws Exception JavaDoc {
484         ClassGenerator gen = new ClassGenerator(classTemplate, versionString);
485
486         // Iterate only once if this is datamap mode
487
Iterator JavaDoc it = objEntities.iterator();
488         if (MODE_ENTITY.equals(mode))
489         {
490             it = objEntities.iterator();
491         }
492         else
493         {
494             if (objEntities.isEmpty())
495             {
496                 it = objEntities.iterator();
497             }
498             else
499             {
500                 it = Collections.singleton(objEntities.get(0)).iterator();
501             }
502         }
503         
504         while (it.hasNext()) {
505             ObjEntity ent = (ObjEntity) it.next();
506             
507             initClassGenerator_1_1(gen.getClassGenerationInfo(), ent, false);
508             Writer JavaDoc out = openWriter(ent, gen.getClassGenerationInfo().getPackageName(), gen.getClassGenerationInfo().getClassName());
509             if (out == null) {
510                 continue;
511             }
512
513             gen.generateClass(out, ent);
514             closeWriter(out);
515         }
516     }
517
518     /**
519      * Runs class generation. Produces a single Java class for
520      * each ObjEntity in the map.
521      */

522     private void generateSingleClasses_1_2(String JavaDoc classTemplate, String JavaDoc superPrefix) throws Exception JavaDoc {
523         ClassGenerator gen = new ClassGenerator(classTemplate, versionString, vppConfig);
524
525         // Iterate only once if this is datamap mode
526
Iterator JavaDoc it = objEntities.iterator();
527         if (MODE_ENTITY.equals(mode))
528         {
529             it = objEntities.iterator();
530         }
531         else
532         {
533             if (objEntities.isEmpty())
534             {
535                 it = objEntities.iterator();
536             }
537             else
538             {
539                 it = Collections.singleton(objEntities.get(0)).iterator();
540             }
541         }
542         
543         while (it.hasNext()) {
544             ObjEntity ent = (ObjEntity) it.next();
545             
546             String JavaDoc fqnSubClass = ent.getClassName();
547             String JavaDoc fqnBaseClass = (null != ent.getSuperClassName())
548                 ? ent.getSuperClassName() : CayenneDataObject.class.getName();
549
550             StringUtils stringUtils = StringUtils.getInstance();
551             
552             String JavaDoc subClassName = stringUtils.stripPackageName(fqnSubClass);
553             String JavaDoc subPackageName = stringUtils.stripClass(fqnSubClass);
554
555             String JavaDoc superClassName = superPrefix + stringUtils.stripPackageName(fqnSubClass);
556
557             String JavaDoc superPackageName = this.superPkg;
558             String JavaDoc fqnSuperClass = superPackageName + "." + superClassName;
559
560             Writer JavaDoc out = openWriter(ent, subPackageName, subClassName);
561             if (out == null) {
562                 continue;
563             }
564
565             gen.generateClass(out, dataMap, ent, fqnBaseClass, fqnSuperClass, fqnSubClass);
566             closeWriter(out);
567         }
568     }
569
570     /**
571      * Runs class generation. Produces a single Java class for
572      * each ObjEntity in the map.
573      * @deprecated Use generateSingleClasses(String classTemplate, String superPrefix) instead.
574      */

575     public void generateSingleClasses(String JavaDoc classTemplate) throws Exception JavaDoc {
576         generateSingleClasses(classTemplate, SUPERCLASS_PREFIX);
577     }
578
579     /**
580      * Runs class generation. Produces a single Java class for
581      * each ObjEntity in the map.
582      */

583     public void generateSingleClasses(String JavaDoc classTemplate, String JavaDoc superPrefix) throws Exception JavaDoc {
584         // note - client templates ignore version and automatically switch to 1.2
585
if(client) {
586             generateSingleClasses_1_2(classTemplate, superPrefix);
587         }
588         else if (VERSION_1_1.equals(versionString)) {
589             generateSingleClasses_1_1(classTemplate);
590         }
591         else if (VERSION_1_2.equals(versionString)) {
592             generateSingleClasses_1_2(classTemplate, superPrefix);
593         }
594         else {
595             throw new IllegalStateException JavaDoc("Illegal Version in generateClassPairs: " + versionString);
596         }
597     }
598
599     /** Initializes ClassGenerationInfo with class name and package of a generated class. */
600     protected void initClassGenerator_1_1(
601         ClassGenerationInfo gen,
602         ObjEntity entity,
603         boolean superclass) {
604
605         // figure out generator properties
606
String JavaDoc fullClassName = entity.getClassName();
607         int i = fullClassName.lastIndexOf(".");
608
609         String JavaDoc pkg = null;
610         String JavaDoc spkg = null;
611         String JavaDoc cname = null;
612
613         // dot in first or last position is invalid
614
if (i == 0 || i + 1 == fullClassName.length()) {
615             throw new CayenneRuntimeException("Invalid class mapping: " + fullClassName);
616         }
617         else if (i < 0) {
618             pkg = (superclass) ? superPkg : null;
619             spkg = (superclass) ? null : superPkg;
620             cname = fullClassName;
621         }
622         else {
623             cname = fullClassName.substring(i + 1);
624             pkg =
625                 (superclass && superPkg != null) ? superPkg : fullClassName.substring(0, i);
626
627             spkg =
628                 (!superclass && superPkg != null && !pkg.equals(superPkg)) ? superPkg : null;
629         }
630
631         // init generator
632
gen.setPackageName(pkg);
633         gen.setClassName(cname);
634         if(entity.getSuperClassName()!=null) {
635             gen.setSuperClassName(entity.getSuperClassName());
636         } else {
637             gen.setSuperClassName(CayenneDataObject.class.getName());
638         }
639         gen.setSuperPackageName(spkg);
640     }
641
642     /**
643      * Returns "superPkg" property value -
644      * a name of a superclass package that should be used
645      * for all generated superclasses.
646      */

647     public String JavaDoc getSuperPkg() {
648         return superPkg;
649     }
650
651     /**
652      * Sets "superPkg" property value.
653      */

654     public void setSuperPkg(String JavaDoc superPkg) {
655         this.superPkg = superPkg;
656     }
657
658     /**
659      * Returns whether a default client object template will be used.
660      *
661      * @since 1.2
662      */

663     public boolean isClient() {
664         return client;
665     }
666     
667     /**
668      * Sets whether a default client object template should be used.
669      *
670      * @since 1.2
671      */

672     public void setClient(boolean client) {
673         this.client = client;
674     }
675     
676     /**
677      * @return Returns the dataMap.
678      */

679     public DataMap getDataMap() {
680         return dataMap;
681     }
682
683     /**
684      * @param dataMap The dataMap to set.
685      */

686     public void setDataMap(DataMap dataMap) {
687         this.dataMap = dataMap;
688     }
689
690     public List JavaDoc getObjEntities() {
691         return objEntities;
692     }
693
694     public void setObjEntities(List JavaDoc objEntities) {
695         this.objEntities = objEntities;
696     }
697
698     /**
699      * @return Returns the versionString.
700      */

701     public String JavaDoc getVersionString() {
702         return versionString;
703     }
704     /**
705      * @param versionString The versionString to set.
706      */

707     public void setVersionString(String JavaDoc versionString) {
708         if ((false == VERSION_1_1.equals(versionString)) && (false == VERSION_1_2.equals(versionString))) {
709             throw new IllegalStateException JavaDoc("'version' must be '" + VERSION_1_1 + "' or '" + VERSION_1_2 + "', but was '" + versionString + "'");
710         }
711         this.versionString = versionString;
712     }
713     
714     /**
715      * @return Returns the vppConfig.
716      */

717     public VPPConfig getVppConfig() {
718         return vppConfig;
719     }
720     /**
721      * @param vppConfig The vppConfig to set.
722      */

723     public void setVppConfig(VPPConfig vppConfig) {
724         this.vppConfig = vppConfig;
725     }
726
727     /**
728      * @param mode use "entity" for per-entity generation and "datamap" for per-datamap generation.
729      */

730     public void setMode(String JavaDoc mode) {
731         if ((false == MODE_ENTITY.equals(mode)) && (false == MODE_DATAMAP.equals(mode))) {
732             throw new IllegalStateException JavaDoc("'mode' must be '" + MODE_ENTITY + "' or '" + MODE_DATAMAP + "', but was '" + mode + "'");
733         }
734         this.mode = mode;
735     }
736 }
Popular Tags