KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectstyle > cayenne > modeler > pref > DataMapDefaults


1 package org.objectstyle.cayenne.modeler.pref;
2
3 import org.objectstyle.cayenne.PersistenceState;
4
5 public class DataMapDefaults extends _DataMapDefaults {
6     
7     public static final String JavaDoc DEFAULT_SUPERCLASS_PACKAGE = "auto";
8
9     public void setPersistenceState(int persistenceState) {
10
11         // init defaults on insert...
12
if (this.persistenceState == PersistenceState.TRANSIENT
13                 && persistenceState == PersistenceState.NEW) {
14             setGeneratePairs(Boolean.TRUE);
15             setSuperclassPackageSuffix(DEFAULT_SUPERCLASS_PACKAGE);
16         }
17         super.setPersistenceState(persistenceState);
18     }
19
20     public String JavaDoc getSuperclassPackage() {
21         return getSuperclassPackageSuffix();
22     }
23
24     public void setSuperclassPackage(String JavaDoc superclassPackage) {
25         // TODO: rename "SuperclassPackageSuffix" to "SuperclassPackage"
26
setSuperclassPackageSuffix(superclassPackage);
27     }
28
29     /**
30      * Sets superclass package, building it by "normalizing" and concatenating prefix and
31      * suffix.
32      */

33     public void setSuperclassPackage(String JavaDoc prefix, String JavaDoc suffix) {
34         if (prefix == null) {
35             prefix = "";
36         }
37         else if (prefix.endsWith(".")) {
38             prefix = prefix.substring(0, prefix.length() - 1);
39         }
40
41         if (suffix == null) {
42             suffix = "";
43         }
44         else if (suffix.startsWith(".")) {
45             suffix = suffix.substring(1);
46         }
47
48         String JavaDoc dot = (suffix.length() > 0 && prefix.length() > 0) ? "." : "";
49         setSuperclassPackage(prefix + dot + suffix);
50     }
51 }
52
53
Popular Tags