1 6 7 package SOFA.Connector.EEG.EEM.Actions; 8 9 import SOFA.Connector.EEG.CodeWriter.CDL2JavaMapping; 10 import SOFA.Connector.EEG.CodeWriter.JWriterDirectorException; 11 import SOFA.SOFAnode.Made.TIR.ExceptionDef; 12 import SOFA.SOFAnode.Made.TIR.OperationDef; 13 import SOFA.SOFAnode.Made.TIR.ParamDescr; 14 import SOFA.SOFAnode.Made.TIR.ParamMode; 15 import SOFA.SOFAnode.Made.TIR.TIRExceptLock; 16 17 22 public class JIfaceNormal { 23 public static String targetCallParams(OperationDef method) throws JWriterDirectorException { 24 try { 25 StringBuffer ret=new StringBuffer (); 26 27 int j; 28 ParamDescr[] params=method.params(); 29 for (j=0;j<params.length;j++) { 30 if (j>0) { 31 ret.append(", "); 32 } 33 ret.append(params[j].name()); 34 } 35 return ret.toString(); 36 } catch (java.rmi.RemoteException e) { 37 throw new JWriterDirectorException("Cannot access TIR.",e); 38 } catch (TIRExceptLock e) { 39 throw new JWriterDirectorException("Cannot access TIR.",e); 40 } 41 } 42 43 public static String getMethodDef(OperationDef mt) throws JWriterDirectorException { 44 try { 45 StringBuffer ret=new StringBuffer (CDL2JavaMapping.getTypeName(mt.result(),ParamMode.PARAM_IN)+" "+mt.get_identification().name()+"("); 46 47 int j; 48 ParamDescr[] params=mt.params(); 49 for (j=0;j<params.length;j++) { 50 if (j>0) { 51 ret.append(", "); 52 } 53 ret.append(CDL2JavaMapping.getTypeName(params[j].type(),params[j].mode().value())+" "+params[j].name()); 54 } 55 ret.append(")"); 56 57 ExceptionDef[] exceptions=mt.exceptions(); 58 for (j=0;j<exceptions.length;j++) { 59 if (j==0) { 60 ret.append(" throws "); 61 } else { 62 ret.append(", "); 63 } 64 ret.append(CDL2JavaMapping.getAbsoluteName(exceptions[j].get_identification().absolute_name())); 65 } 66 return ret.toString(); 67 } catch (Exception e) { 68 throw new JWriterDirectorException("Cannot create method declaration.",e); 69 } 70 } 71 } 72 | Popular Tags |