1 20 package org.objectweb.modfact.jmi.xmiio.exporter; 21 22 import java.io.ByteArrayOutputStream ; 23 import java.io.IOException ; 24 import org.objectweb.modfact.jmi.logging.Level; 25 import org.objectweb.modfact.jmi.logging.ModFactLogger; 26 27 import javax.jmi.model.ModelElement; 28 import javax.jmi.model.MofPackage; 29 import javax.jmi.model.VisibilityKindEnum; 30 31 import org.objectweb.modfact.jmi.generator.ZipGenerator; 32 import org.objectweb.modfact.jmi.helper.JMIProvider; 33 34 38 public class JMI1_0ExportGenerator extends ZipGenerator { 39 40 MofPackage[] input; 41 42 ModFactLogger logger; 43 44 47 public void setInput(ModelElement[] elt) { 48 input = new MofPackage[elt.length]; 49 for (int i = 0; i < input.length; i++) { 50 input[i] = (MofPackage) elt[i]; 51 } 52 } 53 54 57 public void setLogger(ModFactLogger log) { 58 logger = log; 59 } 60 61 public JMI1_0ExportGenerator() { 62 } 63 64 67 public void generate() 68 throws IOException { 69 logger.log(Level.FINE, "Begin generation of JMI Exporter"); 70 71 for (int p = 0; p < input.length; p++) { 72 if (input[p] 73 .getVisibility() 74 .equals(VisibilityKindEnum.forName("public_vis")) 75 && input[p].refGetValue("container") == null) { 76 77 MofPackage[] param = new MofPackage[1]; 79 param[0] = input[p]; 80 81 String path = JMIProvider.qualifierOf(input[p]); 82 path = path.replace('.', '/') +"/"; 83 String className = JMIProvider.jmiPackageExtentName(input[p]) + "XMIExport"; 84 String baseFileName = path + className; 85 86 GenerationXMIExport exportGenerator = new GenerationXMIExport(); 87 ByteArrayOutputStream entryOutput1 = new ByteArrayOutputStream (); 88 exportGenerator.setOutput(entryOutput1); 89 exportGenerator.generateXMIExport(param[0], className); 90 writeEntry(baseFileName + ".java", entryOutput1); 91 entryOutput1.close(); 92 93 logger.log(Level.FINE, "Exporter is generated"); 94 } 95 } 96 out.finish(); 97 logger.log(Level.FINE, " Generation is completed without error"); 98 } 99 100 } 101 | Popular Tags |