1 25 26 package org.objectweb.jorm.mapper.rdb.lib; 27 28 import java.io.FileWriter ; 29 import java.io.IOException ; 30 31 import org.objectweb.jorm.api.PException; 32 import org.objectweb.jorm.api.PExceptionIO; 33 34 39 public class RdbScriptPMSM extends RdbPMappingStructuresManager implements 40 RdbScriptWriter { 41 42 private boolean writeScript = false; 43 private String fileName; 44 45 public RdbScriptPMSM(String fileName, boolean writeScript) { 46 this.fileName = fileName; 47 this.writeScript = writeScript; 48 } 49 50 54 public void init() throws PException { 55 if (fileName == null) { 56 throw new PException("A file name must be specified before calling the init method."); 57 } 58 if (writeScript) { 59 try { 60 FileWriter writer = new FileWriter (fileName, false); 62 writer.write(""); 63 writer.close(); 64 } catch (IOException ioe) { 65 throw new PExceptionIO(ioe, "Problem while creating the database creation script file."); 66 } 67 } 68 } 69 70 public String getFileName() { 71 return fileName; 72 } 73 public void setFileName(String fileName) { 74 this.fileName = fileName; 75 } 76 77 public boolean isWriteScript() { 78 return writeScript; 79 } 80 public void setWriteScript(boolean writeScript) { 81 this.writeScript = writeScript; 82 } 83 84 } 85 | Popular Tags |