1 20 package org.objectweb.modfact.jmi.api; 21 22 import javax.jmi.model.Attribute; 23 import javax.jmi.model.Constant; 24 import javax.jmi.model.ModelElement; 25 import javax.jmi.model.MofClass; 26 import javax.jmi.model.Operation; 27 import javax.jmi.model.Reference; 28 import javax.jmi.model.ScopeKindEnum; 29 import javax.jmi.model.VisibilityKindEnum; 30 31 import org.objectweb.modfact.jmi.helper.JMIProvider; 32 import org.objectweb.modfact.jmi.helper.MofHelper; 33 import org.objectweb.modfact.jmi.logging.ModFactLogger; 34 35 39 public class InstanceInterfaceGenerator extends CommonGenerator { 40 MofClass[] input; 41 42 ModFactLogger logger; 43 44 47 public void setInput(ModelElement[] elt) { 48 input = new MofClass[elt.length]; 49 for (int i = 0; i < input.length; i++) { 50 input[i] = (MofClass) elt[i]; 51 } 52 } 53 54 57 public void setLogger(ModFactLogger log) { 58 logger = log; 59 } 60 61 64 public void generate() { 65 66 MofClass c = input[0]; 67 68 outputln( 69 "package " + JMIProvider.qualifierOf(c) + ";" ); 70 71 output("public interface " + JMIProvider.jmiClassName(c)); 72 73 MofClass[] supertypes = (MofClass[])c.getSupertypes().toArray(new MofClass[0]); 74 if (supertypes.length == 0) { 76 outputln(" extends javax.jmi.reflect.RefObject {"); 77 } else { 79 output(" extends "); 80 for (int i = 0; i < supertypes.length; i++) { 81 if (i != 0) out.print(" ,"); 82 output( 83 JMIProvider.jmiClassQualifiedName(supertypes[i]) ); 84 } 85 outputln("{"); 86 } 87 88 Constant[] constants = MofHelper.constantsOfClass(c); 90 for (int i = 0; i < constants.length; i++) { 91 constantTemplate(constants[i]); 92 } 93 94 100 Attribute[] attributes_nd = 101 MofHelper.attributesOfClass( 102 c ,ScopeKindEnum.forName("instance_level"), false); 103 104 for (int i = 0; i < attributes_nd.length; i++) { 105 attributeTemplate(attributes_nd[i]); 106 } 107 108 Reference[] references = MofHelper.referencesOfClass(c, false); 110 for (int i = 0; i < references.length; i++) { 111 referenceTemplate(references[i]); 112 } 113 114 Operation[] operations = MofHelper.operationsOfClass(c, ScopeKindEnum.INSTANCE_LEVEL, false ); 116 for (int i = 0; i < operations.length; i++) { 117 if (operations[i].getVisibility().equals(VisibilityKindEnum.PUBLIC_VIS)) 118 operationTemplate(operations[i]); 119 } 120 121 outputln("}"); flushFile(); 124 } 125 } 126 | Popular Tags |