1 27 28 package org.objectweb.ccm.visitorIDL3.xmi; 29 30 33 public class XMITranslator { 34 35 38 public XMITranslator() { 39 } 40 41 48 public java.lang.String 49 toXMI(org.objectweb.ccm.IDL3.TypeRef typeref) { 50 switch (typeref.getTypeKind()) { 51 case org.objectweb.ccm.IDL3.TypeKind._tk_null : 52 return "null"; 53 case org.objectweb.ccm.IDL3.TypeKind._tk_void : 54 return "void"; 55 case org.objectweb.ccm.IDL3.TypeKind._tk_short : 56 return "CORBAshort"; 57 case org.objectweb.ccm.IDL3.TypeKind._tk_ushort : 58 return "CORBAunsignedshort"; 59 case org.objectweb.ccm.IDL3.TypeKind._tk_long : 60 return "CORBAlong"; 61 case org.objectweb.ccm.IDL3.TypeKind._tk_ulong : 62 return "CORBAunsignedlong"; 63 case org.objectweb.ccm.IDL3.TypeKind._tk_longlong : 64 return "CORBAlonglong"; 65 case org.objectweb.ccm.IDL3.TypeKind._tk_ulonglong : 66 return "CORBAunsignedlonglong"; 67 case org.objectweb.ccm.IDL3.TypeKind._tk_float : 68 return "CORBAfloat"; 69 case org.objectweb.ccm.IDL3.TypeKind._tk_double : 70 return "CORBAdouble"; 71 case org.objectweb.ccm.IDL3.TypeKind._tk_longdouble : 72 return "CORBAlongdouble"; 73 case org.objectweb.ccm.IDL3.TypeKind._tk_boolean : 74 return "CORBAboolean"; 75 case org.objectweb.ccm.IDL3.TypeKind._tk_char : 76 return "CORBAchar"; 77 case org.objectweb.ccm.IDL3.TypeKind._tk_wchar : 78 return "CORBAwchar"; 79 case org.objectweb.ccm.IDL3.TypeKind._tk_octet : 80 return "CORBAoctet"; 81 case org.objectweb.ccm.IDL3.TypeKind._tk_any : 82 return "CORBAany"; 83 case org.objectweb.ccm.IDL3.TypeKind._tk_Principal : 84 return "CORBAPrincipal"; 85 case org.objectweb.ccm.IDL3.TypeKind._tk_TypeCode : 86 return "CORBATypeCode"; 87 case org.objectweb.ccm.IDL3.TypeKind._tk_objref : 88 return "CORBAObject"; 89 90 case org.objectweb.ccm.IDL3.TypeKind._tk_alias : 91 case org.objectweb.ccm.IDL3.TypeKind._tk_struct : 92 case org.objectweb.ccm.IDL3.TypeKind._tk_union : 93 case org.objectweb.ccm.IDL3.TypeKind._tk_enum : 94 case org.objectweb.ccm.IDL3.TypeKind._tk_exception : 95 case org.objectweb.ccm.IDL3.TypeKind._tk_value_box : 96 case org.objectweb.ccm.IDL3.TypeKind._tk_value : 97 case org.objectweb.ccm.IDL3.TypeKind._tk_native : 98 case org.objectweb.ccm.IDL3.TypeKind._tk_abstract_interface : 99 case org.objectweb.ccm.IDL3.TypeKind._tk_local_interface : 100 case org.objectweb.ccm.IDL3.TypeKind._tk_interface : 101 case org.objectweb.ccm.IDL3.TypeKind._tk_component : 102 case org.objectweb.ccm.IDL3.TypeKind._tk_home : 103 case org.objectweb.ccm.IDL3.TypeKind._tk_event : 104 org.objectweb.ccm.IDL3.Declaration decl = (org.objectweb.ccm.IDL3.Declaration) typeref; 105 return getAbsoluteName(decl); 106 107 case org.objectweb.ccm.IDL3.TypeKind._tk_sequence : 108 org.objectweb.ccm.IDL3.TypeRefImpl impl= (org.objectweb.ccm.IDL3.TypeRefImpl) typeref; 109 java.lang.String str = toXMI(impl.getContentType()); 110 int length = impl.getLength(); 111 if (length == 0) 112 return "CORBAsequence<" + str + ">"; 113 return "CORBAsequence<" + str + ", " + length + ">"; 114 115 case org.objectweb.ccm.IDL3.TypeKind._tk_array : 116 impl= (org.objectweb.ccm.IDL3.TypeRefImpl) typeref; 117 str = toXMI(impl.getContentType()); 118 return "CORBAarray<" + str + ", " + impl.getLength() + ">"; 119 120 case org.objectweb.ccm.IDL3.TypeKind._tk_string : 121 impl= (org.objectweb.ccm.IDL3.TypeRefImpl) typeref; 122 length = impl.getLength(); 123 if (length == 0) 124 return "CORBAstring"; 125 return "CORBAstring<" + impl.getLength() + ">"; 126 127 case org.objectweb.ccm.IDL3.TypeKind._tk_wstring : 128 impl= (org.objectweb.ccm.IDL3.TypeRefImpl) typeref; 129 length = impl.getLength(); 130 if (length == 0) 131 return "CORBAwstring"; 132 return "CORBAwstring<" + impl.getLength() + ">"; 133 134 case org.objectweb.ccm.IDL3.TypeKind._tk_fixed : 135 impl= (org.objectweb.ccm.IDL3.TypeRefImpl) typeref; 136 return "CORBAfixed<" + impl.getDigits() + ", " + impl.getScale() + ">"; 137 138 default : 139 return ""; 140 } 141 } 142 143 148 public java.lang.String 149 toXMIString(org.objectweb.ccm.IDL3.TypeRef typeref) { 150 switch(typeref.getTypeKind()) { 151 case org.objectweb.ccm.IDL3.TypeKind._tk_null : 152 return "null"; 153 case org.objectweb.ccm.IDL3.TypeKind._tk_void : 154 return "void"; 155 case org.objectweb.ccm.IDL3.TypeKind._tk_short : 156 return "CORBAshort"; 157 case org.objectweb.ccm.IDL3.TypeKind._tk_ushort : 158 return "CORBAunsignedshort"; 159 case org.objectweb.ccm.IDL3.TypeKind._tk_long : 160 return "CORBAlong"; 161 case org.objectweb.ccm.IDL3.TypeKind._tk_ulong : 162 return "CORBAunsignedlong"; 163 case org.objectweb.ccm.IDL3.TypeKind._tk_longlong : 164 return "CORBAlonglong"; 165 case org.objectweb.ccm.IDL3.TypeKind._tk_ulonglong : 166 return "CORBAunsignedlonglong"; 167 case org.objectweb.ccm.IDL3.TypeKind._tk_float : 168 return "CORBAfloat"; 169 case org.objectweb.ccm.IDL3.TypeKind._tk_double : 170 return "CORBAdouble"; 171 case org.objectweb.ccm.IDL3.TypeKind._tk_longdouble : 172 return "CORBAlongdouble"; 173 case org.objectweb.ccm.IDL3.TypeKind._tk_boolean : 174 return "CORBAboolean"; 175 case org.objectweb.ccm.IDL3.TypeKind._tk_char : 176 return "CORBAchar"; 177 case org.objectweb.ccm.IDL3.TypeKind._tk_wchar : 178 return "CORBAwchar"; 179 case org.objectweb.ccm.IDL3.TypeKind._tk_octet : 180 return "CORBAoctet"; 181 case org.objectweb.ccm.IDL3.TypeKind._tk_any : 182 return "CORBAany"; 183 case org.objectweb.ccm.IDL3.TypeKind._tk_Principal : 184 return "CORBAPrincipal"; 185 case org.objectweb.ccm.IDL3.TypeKind._tk_TypeCode : 186 return "CORBATypeCode"; 187 case org.objectweb.ccm.IDL3.TypeKind._tk_objref : 188 return "CORBAObject"; 189 case org.objectweb.ccm.IDL3.TypeKind._tk_string : 190 return "CORBAstring"; 191 case org.objectweb.ccm.IDL3.TypeKind._tk_wstring : 192 return "CORBAwstring"; 193 case org.objectweb.ccm.IDL3.TypeKind._tk_fixed : 194 return "CORBAFixed"; 195 case org.objectweb.ccm.IDL3.TypeKind._tk_sequence : 196 return "CORBASequence"; 197 case org.objectweb.ccm.IDL3.TypeKind._tk_array : 198 return "CORBAArray"; 199 200 case org.objectweb.ccm.IDL3.TypeKind._tk_alias : 201 case org.objectweb.ccm.IDL3.TypeKind._tk_struct : 202 case org.objectweb.ccm.IDL3.TypeKind._tk_union : 203 case org.objectweb.ccm.IDL3.TypeKind._tk_enum : 204 case org.objectweb.ccm.IDL3.TypeKind._tk_exception : 205 case org.objectweb.ccm.IDL3.TypeKind._tk_value_box : 206 case org.objectweb.ccm.IDL3.TypeKind._tk_value : 207 case org.objectweb.ccm.IDL3.TypeKind._tk_native : 208 case org.objectweb.ccm.IDL3.TypeKind._tk_abstract_interface : 209 case org.objectweb.ccm.IDL3.TypeKind._tk_local_interface : 210 case org.objectweb.ccm.IDL3.TypeKind._tk_interface : 211 case org.objectweb.ccm.IDL3.TypeKind._tk_component : 212 case org.objectweb.ccm.IDL3.TypeKind._tk_home : 213 case org.objectweb.ccm.IDL3.TypeKind._tk_event : 214 org.objectweb.ccm.IDL3.Declaration decl = (org.objectweb.ccm.IDL3.Declaration) typeref; 215 return getAbsoluteName(decl); 216 217 default : 218 return ""; 219 } 220 } 221 222 229 public java.lang.String 230 getAbsoluteName(org.objectweb.ccm.IDL3.Declaration decl) { 231 return decl.getAbsoluteName(); 232 } 233 234 242 public java.lang.String 243 toString(org.objectweb.ccm.IDL3.AnyValue anyvalue, 244 org.objectweb.ccm.IDL3.TypeRef typeref) { 245 if (anyvalue.isInteger()) { 247 return java.lang.String.valueOf(anyvalue.getAsInteger()); 248 } else if (anyvalue.isString()) { 249 return "\"" + anyvalue.getAsString() + "\""; 250 } else if (anyvalue.isWString()) { 251 return "L\"" + anyvalue.getAsWString() + "\""; 252 } else if (anyvalue.isChar()) { 253 return "\'" + java.lang.String.valueOf(anyvalue.getAsChar()) + "\'"; 254 } else if (anyvalue.isWChar()) { 255 return "L\'" + java.lang.String.valueOf(anyvalue.getAsWChar()) + "\'"; 256 } else if (anyvalue.isFloating()) { 257 return java.lang.String.valueOf(anyvalue.getAsFloating()); 258 } else if (anyvalue.isFixed()) { 259 return anyvalue.getAsFixed(); 260 } else if (anyvalue.isBoolean()) { 261 if (anyvalue.getAsBoolean()) { 262 return "TRUE"; 263 } 264 return "FALSE"; 265 } else if (anyvalue.isEnum()) { 266 java.lang.String abs_name = ((org.objectweb.ccm.IDL3.EnumDecl) 268 typeref).getParent().getAbsoluteName(); 269 return abs_name + "::" + anyvalue.getAsEnum(); 270 } else { 271 return ""; 272 } 273 } 274 } 275 | Popular Tags |