1 19 20 package org.apache.cayenne.project; 21 22 import java.io.PrintWriter ; 23 24 import org.apache.cayenne.map.DataMap; 25 26 32 public class DataMapFile extends ProjectFile { 33 public static final String LOCATION_SUFFIX = ".map.xml"; 34 35 protected DataMap map; 36 37 public DataMapFile() {} 38 39 42 public DataMapFile(Project project, DataMap map) { 43 super(project, map.getLocation()); 44 this.map = map; 45 } 46 47 50 public Object getObject() { 51 return map; 52 } 53 54 57 public String getObjectName() { 58 return map.getName(); 59 } 60 61 public void save(PrintWriter out) throws Exception { 62 map.encodeAsXML(out); 63 } 64 65 68 public boolean canHandle(Object obj) { 69 return obj instanceof DataMap; 70 } 71 72 75 public void willSave() { 76 super.willSave(); 77 78 if (map != null) { 79 map.setLocation(getLocation()); 80 } 81 } 82 83 86 public String getLocationSuffix() { 87 return LOCATION_SUFFIX; 88 } 89 } 90 | Popular Tags |