KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * JIfaceNormal.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 JIfaceNormal {
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             return ret.toString();
36         } catch (java.rmi.RemoteException JavaDoc 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 JavaDoc getMethodDef(OperationDef mt) throws JWriterDirectorException {
44         try {
45             StringBuffer JavaDoc ret=new StringBuffer JavaDoc(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 JavaDoc e) {
68             throw new JWriterDirectorException("Cannot create method declaration.",e);
69         }
70     }
71 }
72
Popular Tags