KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * CDL2IDL2JavaMapping.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 CDL2IDL2JavaMapping {
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             // FIXME, zatim to funguje jen pro prim. typy, takze muzeme predpokladat, ze vsechny holdery jsou
33
// v package cz.cuni.sofa.lib
34
ret="org.omg.CORBA"+ret.substring("cz.cuni.sofa.lib".length());
35         }
36
37         if (ret==null) {
38             throw new CodeWriterException("Cannot map CDL->IDL type to Java.");
39         }
40         return ret;
41     }
42
43     static public String JavaDoc getAbsoluteName(AbsoluteName an) throws CodeWriterException {
44         try {
45             int i, size=an.size();
46             String JavaDoc ret=an.elementAt(0);
47             for (i=1;i<size;i++) {
48                 ret+="."+an.elementAt(i);
49             }
50             return ret;
51         } catch (java.rmi.RemoteException JavaDoc e) {
52             throw new CodeWriterException("Can't access TIR.",e);
53         }
54     }
55 }
56
Popular Tags