KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > Connector > EEG > CodeWriter > CDL2JavaMapping


1 /*
2  * CDL2JavaMapping.java
3  *
4  * Created on 7. duben 2002, 10:23
5  */

6
7 package SOFA.Connector.EEG.CodeWriter;
8
9 import SOFA.SOFAnode.Made.TIR.AbsoluteName;
10 import SOFA.SOFAnode.Made.TIR.CDLType;
11 import SOFA.SOFAnode.Made.TIR.ParamMode;
12
13 /**
14  *
15  * @author ghort
16  * @version
17  */

18 public class CDL2JavaMapping {
19
20     static protected SOFA.SOFAnode.Made.CodeGen.JavaMapping mapping;
21
22     static public String JavaDoc getTypeName(CDLType cdlType, int paramMode) throws CodeWriterException {
23         if (mapping==null) {
24             mapping=new SOFA.SOFAnode.Made.CodeGen.JavaMapping();
25         }
26         String JavaDoc ret;
27
28         if (paramMode==ParamMode.PARAM_IN) {
29             ret=mapping.getImplTypeName(cdlType);
30         } else {
31             ret=mapping.getImplTypeHolderName(cdlType);
32         }
33
34         if (ret==null) {
35             throw new CodeWriterException("Cannot map CDL type to Java.");
36         }
37         return ret;
38     }
39
40     static public String JavaDoc getAbsoluteName(AbsoluteName an) throws CodeWriterException {
41         try {
42             int i, size=an.size();
43             String JavaDoc ret=an.elementAt(0);
44             for (i=1;i<size;i++) {
45                 ret+="."+an.elementAt(i);
46             }
47             return ret;
48         } catch (java.rmi.RemoteException JavaDoc e) {
49             throw new CodeWriterException("Can't access TIR.",e);
50         }
51     }
52 }
53
Popular Tags