KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > Connector > EEG > EEM > Actions > JIfaceCN


1 /*
2  * JIfaceCN.java
3  *
4  * Created on 13. duben 2002, 21:08
5  */

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 /**
18  *
19  * @author ghort
20  * @version
21  */

22 public class JIfaceCN {
23     public static String JavaDoc targetCallParams(OperationDef method) throws JWriterDirectorException {
24         try {
25             StringBuffer JavaDoc ret=new StringBuffer JavaDoc();
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             if (j>0) {
36                 ret.append(", ");
37             }
38             ret.append("thr_id");
39             return ret.toString();
40         } catch (java.rmi.RemoteException JavaDoc e) {
41             throw new JWriterDirectorException("Cannot access TIR.",e);
42         } catch (TIRExceptLock e) {
43             throw new JWriterDirectorException("Cannot access TIR.",e);
44         }
45     }
46     
47     public static String JavaDoc getMethodDef(OperationDef mt) throws JWriterDirectorException {
48         try {
49             StringBuffer JavaDoc ret=new StringBuffer JavaDoc(CDL2JavaMapping.getTypeName(mt.result(),ParamMode.PARAM_IN)+" "+mt.get_identification().name()+"(");
50             
51             int j;
52             ParamDescr[] params=mt.params();
53             for (j=0;j<params.length;j++) {
54                 if (j>0) {
55                     ret.append(", ");
56                 }
57                 ret.append(CDL2JavaMapping.getTypeName(params[j].type(),params[j].mode().value())+" "+params[j].name());
58             }
59             if (j>0) {
60                 ret.append(", ");
61             }
62             ret.append("String thr_id");
63             ret.append(")");
64             
65             ExceptionDef[] exceptions=mt.exceptions();
66             for (j=0;j<exceptions.length;j++) {
67                 if (j==0) {
68                     ret.append(" throws ");
69                 } else {
70                     ret.append(", ");
71                 }
72                 ret.append(CDL2JavaMapping.getAbsoluteName(exceptions[j].get_identification().absolute_name()));
73             }
74             return ret.toString();
75         } catch (Exception JavaDoc e) {
76             throw new JWriterDirectorException("Cannot create method declaration.",e);
77         }
78     }
79 }
80
Popular Tags