1 19 20 package org.apache.cayenne.project; 21 22 import java.io.PrintWriter ; 23 24 import org.apache.cayenne.conf.ConfigSaver; 25 import org.apache.cayenne.conf.ConfigSaverDelegate; 26 import org.apache.cayenne.conf.Configuration; 27 import org.apache.cayenne.conf.RuntimeSaveDelegate; 28 29 36 public class ApplicationProjectFile extends ProjectFile { 37 38 protected ConfigSaverDelegate saveDelegate; 39 40 private String objectName = null; 41 42 private ApplicationProjectFile() { 43 super(); 44 } 45 46 49 public ApplicationProjectFile(Project project) { 50 this(project, Configuration.DEFAULT_DOMAIN_FILE); 51 } 52 53 56 public ApplicationProjectFile(Project project, String fileName) { 57 super(project, fileName); 58 this.objectName = fileName.substring(0, fileName.lastIndexOf(this 59 .getLocationSuffix())); 60 } 61 62 66 public String getLocationSuffix() { 67 return ".xml"; 68 } 69 70 73 public Object getObject() { 74 return getProject(); 75 } 76 77 80 public String getObjectName() { 81 return this.objectName; 82 } 83 84 public void save(PrintWriter out) throws Exception { 85 ConfigSaverDelegate localDelegate = (saveDelegate != null) 86 ? saveDelegate 87 : new RuntimeSaveDelegate(((ApplicationProject) projectObj) 88 .getConfiguration()); 89 new ConfigSaver(localDelegate).storeDomains(out); 90 } 91 92 public boolean canHandle(Object obj) { 93 return obj instanceof ApplicationProject; 94 } 95 96 101 public ConfigSaverDelegate getSaveDelegate() { 102 return saveDelegate; 103 } 104 105 110 public void setSaveDelegate(ConfigSaverDelegate saveDelegate) { 111 this.saveDelegate = saveDelegate; 112 } 113 } 114 | Popular Tags |