KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * JIfaceCNCORBA.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.CDL2IDL2JavaMapping;
10 import SOFA.Connector.EEG.CodeWriter.CDL2JavaMapping;
11 import SOFA.Connector.EEG.CodeWriter.JWriterDirectorException;
12 import SOFA.SOFAnode.Made.TIR.ExceptionDef;
13 import SOFA.SOFAnode.Made.TIR.OperationDef;
14 import SOFA.SOFAnode.Made.TIR.ParamDescr;
15 import SOFA.SOFAnode.Made.TIR.ParamMode;
16 import SOFA.SOFAnode.Made.TIR.TIRExceptLock;
17
18 /**
19  *
20  * @author ghort
21  * @version
22  */

23 public class JIfaceCNCORBA {
24     public static String JavaDoc targetCallParams(OperationDef method) throws JWriterDirectorException {
25         try {
26             StringBuffer JavaDoc ret=new StringBuffer JavaDoc();
27             
28             int j;
29             ParamDescr[] params=method.params();
30             for (j=0;j<params.length;j++) {
31                 if (j>0) {
32                     ret.append(", ");
33                 }
34                 
35                 int mode=params[j].mode().value();
36                 if (mode==ParamMode.PARAM_INOUT || mode==ParamMode.PARAM_OUT) {
37                     ret.append("_corbaholder_");
38                 }
39                 ret.append(params[j].name());
40             }
41             if (j>0) {
42                 ret.append(", ");
43             }
44             ret.append("thr_id");
45             return ret.toString();
46         } catch (java.rmi.RemoteException JavaDoc e) {
47             throw new JWriterDirectorException("Cannot access TIR.",e);
48         } catch (TIRExceptLock e) {
49             throw new JWriterDirectorException("Cannot access TIR.",e);
50         }
51     }
52     
53     public static String JavaDoc getMethodDef(OperationDef mt) throws JWriterDirectorException {
54         try {
55             StringBuffer JavaDoc ret=new StringBuffer JavaDoc(CDL2IDL2JavaMapping.getTypeName(mt.result(),ParamMode.PARAM_IN)+" "+mt.get_identification().name()+"(");
56             
57             int j;
58             ParamDescr[] params=mt.params();
59             for (j=0;j<params.length;j++) {
60                 if (j>0) {
61                     ret.append(", ");
62                 }
63                 ret.append(CDL2IDL2JavaMapping.getTypeName(params[j].type(),params[j].mode().value())+" ");
64                 
65                 int mode=params[j].mode().value();
66                 if (mode==ParamMode.PARAM_INOUT || mode==ParamMode.PARAM_OUT) {
67                     ret.append("_corbaholder_");
68                 }
69                 ret.append(params[j].name());
70             }
71             if (j>0) {
72                 ret.append(", ");
73             }
74             ret.append("String thr_id");
75             ret.append(")");
76             
77             ExceptionDef[] exceptions=mt.exceptions();
78             for (j=0;j<exceptions.length;j++) {
79                 if (j==0) {
80                     ret.append(" throws ");
81                 } else {
82                     ret.append(", ");
83                 }
84                 ret.append(CDL2JavaMapping.getAbsoluteName(exceptions[j].get_identification().absolute_name()));
85             }
86             return ret.toString();
87         } catch (Exception JavaDoc e) {
88             throw new JWriterDirectorException("Cannot create method declaration.",e);
89         }
90     }
91 }
92
Popular Tags