1 20 package org.objectweb.modfact.corba.xmiio.common; 21 22 import org.objectweb.modfact.corba.generator.BracketGenerator; 23 import org.omg.mof.Model.ModelElement; 24 import org.objectweb.modfact.corba.helper.IDLCommon; 25 import org.objectweb.modfact.corba.helper.JavaCommon; 26 import org.objectweb.modfact.corba.helper.MOFCommon; 27 import org.objectweb.modfact.corba.helper.StringHelper; 28 import org.objectweb.modfact.corba.helper.XMIImportCommon; 29 import org.objectweb.modfact.corba.logging.ModFactLogger; 30 import org.objectweb.modfact.corba.logging.Level; 31 32 public abstract class AbstractXMIIOGenerator extends BracketGenerator { 33 34 35 protected IDLCommon idlHelper; 36 37 38 protected MOFCommon mofHelper; 39 40 41 protected JavaCommon javaHelper; 42 43 44 protected XMIImportCommon xmiImpHelper; 45 46 47 protected boolean mappingValid; 48 49 50 protected ModFactLogger _logger = ModFactLogger.getLogger("fr.lip6.src.mdafactory.generation.xmiimport.GenerationXMIImportApplication"); 51 52 55 public void setInput(ModelElement[] elt) throws Exception { 56 } 58 59 62 public void setLogger(ModFactLogger log) throws Exception { 63 _logger = log; 64 } 65 66 69 public void generate() throws Exception { 70 } 72 73 77 public void annotationTemplate(String annotation_) throws org.omg.mof.Reflective.MofError { 78 79 if (annotation_.trim().length() > 0) { 80 String annotation = "/** \n" + StringHelper.replaceAll(annotation_.trim(), "\\\\n", "\n") + "\n/"; 81 annotation = StringHelper.replaceAll(annotation, "\\\\s", " "); 82 StringBuffer margin = new StringBuffer (); 83 for (int i = 0; i < level; i++) 84 margin.append(TABULATION); 85 annotation = StringHelper.replaceAll(annotation, "\n", "\n" + margin.toString() + " *"); 86 outputln(annotation); 87 } 88 } 89 90 96 protected String getClassName(String package_name_, String suffix_) { 97 _logger.log(Level.FINE, "getClassName(" + package_name_ + ")"); 98 String packageName1 = idlHelper.format1(package_name_); 99 String className = filename; 100 if (filename.trim().length() > 0) { 101 while (className.indexOf(java.io.File.separator) != -1) 102 className = className.substring(className.indexOf(java.io.File.separator) + 1); 103 if (className.lastIndexOf(".java") != -1) 104 className = className.substring(0, className.lastIndexOf(".java")); 105 } else { 106 className = packageName1 + suffix_; 107 } 108 return className; 109 } 110 111 114 public void setIdlHelper(IDLCommon common) { 115 idlHelper = common; 116 } 117 118 121 public void setJavaHelper(JavaCommon common) { 122 javaHelper = common; 123 } 124 125 128 public void setMappingValid(boolean b) { 129 mappingValid = b; 130 } 131 132 135 public void setMofHelper(MOFCommon common) { 136 mofHelper = common; 137 } 138 139 142 public void setXmiImpHelper(XMIImportCommon common) { 143 xmiImpHelper = common; 144 } 145 146 } 147 | Popular Tags |