1 26 27 package org.objectweb.openccm.pss.generator.common.lib; 28 29 31 import org.objectweb.openccm.ast.api.PsdlOperationDecl; 32 import org.objectweb.openccm.ast.api.Parameter; 33 import org.objectweb.openccm.ast.api.ExceptionDecl; 34 35 import org.objectweb.openccm.generator.java.ast.api.*; 36 import org.objectweb.openccm.generator.java.ast.lib.*; 37 38 import org.objectweb.openccm.generator.translator.idl2java.api.PSDL_JavaTranslator; 39 40 41 48 49 public class PSDLOperationMapping 50 implements org.objectweb.openccm.pss.generator.common.api.PSDLOperationMapping 51 { 52 53 59 60 private PsdlOperationDecl op_; 61 62 68 71 72 public PSDLOperationMapping() 73 { 74 op_ = null; 76 } 77 78 84 90 95 public void 96 setOperation(PsdlOperationDecl op) 97 { 98 op_ = op; 99 } 100 101 107 public void 108 toJava(PSDL_JavaTranslator translator, 109 InterfaceObject obj) 110 { 111 MethodObject method = null; 112 ParameterObject param = null; 113 Parameter[] parameters = null; 114 ExceptionDecl[] exceptions = null; 115 116 method = new MethodObjectImpl(); 117 method.addComment("The "+op_.getName()+" method."); 118 method.setName(op_.getName()); 119 method.setReturnType( translator.toJava(op_.getType()) ); 120 121 parameters = op_.getParameterList().getParameters(); 123 for (int i=0; i<parameters.length; i++) 124 { 125 param = new ParameterObjectImpl(); 126 param.setName(parameters[i].getName()); 127 param.setType( translator.toJava(parameters[i].getType(), 128 parameters[i].getMode()) ); 129 method.addParameter(param); 130 } 131 132 exceptions = op_.getExceptionList().getExceptions(); 134 for (int i=0; i<exceptions.length; i++) 135 { 136 method.addException( translator.getAbsoluteName(exceptions[i]) ); 137 } 138 139 obj.addMethod(method); 140 } 141 } 142 | Popular Tags |