1 package org.objectweb.modfact.jmi.impl; 2 3 import javax.jmi.model.Attribute; 4 import javax.jmi.model.ModelElement; 5 import javax.jmi.model.MofClass; 6 import javax.jmi.model.Operation; 7 import javax.jmi.model.Reference; 8 import javax.jmi.model.ScopeKindEnum; 9 import javax.jmi.model.VisibilityKindEnum; 10 11 import org.objectweb.modfact.jmi.helper.ImplHelper; 12 import org.objectweb.modfact.jmi.helper.JMIProvider; 13 import org.objectweb.modfact.jmi.helper.MofHelper; 14 import org.objectweb.modfact.jmi.logging.ModFactLogger; 15 16 17 21 public class InstanceImplementationGenerator extends CommonImplementationGenerator { 22 MofClass[] input; 23 24 ModFactLogger logger; 25 26 29 public void setInput(ModelElement[] elt) { 30 input = new MofClass[elt.length]; 31 for (int i = 0; i < input.length; i++) { 32 input[i] = (MofClass) elt[i]; 33 } 34 } 35 36 39 public void setLogger(ModFactLogger log) { 40 logger = log; 41 } 42 43 46 public void generate() { 47 48 MofClass c = input[0]; 49 50 outputln("package " +ImplHelper.implPrefix + JMIProvider.shortQualifierOf(c) + ";" ); 51 outputln("import " + JMIProvider.qualifierOf(c) + ".*;" ); 52 53 outputln("import org.objectweb.modfact.jmi.reflect.*;"); 54 55 output("public class " + JMIProvider.jmiClassName(c) +"Impl" 56 +" extends RefObjectImpl " 57 +"implements " 58 +JMIProvider.jmiClassQualifiedName(c) 59 +" {" ); 60 61 62 68 Attribute[] attributes_nd = 69 MofHelper.attributesOfClass( 70 c, 71 ScopeKindEnum.forName("instance_level"), true); 72 73 for (int i = 0; i < attributes_nd.length; i++) { 74 attributeTemplate(attributes_nd[i]); 75 } 76 77 Reference[] references = MofHelper.referencesOfClass( c, true ); 79 for (int i = 0; i < references.length; i++) { 80 referenceTemplate(references[i]); 81 } 82 83 Operation[] operations = MofHelper.operationsOfClass(c, ScopeKindEnum.INSTANCE_LEVEL, true ); 85 for (int i = 0; i < operations.length; i++) { 86 if (operations[i].getVisibility().equals(VisibilityKindEnum.PUBLIC_VIS)) 87 operationTemplate(operations[i]); 88 } 89 90 outputln("}"); flushFile(); 93 } 94 } 95 | Popular Tags |