KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > generator > translator > idl2java > lib > PSDL_JavaTranslator


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Christophe Demarey.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.generator.translator.idl2java.lib;
28
29 // Package dependencies.
30

31 /**
32  * This class translates some PSDL declarations to their java mapping.
33  *
34  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
35  *
36  * @version 0.1
37  */

38
39 public class PSDL_JavaTranslator
40      extends org.objectweb.openccm.generator.translator.idl2java.lib.IDL_JavaTranslator
41   implements org.objectweb.openccm.generator.translator.idl2java.api.PSDL_JavaTranslator
42 {
43     // ==================================================================
44
//
45
// Internal state.
46
//
47
// ==================================================================
48

49     // ==================================================================
50
//
51
// Constructors.
52
//
53
// ==================================================================
54

55     /**
56      * The default constructor.
57      **/

58     public PSDL_JavaTranslator()
59     {
60     }
61
62     // ==================================================================
63
//
64
// Internal methods.
65
//
66
// ==================================================================
67

68     // ==================================================================
69
//
70
// Public methods for org.objectweb.openccm.generator.translator.idl2java.api.PSDL_JavaTranslator.
71
//
72
// ==================================================================
73

74     /**
75      * Translate a PsdlTypeRef into its java mapping.
76      *
77      * @param type - The PsdlTypeRef to translate.
78      *
79      * @return The resulting mapping.
80      **/

81     public java.lang.String JavaDoc
82     toJava(org.objectweb.openccm.ast.api.PsdlTypeRef type)
83     {
84         org.objectweb.openccm.ast.api.TypeRef idl_type = null;
85         org.objectweb.openccm.ast.api.StorageTypeBase st_base = null;
86
87         if (type == null)
88         {
89             return "";
90         }
91         idl_type = type.getTypeRef();
92         if (idl_type != null)
93         {
94             return toJava(idl_type);
95         }
96         else
97         {
98             if (type.isRef())
99             { // type is a StorageType reference
100
return "byte[]";
101             }
102             else
103             { // type is a psdl type
104
st_base = type.getStorageTypeBase();
105                 return getAbsoluteName(st_base);
106             }
107         }
108     }
109
110     /**
111      * Translate a psdl parameter into its java mapping.
112      *
113      * @param type - The PsdlTypeRef to translate.
114      * @param mode - The parameter mode (in, out or inout).
115      *
116      * @return The resulting mapping.
117      **/

118     public java.lang.String JavaDoc
119     toJava(org.objectweb.openccm.ast.api.PsdlTypeRef type,
120            int mode)
121     {
122         org.objectweb.openccm.ast.api.TypeRef idl_type = null;
123         org.objectweb.openccm.ast.api.StorageTypeBase st_base = null;
124
125         if (type == null)
126         {
127             return "";
128         }
129         idl_type = type.getTypeRef();
130         if (idl_type != null)
131         {
132             return toJava(idl_type, mode);
133         }
134         else
135         {
136             if (type.isRef())
137             { // type is a StorageType reference
138
return "byte[]";
139             }
140             else
141             { // type is a psdl type
142
st_base = type.getStorageTypeBase();
143                 return getAbsoluteName(st_base)+"Holder";
144             }
145         }
146     }
147
148     /**
149      * Translate a psdl reference into its java mapping,
150      * i.e. ref<A> => A.
151      *
152      * @param type - The PsdlTypeRef to translate.
153      *
154      * @return The resulting mapping.
155      **/

156     public java.lang.String JavaDoc
157     RefToJava(org.objectweb.openccm.ast.api.PsdlTypeRef type)
158     {
159         org.objectweb.openccm.ast.api.StorageTypeBase st_base = null;
160
161         if (type == null)
162         {
163             return "";
164         }
165         st_base = type.getStorageTypeBase();
166         return getAbsoluteName(st_base);
167     }
168
169     // ==================================================================
170
//
171
// Public methods.
172
//
173
// ==================================================================
174

175 }
176
Popular Tags