1 28 29 30 package org.objectweb.ccm.runtime; 31 32 import org.objectweb.corba.runtime.*; 33 import org.objectweb.corba.ast.api.*; 35 36 39 public class ExtendedJavaTranslator 40 { 41 private org.objectweb.corba.generator.translator.idl2java.lib.CommonTranslator _translator; 43 44 public 46 ExtendedJavaTranslator() 47 { 48 _translator = new org.objectweb.corba.generator.translator.idl2java.lib.CommonTranslator(); 50 } 51 52 56 final public String 57 toJava(TypeRef typeref) 58 { 59 return _translator.toJava(typeref); 60 } 61 62 final public String 63 toJava(TypeRef type, 64 int mode) 65 { 66 return _translator.toJava(type, mode); 67 } 68 69 final public String 70 getAbsoluteName(Declaration decl) 71 { 72 return _translator.getAbsoluteName(decl); 73 } 74 75 final public String 76 getPackage(Declaration decl) 77 { 78 return _translator.getPackage(decl); 79 } 80 81 final public String 82 getAsDirectory(String packname) 83 { 84 return _translator.getAsDirectory(packname); 85 } 86 87 final public String 88 getAsDirectory(Declaration decl) 89 { 90 return _translator.getAsDirectory(decl); 91 } 92 93 final public String 95 toJavaAnyExtractor(TypeRef typeref) 96 { 97 TypeKind tk = typeref.getTypeKind(); 98 99 if (tk == TypeKind.tk_null) 100 return null; 101 else if (tk == TypeKind.tk_void) 102 return null; 103 else if (tk == TypeKind.tk_short) 104 return "extract_short"; 105 else if (tk == TypeKind.tk_ushort) 106 return "extract_ushort"; 107 else if (tk == TypeKind.tk_long) 108 return "extract_long"; 109 else if (tk == TypeKind.tk_ulong) 110 return "extract_long"; 111 else if (tk == TypeKind.tk_longlong) 112 return "extract_longlong"; 113 else if (tk == TypeKind.tk_ulonglong) 114 return "extract_ulonglong"; 115 else if (tk == TypeKind.tk_float) 116 return "extract_float"; 117 else if (tk == TypeKind.tk_double) 118 return "extract_double"; 119 else if (tk == TypeKind.tk_longdouble) 120 return null; 121 else if (tk == TypeKind.tk_boolean) 122 return "extract_boolean"; 123 else if (tk == TypeKind.tk_char) 124 return "extract_char"; 125 else if (tk == TypeKind.tk_wchar) 126 return "extract_wchar"; 127 else if (tk == TypeKind.tk_octet) 128 return "extract_octet"; 129 else if (tk == TypeKind.tk_any) 130 return "extract_any"; 131 else if (tk == TypeKind.tk_Principal) 132 return "extract_Principal"; 133 else if (tk == TypeKind.tk_TypeCode) 134 return "extract_TypeCode"; 135 else if (tk == TypeKind.tk_objref) 136 return "extract_Object"; 137 else if (tk == TypeKind.tk_string) 138 return "extract_string"; 139 else if (tk == TypeKind.tk_wstring) 140 return "extract_wstring"; 141 else if (tk == TypeKind.tk_fixed) 142 return "extract_fixed"; 143 144 else 145 return getAbsoluteName((Declaration)typeref)+"Helper.extract"; 146 } 147 148 final public String 150 toJavaAnyInsertor(TypeRef typeref) 151 { 152 TypeKind tk = typeref.getTypeKind(); 153 154 if (tk == TypeKind.tk_null) 155 return null; 156 else if (tk == TypeKind.tk_void) 157 return null; 158 else if (tk == TypeKind.tk_short) 159 return "insert_short"; 160 else if (tk == TypeKind.tk_ushort) 161 return "insert_ushort"; 162 else if (tk == TypeKind.tk_long) 163 return "insert_long"; 164 else if (tk == TypeKind.tk_ulong) 165 return "insert_long"; 166 else if (tk == TypeKind.tk_longlong) 167 return "insert_longlong"; 168 else if (tk == TypeKind.tk_ulonglong) 169 return "insert_ulonglong"; 170 else if (tk == TypeKind.tk_float) 171 return "insert_float"; 172 else if (tk == TypeKind.tk_double) 173 return "insert_double"; 174 else if (tk == TypeKind.tk_longdouble) 175 return null; 176 else if (tk == TypeKind.tk_boolean) 177 return "insert_boolean"; 178 else if (tk == TypeKind.tk_char) 179 return "insert_char"; 180 else if (tk == TypeKind.tk_wchar) 181 return "insert_wchar"; 182 else if (tk == TypeKind.tk_octet) 183 return "insert_octet"; 184 else if (tk == TypeKind.tk_any) 185 return "insert_any"; 186 else if (tk == TypeKind.tk_Principal) 187 return "insert_Principal"; 188 else if (tk == TypeKind.tk_TypeCode) 189 return "insert_TypeCode"; 190 else if (tk == TypeKind.tk_objref) 191 return "insert_Object"; 192 else if (tk == TypeKind.tk_string) 193 return "insert_string"; 194 else if (tk == TypeKind.tk_wstring) 195 return "insert_wstring"; 196 else if (tk == TypeKind.tk_fixed) 197 return "insert_fixed"; 198 199 else 200 return getAbsoluteName((Declaration)typeref)+"Helper.insert"; 201 } 202 203 public String 205 toJavaNullValue(TypeRef typeref) 206 { 207 TypeKind tk = typeref.getTypeKind(); 208 209 if (tk == TypeKind.tk_null) 210 return null; 211 else if (tk == TypeKind.tk_void) 212 return null; 213 else if (tk == TypeKind.tk_short) 214 return "(short)0"; 215 else if (tk == TypeKind.tk_ushort) 216 return "(short)0"; 217 else if (tk == TypeKind.tk_long) 218 return "0"; 219 else if (tk == TypeKind.tk_ulong) 220 return "0"; 221 else if (tk == TypeKind.tk_longlong) 222 return "(long)0"; 223 else if (tk == TypeKind.tk_ulonglong) 224 return "(long)0"; 225 else if (tk == TypeKind.tk_float) 226 return "0.0"; 227 else if (tk == TypeKind.tk_double) 228 return "0.0"; 229 else if (tk == TypeKind.tk_longdouble) 230 return null; 231 else if (tk == TypeKind.tk_boolean) 232 return "false"; 233 else if (tk == TypeKind.tk_char) 234 return "\'\'"; 235 else if (tk == TypeKind.tk_wchar) 236 return "\'\'"; 237 else if (tk == TypeKind.tk_octet) 238 return "0"; 239 else if (tk == TypeKind.tk_any) 240 return "null"; 241 else if (tk == TypeKind.tk_Principal) 242 return "null"; 243 else if (tk == TypeKind.tk_TypeCode) 244 return "null"; 245 else if (tk == TypeKind.tk_objref) 246 return "null"; 247 else if (tk == TypeKind.tk_string) 248 return "null"; 249 else if (tk == TypeKind.tk_wstring) 250 return "null"; 251 else if (tk == TypeKind.tk_fixed) 252 return "0.0"; 253 254 else 255 return "null"; 256 } 257 } 258 | Popular Tags |