1 19 20 package org.netbeans.mdrant; 21 22 import java.io.File ; 23 import java.io.FileOutputStream ; 24 25 import javax.jmi.reflect.*; 26 27 import org.apache.tools.ant.BuildException; 28 29 import org.netbeans.api.xmi.XMIWriterFactory; 30 import org.netbeans.api.xmi.XMIWriter; 31 32 36 public class WriteXMI extends MdrTask.Sub { 37 38 private static final String DEFAULT_XMI_VERSION = "1.2"; 39 40 private File file; 42 private String extent; 44 private String xmiVersion; 45 46 47 public WriteXMI() { 48 } 49 50 public void execute() throws Exception { 51 52 if ( file == null ) { 53 throw new BuildException( "Export file has to be sppecified. Use the \"file\" attribute" ); 54 } 55 56 if ( extent == null ) { 57 throw new BuildException( "Extent to export has to be sppecified. Use the \"extent\" attribute" ); 58 } 59 60 if ( xmiVersion == null ) { 61 xmiVersion = DEFAULT_XMI_VERSION; 62 } 63 64 XMIWriter xmiWriter = XMIWriterFactory.getDefault().createXMIWriter(); 65 xmiWriter.write( new FileOutputStream ( file ), getRepository().getExtent( extent ), xmiVersion ); 66 67 } 68 69 71 public void setFile( File file ) { 72 this.file = file; 73 } 74 75 public void setExtent( String extent ) { 76 this.extent = extent; 77 } 78 79 public void setXmiVersion( String xmiVersion ) { 80 this.xmiVersion = xmiVersion; 81 } 82 83 84 } 85 | Popular Tags |