1 56 package org.objectstyle.cayenne.project; 57 58 import java.io.PrintWriter ; 59 60 import org.objectstyle.cayenne.conf.ConfigSaver; 61 import org.objectstyle.cayenne.conf.ConfigSaverDelegate; 62 import org.objectstyle.cayenne.conf.Configuration; 63 import org.objectstyle.cayenne.conf.RuntimeSaveDelegate; 64 65 73 public class ApplicationProjectFile extends ProjectFile { 74 protected ConfigSaverDelegate saveDelegate; 75 76 private String objectName = null; 77 78 private ApplicationProjectFile() { 79 super(); 80 } 81 82 85 public ApplicationProjectFile(Project project) { 86 this(project, Configuration.DEFAULT_DOMAIN_FILE); 87 } 88 89 92 public ApplicationProjectFile(Project project, String fileName) { 93 super(project, fileName); 94 this.objectName = fileName.substring(0, fileName.lastIndexOf(this.getLocationSuffix())); 95 } 96 97 102 public String getLocationSuffix() { 103 return ".xml"; 104 } 105 106 109 public Object getObject() { 110 return getProject(); 111 } 112 113 116 public String getObjectName() { 117 return this.objectName; 118 } 119 120 public void save(PrintWriter out) throws Exception { 121 ConfigSaverDelegate localDelegate = 122 (saveDelegate != null) 123 ? saveDelegate 124 : new RuntimeSaveDelegate(((ApplicationProject) projectObj).getConfiguration()); 125 new ConfigSaver(localDelegate).storeDomains(out); 126 } 127 128 public boolean canHandle(Object obj) { 129 return obj instanceof ApplicationProject; 130 } 131 132 136 public ConfigSaverDelegate getSaveDelegate() { 137 return saveDelegate; 138 } 139 140 144 public void setSaveDelegate(ConfigSaverDelegate saveDelegate) { 145 this.saveDelegate = saveDelegate; 146 } 147 } 148 | Popular Tags |