KickJava   Java API By Example, From Geeks To Geeks.

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


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

19
20 package org.apache.cayenne.gen;
21
22 import java.io.Writer JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Collections JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import java.util.List JavaDoc;
27
28 import org.apache.cayenne.CayenneDataObject;
29 import org.apache.cayenne.CayenneRuntimeException;
30 import org.apache.cayenne.PersistentObject;
31 import org.apache.cayenne.map.DataMap;
32 import org.apache.cayenne.map.ObjEntity;
33
34 import foundrylogic.vpp.VPPConfig;
35
36 /**
37  * Generates Java source code for ObjEntities in the DataMap. This class is abstract and
38  * does not deal with filesystem issues directly. Concrete subclasses should provide ways
39  * to store generated files by implementing {@link #openWriter(ObjEntity, String, String)}
40  * and {@link #closeWriter(Writer)}methods.
41  *
42  * @author Andrus Adamchik
43  */

44 public abstract class MapClassGenerator {
45
46     public static final String JavaDoc SINGLE_CLASS_TEMPLATE_1_1 = "dotemplates/singleclass.vm";
47     public static final String JavaDoc SUBCLASS_TEMPLATE_1_1 = "dotemplates/subclass.vm";
48     public static final String JavaDoc SUPERCLASS_TEMPLATE_1_1 = "dotemplates/superclass.vm";
49
50     public static final String JavaDoc SINGLE_CLASS_TEMPLATE_1_2 = "dotemplates/v1_2/singleclass.vm";
51     public static final String JavaDoc SUBCLASS_TEMPLATE_1_2 = "dotemplates/v1_2/subclass.vm";
52     public static final String JavaDoc SUPERCLASS_TEMPLATE_1_2 = "dotemplates/v1_2/superclass.vm";
53
54     /**
55      * @since 1.2
56      */

57     public static final String JavaDoc CLIENT_SUBCLASS_TEMPLATE_1_2 = "dotemplates/v1_2/client-subclass.vm";
58
59     /**
60      * @since 1.2
61      */

62     public static final String JavaDoc CLIENT_SUPERCLASS_TEMPLATE_1_2 = "dotemplates/v1_2/client-superclass.vm";
63
64     public static final String JavaDoc SINGLE_CLASS_TEMPLATE = SINGLE_CLASS_TEMPLATE_1_1;
65     public static final String JavaDoc SUBCLASS_TEMPLATE = SUBCLASS_TEMPLATE_1_1;
66     public static final String JavaDoc SUPERCLASS_TEMPLATE = SUPERCLASS_TEMPLATE_1_1;
67
68     public static final String JavaDoc SUPERCLASS_PREFIX = "_";
69
70     protected static final String JavaDoc VERSION_1_1 = ClassGenerator.VERSION_1_1;
71     protected static final String JavaDoc VERSION_1_2 = ClassGenerator.VERSION_1_2;
72
73     protected static final String JavaDoc DEFAULT_VERSION = VERSION_1_1;
74
75     protected static final String JavaDoc MODE_DATAMAP = "datamap";
76     protected static final String JavaDoc MODE_ENTITY = "entity";
77
78     protected String JavaDoc versionString = DEFAULT_VERSION;
79
80     protected List JavaDoc objEntities;
81     protected String JavaDoc superPkg;
82     protected DataMap dataMap;
83     protected VPPConfig vppConfig;
84     protected String JavaDoc mode = MODE_ENTITY;
85     protected boolean client;
86
87     public MapClassGenerator() {
88     }
89
90     public MapClassGenerator(DataMap dataMap) {
91         this(dataMap, new ArrayList JavaDoc(dataMap.getObjEntities()));
92     }
93
94     /**
95      * Creates a new MapClassGenerator.
96      *
97      * @since 1.2
98      */

99     public MapClassGenerator(DataMap dataMap, List JavaDoc objEntities) {
100         this.dataMap = dataMap;
101         this.setObjEntities(objEntities);
102     }
103
104     protected String JavaDoc defaultSingleClassTemplate() {
105         // there is no default single class client template at the moment
106
if (client) {
107             throw new IllegalStateException JavaDoc(
108                     "Default generation for single classes on the client is not supported...");
109         }
110         else if (VERSION_1_1.equals(versionString)) {
111             return SINGLE_CLASS_TEMPLATE_1_1;
112         }
113         else if (VERSION_1_2.equals(versionString)) {
114             return SINGLE_CLASS_TEMPLATE_1_2;
115         }
116         return SINGLE_CLASS_TEMPLATE;
117     }
118
119     protected String JavaDoc defaultSubclassTemplate() {
120         // client templates are always 1.2
121
if (client) {
122             return CLIENT_SUBCLASS_TEMPLATE_1_2;
123         }
124         else if (VERSION_1_1.equals(versionString)) {
125             return SUBCLASS_TEMPLATE_1_1;
126         }
127         else if (VERSION_1_2.equals(versionString)) {
128             return SUBCLASS_TEMPLATE_1_2;
129         }
130         return SUBCLASS_TEMPLATE;
131     }
132
133     protected String JavaDoc defaultSuperclassTemplate() {
134         // client templates are always 1.2
135
if (client) {
136             return CLIENT_SUPERCLASS_TEMPLATE_1_2;
137         }
138         else if (VERSION_1_1.equals(versionString)) {
139             return SUPERCLASS_TEMPLATE_1_1;
140         }
141         else if (VERSION_1_2.equals(versionString)) {
142             return SUPERCLASS_TEMPLATE_1_2;
143         }
144         return SUPERCLASS_TEMPLATE;
145     }
146
147     /**
148      * Creates a Writer to output source code for a given ObjEntity and Java class.
149      *
150      * @return Writer to store generated class source code or null if this class
151      * generation should be skipped.
152      */

153     public abstract Writer JavaDoc openWriter(ObjEntity entity, String JavaDoc pkgName, String JavaDoc className)
154             throws Exception JavaDoc;
155
156     /**
157      * Closes writer after class code has been successfully written by
158      * ClassGenerationInfo.
159      */

160     public abstract void closeWriter(Writer JavaDoc out) throws Exception JavaDoc;
161
162     /**
163      * Runs class generation. Produces a pair of Java classes for each ObjEntity in the
164      * map. Uses default Cayenne templates for classes.
165      */

166     public void generateClassPairs() throws Exception JavaDoc {
167         generateClassPairs(
168                 defaultSubclassTemplate(),
169                 defaultSuperclassTemplate(),
170                 SUPERCLASS_PREFIX);
171     }
172
173     /**
174      * Runs class generation. Produces a pair of Java classes for each ObjEntity in the
175      * map. This allows developers to use generated <b>subclass </b> for their custom
176      * code, while generated <b>superclass </b> will contain Cayenne code. Superclass will
177      * be generated in the same package, its class name will be derived from the class
178      * name by adding a <code>superPrefix</code>.
179      */

180     public void generateClassPairs(
181             String JavaDoc classTemplate,
182             String JavaDoc superTemplate,
183             String JavaDoc superPrefix) throws Exception JavaDoc {
184
185         // note - client templates ignore version and unconditionally use 1.2
186
if (client) {
187             generateClientClassPairs_1_2(classTemplate, superTemplate, superPrefix);
188         }
189         else if (VERSION_1_1.equals(versionString)) {
190             generateClassPairs_1_1(classTemplate, superTemplate, superPrefix);
191         }
192         else if (VERSION_1_2.equals(versionString)) {
193             generateClassPairs_1_2(classTemplate, superTemplate, superPrefix);
194         }
195         else {
196             throw new IllegalStateException JavaDoc("Illegal Version in generateClassPairs: "
197                     + versionString);
198         }
199     }
200
201     /**
202      * Runs class generation. Produces a pair of Java classes for each ObjEntity in the
203      * map. This allows developers to use generated <b>subclass </b> for their custom
204      * code, while generated <b>superclass </b> will contain Cayenne code. Superclass will
205      * be generated in the same package, its class name will be derived from the class
206      * name by adding a <code>superPrefix</code>.
207      */

208     private void generateClassPairs_1_1(
209             String JavaDoc classTemplate,
210             String JavaDoc superTemplate,
211             String JavaDoc superPrefix) throws Exception JavaDoc {
212
213         ClassGenerator mainGenSetup = new ClassGenerator(classTemplate, versionString);
214         ClassGenerator superGenSetup = new ClassGenerator(superTemplate, versionString);
215
216         ClassGenerationInfo mainGen = mainGenSetup.getClassGenerationInfo();
217         ClassGenerationInfo superGen = superGenSetup.getClassGenerationInfo();
218
219         // prefix is needed for both generators
220
mainGen.setSuperPrefix(superPrefix);
221         superGen.setSuperPrefix(superPrefix);
222
223         // Iterate only once if this is datamap mode
224
Iterator JavaDoc it = objEntities.iterator();
225         if (MODE_ENTITY.equals(mode)) {
226             it = objEntities.iterator();
227         }
228         else {
229             if (objEntities.isEmpty()) {
230                 it = objEntities.iterator();
231             }
232             else {
233                 it = Collections.singleton(objEntities.get(0)).iterator();
234             }
235         }
236
237         while (it.hasNext()) {
238             ObjEntity ent = (ObjEntity) it.next();
239
240             // 1. do the superclass
241
initClassGenerator_1_1(superGen, ent, true);
242
243             Writer JavaDoc superOut = openWriter(ent, superGen.getPackageName(), superPrefix
244                     + superGen.getClassName());
245
246             if (superOut != null) {
247                 superGenSetup.generateClass(superOut, ent);
248                 closeWriter(superOut);
249             }
250
251             // 2. do the main class
252
initClassGenerator_1_1(mainGen, ent, false);
253             Writer JavaDoc mainOut = openWriter(ent, mainGen.getPackageName(), mainGen
254                     .getClassName());
255             if (mainOut != null) {
256                 mainGenSetup.generateClass(mainOut, ent);
257                 closeWriter(mainOut);
258             }
259         }
260     }
261
262     private void generateClientClassPairs_1_2(
263             String JavaDoc classTemplate,
264             String JavaDoc superTemplate,
265             String JavaDoc superPrefix) throws Exception JavaDoc {
266
267         ClassGenerator mainGenSetup = new ClassGenerator(
268                 classTemplate,
269                 ClassGenerator.VERSION_1_2,
270                 vppConfig);
271         ClassGenerator superGenSetup = new ClassGenerator(
272                 superTemplate,
273                 ClassGenerator.VERSION_1_2,
274                 vppConfig);
275
276         // Iterate only once if this is datamap mode
277
Iterator JavaDoc it = objEntities.iterator();
278         if (MODE_ENTITY.equals(mode)) {
279             it = objEntities.iterator();
280         }
281         else {
282             if (objEntities.isEmpty()) {
283                 it = objEntities.iterator();
284             }
285             else {
286                 it = Collections.singleton(objEntities.get(0)).iterator();
287             }
288         }
289
290         while (it.hasNext()) {
291             ObjEntity entity = (ObjEntity) it.next();
292
293             // use client name, and if not specified use regular class name
294
String JavaDoc fqnSubClass = entity.getClientClassName();
295             if (fqnSubClass == null) {
296                 fqnSubClass = entity.getClassName();
297             }
298
299             // use PersistentObject instead of CayenneDataObject as base ...
300
String JavaDoc fqnBaseClass = (entity.getClientSuperClassName() != null) ? entity
301                     .getClientSuperClassName() : PersistentObject.class.getName();
302
303             StringUtils stringUtils = StringUtils.getInstance();
304
305             String JavaDoc subClassName = stringUtils.stripPackageName(fqnSubClass);
306             String JavaDoc subPackageName = stringUtils.stripClass(fqnSubClass);
307
308             String JavaDoc superClassName = superPrefix
309                     + stringUtils.stripPackageName(fqnSubClass);
310
311             String JavaDoc superPackageName = this.superPkg;
312             String JavaDoc fqnSuperClass = superPackageName + "." + superClassName;
313
314             Writer JavaDoc superOut = openWriter(entity, superPackageName, superClassName);
315
316             if (superOut != null) {
317                 superGenSetup.generateClass(
318                         superOut,
319                         dataMap,
320                         entity,
321                         fqnBaseClass,
322                         fqnSuperClass,
323                         fqnSubClass);
324                 closeWriter(superOut);
325             }
326
327             Writer JavaDoc mainOut = openWriter(entity, subPackageName, subClassName);
328             if (mainOut != null) {
329                 mainGenSetup.generateClass(
330                         mainOut,
331                         dataMap,
332                         entity,
333                         fqnBaseClass,
334                         fqnSuperClass,
335                         fqnSubClass);
336                 closeWriter(mainOut);
337             }
338         }
339     }
340
341     /**
342      * Runs class generation. Produces a pair of Java classes for each ObjEntity in the
343      * map. This allows developers to use generated <b>subclass </b> for their custom
344      * code, while generated <b>superclass </b> will contain Cayenne code. Superclass will
345      * be generated in the same package, its class name will be derived from the class
346      * name by adding a <code>superPrefix</code>.
347      */

348     private void generateClassPairs_1_2(
349             String JavaDoc classTemplate,
350             String JavaDoc superTemplate,
351             String JavaDoc superPrefix) throws Exception JavaDoc {
352
353         ClassGenerator mainGenSetup = new ClassGenerator(
354                 classTemplate,
355                 versionString,
356                 vppConfig);
357         ClassGenerator superGenSetup = new ClassGenerator(
358                 superTemplate,
359                 versionString,
360                 vppConfig);
361
362         // Iterate only once if this is datamap mode
363
Iterator JavaDoc it = objEntities.iterator();
364         if (MODE_ENTITY.equals(mode)) {
365             it = objEntities.iterator();
366         }
367         else {
368             if (objEntities.isEmpty()) {
369                 it = objEntities.iterator();
370             }
371             else {
372                 it = Collections.singleton(objEntities.get(0)).iterator();
373             }
374         }
375
376         while (it.hasNext()) {
377             ObjEntity ent = (ObjEntity) it.next();
378
379             String JavaDoc fqnSubClass = ent.getClassName();
380             String JavaDoc fqnBaseClass = (null != ent.getSuperClassName()) ? ent
381                     .getSuperClassName() : CayenneDataObject.class.getName();
382
383             StringUtils stringUtils = StringUtils.getInstance();
384
385             String JavaDoc subClassName = stringUtils.stripPackageName(fqnSubClass);
386             String JavaDoc subPackageName = stringUtils.stripClass(fqnSubClass);
387
388             String JavaDoc superClassName = superPrefix
389                     + stringUtils.stripPackageName(fqnSubClass);
390
391             String JavaDoc superPackageName = this.superPkg;
392             String JavaDoc fqnSuperClass = superPackageName + "." + superClassName;
393
394             Writer JavaDoc superOut = openWriter(ent, superPackageName, superClassName);
395
396             if (superOut != null) {
397                 superGenSetup.generateClass(
398                         superOut,
399                         dataMap,
400                         ent,
401                         fqnBaseClass,
402                         fqnSuperClass,
403                         fqnSubClass);
404                 closeWriter(superOut);
405             }
406
407             Writer JavaDoc mainOut = openWriter(ent, subPackageName, subClassName);
408             if (mainOut != null) {
409                 mainGenSetup.generateClass(
410                         mainOut,
411                         dataMap,
412                         ent,
413                         fqnBaseClass,
414                         fqnSuperClass,
415                         fqnSubClass);
416                 closeWriter(mainOut);
417             }
418         }
419     }
420
421     /**
422      * Runs class generation. Produces a single Java class for each ObjEntity in the map.
423      * Uses default Cayenne templates for classes.
424      */

425     public void generateSingleClasses() throws Exception JavaDoc {
426         generateSingleClasses(defaultSingleClassTemplate(), SUPERCLASS_PREFIX);
427     }
428
429     /**
430      * Runs class generation. Produces a single Java class for each ObjEntity in the map.
431      */

432     private void generateSingleClasses_1_1(String JavaDoc classTemplate) throws Exception JavaDoc {
433         ClassGenerator gen = new ClassGenerator(classTemplate, versionString);
434
435         // Iterate only once if this is datamap mode
436
Iterator JavaDoc it = objEntities.iterator();
437         if (MODE_ENTITY.equals(mode)) {
438             it = objEntities.iterator();
439         }
440         else {
441             if (objEntities.isEmpty()) {
442                 it = objEntities.iterator();
443             }
444             else {
445                 it = Collections.singleton(objEntities.get(0)).iterator();
446             }
447         }
448
449         while (it.hasNext()) {
450             ObjEntity ent = (ObjEntity) it.next();
451
452             initClassGenerator_1_1(gen.getClassGenerationInfo(), ent, false);
453             Writer JavaDoc out = openWriter(
454                     ent,
455                     gen.getClassGenerationInfo().getPackageName(),
456                     gen.getClassGenerationInfo().getClassName());
457             if (out == null) {
458                 continue;
459             }
460
461             gen.generateClass(out, ent);
462             closeWriter(out);
463         }
464     }
465
466     /**
467      * Runs class generation. Produces a single Java class for each ObjEntity in the map.
468      */

469     private void generateSingleClasses_1_2(String JavaDoc classTemplate, String JavaDoc superPrefix)
470             throws Exception JavaDoc {
471         ClassGenerator gen = new ClassGenerator(classTemplate, versionString, vppConfig);
472
473         // Iterate only once if this is datamap mode
474
Iterator JavaDoc it = objEntities.iterator();
475         if (MODE_ENTITY.equals(mode)) {
476             it = objEntities.iterator();
477         }
478         else {
479             if (objEntities.isEmpty()) {
480                 it = objEntities.iterator();
481             }
482             else {
483                 it = Collections.singleton(objEntities.get(0)).iterator();
484             }
485         }
486
487         while (it.hasNext()) {
488             ObjEntity ent = (ObjEntity) it.next();
489
490             String JavaDoc fqnSubClass = ent.getClassName();
491             String JavaDoc fqnBaseClass = (null != ent.getSuperClassName()) ? ent
492                     .getSuperClassName() : CayenneDataObject.class.getName();
493
494             StringUtils stringUtils = StringUtils.getInstance();
495
496             String JavaDoc subClassName = stringUtils.stripPackageName(fqnSubClass);
497             String JavaDoc subPackageName = stringUtils.stripClass(fqnSubClass);
498
499             String JavaDoc superClassName = superPrefix
500                     + stringUtils.stripPackageName(fqnSubClass);
501
502             String JavaDoc superPackageName = this.superPkg;
503             String JavaDoc fqnSuperClass = superPackageName + "." + superClassName;
504
505             Writer JavaDoc out = openWriter(ent, subPackageName, subClassName);
506             if (out == null) {
507                 continue;
508             }
509
510             gen
511                     .generateClass(
512                             out,
513                             dataMap,
514                             ent,
515                             fqnBaseClass,
516                             fqnSuperClass,
517                             fqnSubClass);
518             closeWriter(out);
519         }
520     }
521
522     /**
523      * Runs class generation. Produces a single Java class for each ObjEntity in the map.
524      */

525     public void generateSingleClasses(String JavaDoc classTemplate, String JavaDoc superPrefix)
526             throws Exception JavaDoc {
527         // note - client templates ignore version and automatically switch to 1.2
528
if (client) {
529             generateSingleClasses_1_2(classTemplate, superPrefix);
530         }
531         else if (VERSION_1_1.equals(versionString)) {
532             generateSingleClasses_1_1(classTemplate);
533         }
534         else if (VERSION_1_2.equals(versionString)) {
535             generateSingleClasses_1_2(classTemplate, superPrefix);
536         }
537         else {
538             throw new IllegalStateException JavaDoc("Illegal Version in generateClassPairs: "
539                     + versionString);
540         }
541     }
542
543     /** Initializes ClassGenerationInfo with class name and package of a generated class. */
544     protected void initClassGenerator_1_1(
545             ClassGenerationInfo gen,
546             ObjEntity entity,
547             boolean superclass) {
548
549         // figure out generator properties
550
String JavaDoc fullClassName = entity.getClassName();
551         int i = fullClassName.lastIndexOf(".");
552
553         String JavaDoc pkg = null;
554         String JavaDoc spkg = null;
555         String JavaDoc cname = null;
556
557         // dot in first or last position is invalid
558
if (i == 0 || i + 1 == fullClassName.length()) {
559             throw new CayenneRuntimeException("Invalid class mapping: " + fullClassName);
560         }
561         else if (i < 0) {
562             pkg = (superclass) ? superPkg : null;
563             spkg = (superclass) ? null : superPkg;
564             cname = fullClassName;
565         }
566         else {
567             cname = fullClassName.substring(i + 1);
568             pkg = (superclass && superPkg != null) ? superPkg : fullClassName.substring(
569                     0,
570                     i);
571
572             spkg = (!superclass && superPkg != null && !pkg.equals(superPkg))
573                     ? superPkg
574                     : null;
575         }
576
577         // init generator
578
gen.setPackageName(pkg);
579         gen.setClassName(cname);
580         if (entity.getSuperClassName() != null) {
581             gen.setSuperClassName(entity.getSuperClassName());
582         }
583         else {
584             gen.setSuperClassName(CayenneDataObject.class.getName());
585         }
586         gen.setSuperPackageName(spkg);
587     }
588
589     /**
590      * Returns "superPkg" property value - a name of a superclass package that should be
591      * used for all generated superclasses.
592      */

593     public String JavaDoc getSuperPkg() {
594         return superPkg;
595     }
596
597     /**
598      * Sets "superPkg" property value.
599      */

600     public void setSuperPkg(String JavaDoc superPkg) {
601         this.superPkg = superPkg;
602     }
603
604     /**
605      * Returns whether a default client object template will be used.
606      *
607      * @since 1.2
608      */

609     public boolean isClient() {
610         return client;
611     }
612
613     /**
614      * Sets whether a default client object template should be used.
615      *
616      * @since 1.2
617      */

618     public void setClient(boolean client) {
619         this.client = client;
620     }
621
622     /**
623      * @return Returns the dataMap.
624      */

625     public DataMap getDataMap() {
626         return dataMap;
627     }
628
629     /**
630      * @param dataMap The dataMap to set.
631      */

632     public void setDataMap(DataMap dataMap) {
633         this.dataMap = dataMap;
634     }
635
636     public List JavaDoc getObjEntities() {
637         return objEntities;
638     }
639
640     /**
641      * Initializes internal ObjEntities list. This method creates a copy of the provided
642      * list to allow its indepdendent modification and also filters out entities that do
643      * not require class generation.
644      */

645     public void setObjEntities(List JavaDoc objEntities) {
646         this.objEntities = objEntities != null
647                 ? new ArrayList JavaDoc(objEntities)
648                 : new ArrayList JavaDoc();
649
650         // remove generic entities...
651
Iterator JavaDoc it = objEntities.iterator();
652         while (it.hasNext()) {
653             ObjEntity e = (ObjEntity) it.next();
654             if (e.isGeneric()) {
655                 it.remove();
656             }
657         }
658     }
659
660     /**
661      * @return Returns the versionString.
662      */

663     public String JavaDoc getVersionString() {
664         return versionString;
665     }
666
667     /**
668      * @param versionString The versionString to set.
669      */

670     public void setVersionString(String JavaDoc versionString) {
671         if ((false == VERSION_1_1.equals(versionString))
672                 && (false == VERSION_1_2.equals(versionString))) {
673             throw new IllegalStateException JavaDoc("'version' must be '"
674                     + VERSION_1_1
675                     + "' or '"
676                     + VERSION_1_2
677                     + "', but was '"
678                     + versionString
679                     + "'");
680         }
681         this.versionString = versionString;
682     }
683
684     /**
685      * @return Returns the vppConfig.
686      */

687     public VPPConfig getVppConfig() {
688         return vppConfig;
689     }
690
691     /**
692      * @param vppConfig The vppConfig to set.
693      */

694     public void setVppConfig(VPPConfig vppConfig) {
695         this.vppConfig = vppConfig;
696     }
697
698     /**
699      * @param mode use "entity" for per-entity generation and "datamap" for per-datamap
700      * generation.
701      */

702     public void setMode(String JavaDoc mode) {
703         if ((false == MODE_ENTITY.equals(mode)) && (false == MODE_DATAMAP.equals(mode))) {
704             throw new IllegalStateException JavaDoc("'mode' must be '"
705                     + MODE_ENTITY
706                     + "' or '"
707                     + MODE_DATAMAP
708                     + "', but was '"
709                     + mode
710                     + "'");
711         }
712         this.mode = mode;
713     }
714 }
715
Popular Tags