KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > pss > generator > common > lib > PSDLTools


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.pss.generator.common.lib;
28
29 // Package dependencies
30
import org.objectweb.openccm.ast.api.TypeKind;
31 import org.objectweb.openccm.ast.api.DeclarationKind;
32 import org.objectweb.openccm.ast.api.PsdlTypeRef;
33
34
35 /**
36  * This class implements useful methods dor PSDL types.
37  *
38  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
39  *
40  * @version 0.1
41  */

42
43 public class PSDLTools
44 {
45
46     // ==================================================================
47
//
48
// Internal state.
49
//
50
// ==================================================================
51

52     // ==================================================================
53
//
54
// Constructors.
55
//
56
// ==================================================================
57

58     /**
59      * The default constructor.
60      */

61
62     public PSDLTools()
63     {
64     }
65
66     // ==================================================================
67
//
68
// Internal methods.
69
//
70
// ==================================================================
71

72     // ==================================================================
73
//
74
// Public methods.
75
//
76
// ==================================================================
77

78     /**
79      * Test if a psdl type is an abstract storage type.
80      *
81      * @param type - The psdl type reference to test.
82      *
83      * @return True if this type is an abstract storage type, else false.
84      **/

85     public static boolean
86     isAbstractStorageType(PsdlTypeRef type)
87     {
88         org.objectweb.openccm.ast.api.StorageTypeBase st_base = null;
89
90         st_base = type.getStorageTypeBase();
91         if ( (st_base != null)
92              && (st_base.getDeclKind() == DeclarationKind.dk_abstract_storage_type) )
93         {
94             return true;
95         }
96         return false;
97     }
98
99     /**
100      * Test if a psdl type is immutable.
101      *
102      * @param type - The psdl type reference to test.
103      *
104      * @return True if this type is immutable, else false.
105      **/

106     public static boolean
107     isImmutable(PsdlTypeRef type)
108     {
109         org.objectweb.openccm.ast.api.TypeRef idl_type = null;
110
111         idl_type = type.getTypeRef();
112         if (idl_type != null)
113         {
114             TypeKind tk = idl_type.getTypeKind();
115
116             if ( (tk == TypeKind.tk_null)
117                  || (tk == TypeKind.tk_void)
118                  || (tk == TypeKind.tk_short)
119                  || (tk == TypeKind.tk_ushort)
120                  || (tk == TypeKind.tk_long)
121                  || (tk == TypeKind.tk_ulong)
122                  || (tk == TypeKind.tk_longlong)
123                  || (tk == TypeKind.tk_ulonglong)
124                  || (tk == TypeKind.tk_float)
125                  || (tk == TypeKind.tk_double)
126                  || (tk == TypeKind.tk_longdouble)
127                  || (tk == TypeKind.tk_boolean)
128                  || (tk == TypeKind.tk_char)
129                  || (tk == TypeKind.tk_wchar)
130                  || (tk == TypeKind.tk_octet)
131                  || (tk == TypeKind.tk_string)
132                  || (tk == TypeKind.tk_wstring)
133                  || (tk == TypeKind.tk_fixed) )
134             {
135                 return true;
136             }
137         }
138         return false;
139     }
140
141     /**
142      * Test if a psdl type is a reference to an Abstract Storage Type.
143      *
144      * @param type - The psdl type reference to test.
145      *
146      * @return True if a reference to an Abstract Storage Type is immutable, else false.
147      **/

148     public static boolean
149     isAbstractStorageTypeReference(PsdlTypeRef type)
150     {
151         org.objectweb.openccm.ast.api.StorageTypeBase st_base = null;
152
153         st_base = type.getStorageTypeBase();
154         if ( type.isRef() &&
155              (st_base.getDeclKind() == DeclarationKind.dk_abstract_storage_type)
156             )
157             return true;
158         return false;
159     }
160 }
161
Popular Tags