1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package com.sun.star.uno; 25 26 import com.sun.star.lang.XTypeProvider; 27 import complexlib.ComplexTestCase; 28 29 public final class AnyConverter_Test extends ComplexTestCase { getTestObjectName()30 public String getTestObjectName() { 31 return getClass().getName(); 32 } 33 getTestMethodNames()34 public String[] getTestMethodNames() { 35 return new String[] { 36 "test_toBoolean", "test_toChar", "test_toByte", "test_toShort", 37 "test_toInt", "test_toLong", "test_toFloat", "test_toDouble", 38 "test_toObject", "test_toString", "test_toType", "test_toArray", 39 "test_isBoolean", "test_isChar", "test_isByte", "test_isShort", 40 "test_isInt", "test_isLong", "test_isFloat", "test_isDouble", 41 "test_isObject", "test_isString", "test_isType", "test_isArray", 42 "test_isVoid" }; 43 } 44 45 Any anyBool; // 46 Any anyChar; // 47 Any anyByte; // 48 Any anyShort; // 49 Any anyInt; // 50 Any anyLong; // 51 Any anyFloat; // 52 Any anyDouble; // 53 Any anyStr; // 54 Any anyType; // 55 Any anyArByte; // 56 Any anyVoid; // 57 Any anyXTypeProvider; 58 59 Boolean aBool= new Boolean(true); 60 Character aChar= new Character('A'); 61 Byte aByte= new Byte((byte) 111); 62 Short aShort= new Short((short) 11111); 63 Integer aInt= new Integer( 1111111); 64 Long aLong= new Long( 0xffffffff); 65 Float aFloat= new Float( 3.14); 66 Double aDouble= new Double( 3.145); 67 Object aObj= new ATypeProvider(); 68 String aStr= new String("I am a string"); 69 Type aType= new Type(String.class); 70 byte[] arByte= new byte[] {1,2,3}; 71 AnyConverter_Test()72 public AnyConverter_Test() { 73 anyVoid= new Any(new Type(void.class), null); 74 anyBool= new Any(new Type(Boolean.TYPE), aBool); 75 anyChar= new Any(new Type(Character.TYPE), aChar); 76 anyByte= new Any(new Type(Byte.TYPE), aByte); 77 anyShort= new Any(new Type(Short.TYPE), aShort); 78 anyInt= new Any(new Type(Integer.TYPE), aInt); 79 anyLong= new Any(new Type(Long.TYPE), aLong); 80 anyFloat= new Any(new Type(Float.TYPE), aFloat); 81 anyDouble= new Any(new Type(Double.TYPE), aDouble); 82 anyStr= new Any(new Type(String.class), aStr); 83 anyType= new Any(new Type(Type.class), aType); 84 anyArByte= new Any(new Type(byte[].class), arByte); 85 anyXTypeProvider= new Any(new Type(XTypeProvider.class), aObj); 86 } 87 test_toBoolean()88 public void test_toBoolean() 89 throws com.sun.star.lang.IllegalArgumentException 90 { 91 // must work 92 boolean b= AnyConverter.toBoolean(aBool); 93 assure("", b == aBool.booleanValue()); 94 b= AnyConverter.toBoolean(anyBool); 95 assure("", b == ((Boolean)anyBool.getObject()).booleanValue()); 96 97 // must fail 98 try { AnyConverter.toBoolean(aChar); failed(""); 99 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 100 try { AnyConverter.toBoolean(anyChar); failed(""); 101 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 102 try { AnyConverter.toBoolean(aByte); failed(""); 103 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 104 try { AnyConverter.toBoolean(anyByte); failed(""); 105 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 106 try { AnyConverter.toBoolean(aShort); failed(""); 107 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 108 try { AnyConverter.toBoolean(anyShort); failed(""); 109 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 110 try { AnyConverter.toBoolean(aInt); failed(""); 111 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 112 try { AnyConverter.toBoolean(anyInt); failed(""); 113 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 114 try { AnyConverter.toBoolean(aLong); failed(""); 115 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 116 try { AnyConverter.toBoolean(anyLong); failed(""); 117 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 118 try { AnyConverter.toBoolean(aFloat); failed(""); 119 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 120 try { AnyConverter.toBoolean(anyFloat); failed(""); 121 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 122 try { AnyConverter.toBoolean(aDouble); failed(""); 123 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 124 try { AnyConverter.toBoolean(anyDouble); failed(""); 125 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 126 try { AnyConverter.toBoolean(aObj); failed(""); 127 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 128 try { AnyConverter.toBoolean(aStr); failed(""); 129 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 130 try { AnyConverter.toBoolean(anyStr); failed(""); 131 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 132 try { AnyConverter.toBoolean(aType); failed(""); 133 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 134 try { AnyConverter.toBoolean(anyType); failed(""); 135 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 136 try { AnyConverter.toBoolean(anyVoid); failed(""); 137 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 138 try { AnyConverter.toBoolean(arByte); failed(""); 139 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 140 try { AnyConverter.toBoolean(anyArByte); failed(""); 141 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 142 } 143 test_toChar()144 public void test_toChar() 145 throws com.sun.star.lang.IllegalArgumentException 146 { 147 // must work 148 char b= AnyConverter.toChar(aChar); 149 assure("", b == aChar.charValue()); 150 b= AnyConverter.toChar(anyChar); 151 assure("", b == ((Character)anyChar.getObject()).charValue()); 152 153 // must fail 154 try { AnyConverter.toChar(aBool); failed(""); 155 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 156 try { AnyConverter.toChar(anyBool); failed(""); 157 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 158 try { AnyConverter.toChar(aByte); failed(""); 159 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 160 try { AnyConverter.toChar(anyByte); failed(""); 161 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 162 try { AnyConverter.toChar(aShort); failed(""); 163 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 164 try { AnyConverter.toChar(anyShort); failed(""); 165 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 166 try { AnyConverter.toChar(aInt); failed(""); 167 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 168 try { AnyConverter.toChar(anyInt); failed(""); 169 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 170 try { AnyConverter.toChar(aLong); failed(""); 171 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 172 try { AnyConverter.toChar(anyLong); failed(""); 173 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 174 try { AnyConverter.toChar(aFloat); failed(""); 175 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 176 try { AnyConverter.toChar(anyFloat); failed(""); 177 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 178 try { AnyConverter.toChar(aDouble); failed(""); 179 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 180 try { AnyConverter.toChar(anyDouble); failed(""); 181 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 182 try { AnyConverter.toChar(aObj); failed(""); 183 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 184 try { AnyConverter.toChar(aStr); failed(""); 185 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 186 try { AnyConverter.toChar(anyStr); failed(""); 187 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 188 try { AnyConverter.toChar(aType); failed(""); 189 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 190 try { AnyConverter.toChar(anyType); failed(""); 191 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 192 try { AnyConverter.toChar(anyVoid); failed(""); 193 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 194 try { AnyConverter.toChar(arByte); failed(""); 195 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 196 try { AnyConverter.toChar(anyArByte); failed(""); 197 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 198 } 199 test_toByte()200 public void test_toByte() 201 throws com.sun.star.lang.IllegalArgumentException 202 { 203 // must work 204 byte val= AnyConverter.toByte(aByte); 205 assure("", val == aByte.byteValue()); 206 val= AnyConverter.toByte(anyByte); 207 assure("", val == ((Byte)anyByte.getObject()).byteValue()); 208 209 // must fail 210 try { AnyConverter.toByte(aChar); failed(""); 211 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 212 try { AnyConverter.toByte(anyChar); failed(""); 213 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 214 try { AnyConverter.toByte(aShort); failed(""); 215 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 216 try { AnyConverter.toByte(anyShort); failed(""); 217 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 218 try { AnyConverter.toByte(aInt); failed(""); 219 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 220 try { AnyConverter.toByte(anyInt); failed(""); 221 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 222 try { AnyConverter.toByte(aLong); failed(""); 223 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 224 try { AnyConverter.toByte(anyLong); failed(""); 225 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 226 try { AnyConverter.toByte(aFloat); failed(""); 227 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 228 try { AnyConverter.toByte(anyFloat); failed(""); 229 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 230 try { AnyConverter.toByte(aDouble); failed(""); 231 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 232 try { AnyConverter.toByte(anyDouble); failed(""); 233 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 234 try { AnyConverter.toByte(aObj); failed(""); 235 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 236 try { AnyConverter.toByte(aStr); failed(""); 237 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 238 try { AnyConverter.toByte(anyStr); failed(""); 239 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 240 try { AnyConverter.toByte(aType); failed(""); 241 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 242 try { AnyConverter.toByte(anyType); failed(""); 243 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 244 try { AnyConverter.toByte(anyVoid); failed(""); 245 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 246 try { AnyConverter.toByte(arByte); failed(""); 247 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 248 try { AnyConverter.toByte(anyArByte); failed(""); 249 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 250 } 251 test_toShort()252 public void test_toShort() 253 throws com.sun.star.lang.IllegalArgumentException 254 { 255 // must work 256 short sh= AnyConverter.toShort(aByte); 257 assure("", sh == aByte.byteValue()); 258 sh= AnyConverter.toShort(aShort); 259 assure("", sh == aShort.shortValue()); 260 sh= AnyConverter.toShort(anyByte); 261 assure("", sh == ((Byte)anyByte.getObject()).byteValue()); 262 sh= AnyConverter.toShort(anyShort); 263 assure("", sh == ((Short) anyShort.getObject()).shortValue()); 264 Any a = new Any( Type.UNSIGNED_SHORT, new Short((short)5) ); 265 assure("", 5 == AnyConverter.toUnsignedShort( a )); 266 267 // must fail 268 try { AnyConverter.toShort(a); failed(""); 269 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 270 try { AnyConverter.toUnsignedShort(anyShort); failed(""); 271 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 272 try { AnyConverter.toChar(aBool); failed(""); 273 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 274 try { AnyConverter.toChar(anyBool); failed(""); 275 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 276 try { AnyConverter.toShort(aChar); failed(""); 277 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 278 try { AnyConverter.toShort(anyChar); failed(""); 279 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 280 try { AnyConverter.toShort(aBool); failed(""); 281 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 282 try { AnyConverter.toShort(anyBool); failed(""); 283 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 284 try { AnyConverter.toShort(aInt); failed(""); 285 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 286 try { AnyConverter.toShort(anyInt); failed(""); 287 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 288 try { AnyConverter.toShort(aLong); failed(""); 289 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 290 try { AnyConverter.toShort(anyLong); failed(""); 291 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 292 try { AnyConverter.toShort(aFloat); failed(""); 293 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 294 try { AnyConverter.toShort(anyFloat); failed(""); 295 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 296 try { AnyConverter.toShort(aDouble); failed(""); 297 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 298 try { AnyConverter.toShort(anyDouble); failed(""); 299 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 300 try { AnyConverter.toShort(aObj); failed(""); 301 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 302 try { AnyConverter.toShort(aStr); failed(""); 303 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 304 try { AnyConverter.toShort(anyStr); failed(""); 305 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 306 try { AnyConverter.toShort(aType); failed(""); 307 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 308 try { AnyConverter.toShort(anyType); failed(""); 309 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 310 try { AnyConverter.toShort(anyVoid); failed(""); 311 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 312 try { AnyConverter.toShort(arByte); failed(""); 313 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 314 try { AnyConverter.toShort(anyArByte); failed(""); 315 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 316 } 317 test_toInt()318 public void test_toInt() 319 throws com.sun.star.lang.IllegalArgumentException 320 { 321 // must work 322 int val= AnyConverter.toInt(aByte); 323 assure("", val == aByte.byteValue()); 324 val= AnyConverter.toInt(aShort); 325 assure("", val == aShort.shortValue()); 326 val= AnyConverter.toInt(aInt); 327 assure("", val == aInt.intValue()); 328 val= AnyConverter.toInt(anyByte); 329 assure("", val == ((Byte)anyByte.getObject()).byteValue()); 330 val= AnyConverter.toInt(anyShort); 331 assure("", val == ((Short) anyShort.getObject()).shortValue()); 332 val= AnyConverter.toInt(anyInt); 333 assure("", val == ((Integer) anyInt.getObject()).intValue()); 334 Any a = new Any( Type.UNSIGNED_SHORT, new Short((short)5) ); 335 assure("", 5 == AnyConverter.toInt(a)); 336 assure("", 5 == AnyConverter.toUnsignedInt(a)); 337 a = new Any( Type.UNSIGNED_LONG, new Integer(5) ); 338 assure("", 5 == AnyConverter.toUnsignedInt(a)); 339 340 // must fail 341 try { AnyConverter.toUnsignedInt(anyInt); failed(""); 342 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 343 try { AnyConverter.toInt(a); failed(""); 344 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 345 try { AnyConverter.toUnsignedInt(anyShort); failed(""); 346 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 347 try { AnyConverter.toInt(aChar); failed(""); 348 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 349 try { AnyConverter.toInt(anyChar); failed(""); 350 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 351 try { AnyConverter.toInt(aBool); failed(""); 352 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 353 try { AnyConverter.toInt(anyBool); failed(""); 354 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 355 try { AnyConverter.toInt(aLong); failed(""); 356 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 357 try { AnyConverter.toInt(anyLong); failed(""); 358 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 359 try { AnyConverter.toInt(aFloat); failed(""); 360 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 361 try { AnyConverter.toInt(anyFloat); failed(""); 362 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 363 try { AnyConverter.toInt(aDouble); failed(""); 364 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 365 try { AnyConverter.toInt(anyDouble); failed(""); 366 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 367 try { AnyConverter.toInt(aObj); failed(""); 368 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 369 try { AnyConverter.toInt(aStr); failed(""); 370 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 371 try { AnyConverter.toInt(anyStr); failed(""); 372 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 373 try { AnyConverter.toInt(aType); failed(""); 374 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 375 try { AnyConverter.toInt(anyType); failed(""); 376 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 377 try { AnyConverter.toInt(anyVoid); failed(""); 378 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 379 try { AnyConverter.toInt(arByte); failed(""); 380 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 381 try { AnyConverter.toInt(anyArByte); failed(""); 382 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 383 } 384 test_toLong()385 public void test_toLong() 386 throws com.sun.star.lang.IllegalArgumentException 387 { 388 // must work 389 long val= AnyConverter.toLong(aByte); 390 assure("", val == aByte.byteValue()); 391 val= AnyConverter.toLong(aShort); 392 assure("", val == aShort.shortValue()); 393 val= AnyConverter.toLong(aInt); 394 assure("", val == aInt.intValue()); 395 val= AnyConverter.toLong(aLong); 396 assure("", val == aLong.longValue()); 397 val= AnyConverter.toLong(anyByte); 398 assure("", val == ((Byte)anyByte.getObject()).byteValue()); 399 val= AnyConverter.toLong(anyShort); 400 assure("", val == ((Short) anyShort.getObject()).shortValue()); 401 val= AnyConverter.toLong(anyInt); 402 assure("", val == ((Integer) anyInt.getObject()).intValue()); 403 val= AnyConverter.toLong(anyLong); 404 assure("", val == ((Long) anyLong.getObject()).longValue()); 405 Any a = new Any( Type.UNSIGNED_SHORT, new Short((short)5) ); 406 assure("", 5 == AnyConverter.toLong(a)); 407 assure("", 5 == AnyConverter.toUnsignedLong(a)); 408 a = new Any( Type.UNSIGNED_LONG, new Integer(5) ); 409 assure("", 5 == AnyConverter.toUnsignedLong(a)); 410 assure("", 5 == AnyConverter.toLong(a)); 411 a = new Any( Type.UNSIGNED_HYPER, new Long(5) ); 412 assure("", 5 == AnyConverter.toUnsignedLong(a)); 413 414 // must fail 415 try { AnyConverter.toUnsignedLong(anyShort); failed(""); 416 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 417 try { AnyConverter.toUnsignedLong(anyInt); failed(""); 418 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 419 try { AnyConverter.toLong(a); failed(""); 420 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 421 try { AnyConverter.toUnsignedLong(anyLong); failed(""); 422 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 423 try { AnyConverter.toLong(aChar); failed(""); 424 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 425 try { AnyConverter.toLong(anyChar); failed(""); 426 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 427 try { AnyConverter.toLong(aBool); failed(""); 428 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 429 try { AnyConverter.toLong(anyBool); failed(""); 430 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 431 try { AnyConverter.toLong(aFloat); failed(""); 432 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 433 try { AnyConverter.toLong(anyFloat); failed(""); 434 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 435 try { AnyConverter.toLong(aDouble); failed(""); 436 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 437 try { AnyConverter.toLong(anyDouble); failed(""); 438 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 439 try { AnyConverter.toLong(aObj); failed(""); 440 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 441 try { AnyConverter.toLong(aStr); failed(""); 442 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 443 try { AnyConverter.toLong(anyStr); failed(""); 444 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 445 try { AnyConverter.toLong(aType); failed(""); 446 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 447 try { AnyConverter.toLong(anyType); failed(""); 448 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 449 try { AnyConverter.toLong(anyVoid); failed(""); 450 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 451 try { AnyConverter.toLong(arByte); failed(""); 452 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 453 try { AnyConverter.toLong(anyArByte); failed(""); 454 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 455 } 456 test_toFloat()457 public void test_toFloat() 458 throws com.sun.star.lang.IllegalArgumentException 459 { 460 // must work 461 float val= AnyConverter.toFloat(aByte); 462 assure("", val == aByte.byteValue()); // 111 = 111.0 463 val= AnyConverter.toFloat(anyByte); 464 assure("", val == ((Byte)anyByte.getObject()).byteValue()); 465 val= AnyConverter.toFloat(aShort); 466 assure("", val == aShort.shortValue()); //11111 = 11111.0 467 val= AnyConverter.toFloat(anyShort); 468 assure("", val == ((Short) anyShort.getObject()).shortValue()); 469 val= AnyConverter.toFloat(aFloat); 470 assure("", val == aFloat.floatValue()); 471 val= AnyConverter.toFloat(anyFloat); 472 assure("", val == ((Float) anyFloat.getObject()).floatValue()); 473 474 // must fail 475 try { AnyConverter.toFloat(aChar); failed(""); 476 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 477 try { AnyConverter.toFloat(anyChar); failed(""); 478 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 479 try { AnyConverter.toFloat(aBool); failed(""); 480 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 481 try { AnyConverter.toFloat(anyBool); failed(""); 482 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 483 try { AnyConverter.toFloat(aInt); failed(""); 484 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 485 try { AnyConverter.toFloat(anyInt); failed(""); 486 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 487 try { AnyConverter.toFloat(aLong); failed(""); 488 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 489 try { AnyConverter.toFloat(anyLong); failed(""); 490 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 491 try { AnyConverter.toFloat(aDouble); failed(""); 492 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 493 try { AnyConverter.toFloat(anyDouble); failed(""); 494 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 495 try { AnyConverter.toFloat(aObj); failed(""); 496 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 497 try { AnyConverter.toFloat(aStr); failed(""); 498 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 499 try { AnyConverter.toFloat(anyStr); failed(""); 500 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 501 try { AnyConverter.toFloat(aType); failed(""); 502 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 503 try { AnyConverter.toFloat(anyType); failed(""); 504 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 505 try { AnyConverter.toFloat(anyVoid); failed(""); 506 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 507 try { AnyConverter.toFloat(arByte); failed(""); 508 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 509 try { AnyConverter.toFloat(anyArByte); failed(""); 510 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 511 } 512 test_toDouble()513 public void test_toDouble() 514 throws com.sun.star.lang.IllegalArgumentException 515 { 516 // must work 517 double val= AnyConverter.toDouble(aByte); 518 assure("", val == aByte.byteValue()); // 111 = 111.0 519 val= AnyConverter.toDouble(anyByte); 520 assure("", val == ((Byte)anyByte.getObject()).byteValue()); 521 val= AnyConverter.toDouble(aShort); 522 assure("", val == aShort.shortValue()); //11111 = 11111.0 523 val= AnyConverter.toDouble(anyShort); 524 assure("", val == ((Short) anyShort.getObject()).shortValue()); 525 val= AnyConverter.toDouble(aInt); 526 assure("", val == aInt.intValue()); 527 val= AnyConverter.toDouble(anyInt); 528 assure("", val == ((Integer) anyInt.getObject()).intValue()); 529 val= AnyConverter.toDouble(aFloat); 530 assure("", val == aFloat.floatValue()); 531 val= AnyConverter.toDouble(anyFloat); 532 float float1= ((Float) anyFloat.getObject()).floatValue(); 533 assure("", val <= (float1 + 0.1) || val >= (float1 - 0.1)); 534 val= AnyConverter.toDouble(aDouble); 535 assure("", val == aDouble.doubleValue()); 536 val= AnyConverter.toDouble(anyDouble); 537 assure("", val == ((Double) anyDouble.getObject()).doubleValue()); 538 539 // must fail 540 try { AnyConverter.toDouble(aChar); failed(""); 541 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 542 try { AnyConverter.toDouble(anyChar); failed(""); 543 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 544 try { AnyConverter.toDouble(aBool); failed(""); 545 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 546 try { AnyConverter.toDouble(anyBool); failed(""); 547 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 548 try { AnyConverter.toDouble(aLong); failed(""); 549 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 550 try { AnyConverter.toDouble(anyLong); failed(""); 551 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 552 try { AnyConverter.toDouble(aObj); failed(""); 553 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 554 try { AnyConverter.toDouble(aStr); failed(""); 555 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 556 try { AnyConverter.toDouble(anyStr); failed(""); 557 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 558 try { AnyConverter.toDouble(aType); failed(""); 559 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 560 try { AnyConverter.toDouble(anyType); failed(""); 561 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 562 try { AnyConverter.toDouble(anyVoid); failed(""); 563 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 564 try { AnyConverter.toDouble(arByte); failed(""); 565 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 566 try { AnyConverter.toDouble(anyArByte); failed(""); 567 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 568 } 569 test_toObject()570 public void test_toObject() 571 throws com.sun.star.lang.IllegalArgumentException 572 { 573 // must work 574 Type _type= new Type(XTypeProvider.class); 575 Object val= AnyConverter.toObject(_type, aObj); 576 assure("", UnoRuntime.areSame(val, aObj)); 577 val= AnyConverter.toObject( 578 _type, new Any( new Type(XTypeProvider.class), null)); 579 assure("", val == null); 580 581 // structs, exceptions 582 com.sun.star.lang.IllegalArgumentException exc = 583 new com.sun.star.lang.IllegalArgumentException(); 584 Any any_exc = new Any( 585 new Type("com.sun.star.lang.IllegalArgumentException", 586 TypeClass.EXCEPTION), exc); 587 assure("", 588 AnyConverter.toObject( 589 new Type(com.sun.star.lang.IllegalArgumentException.class), 590 any_exc).equals(exc)); 591 assure("", 592 AnyConverter.toObject( 593 new Type(com.sun.star.uno.Exception.class), any_exc).equals( 594 exc)); 595 try { 596 AnyConverter.toObject( 597 new Type(com.sun.star.uno.RuntimeException.class), any_exc); 598 failed(""); 599 } catch (com.sun.star.lang.IllegalArgumentException ie) {}; 600 any_exc = new Any(com.sun.star.lang.IllegalArgumentException.class, 601 exc); 602 assure("", 603 AnyConverter.toObject( 604 new Type(com.sun.star.lang.IllegalArgumentException.class), 605 any_exc).equals(exc)); 606 assure("", 607 AnyConverter.toObject(new Type(com.sun.star.uno.Exception.class), 608 any_exc).equals(exc)); 609 try { 610 AnyConverter.toObject( 611 new Type(com.sun.star.uno.RuntimeException.class), any_exc); 612 failed(""); 613 } catch (com.sun.star.lang.IllegalArgumentException ie) {}; 614 615 // must fail 616 try { AnyConverter.toObject(_type, aType); failed(""); 617 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 618 try { AnyConverter.toObject(_type, anyType); failed(""); 619 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 620 try { AnyConverter.toObject(_type, anyVoid); failed(""); 621 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 622 try { AnyConverter.toObject(_type, new Object()); failed(""); 623 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 624 } 625 test_toString()626 public void test_toString() 627 throws com.sun.star.lang.IllegalArgumentException 628 { 629 // must work 630 String val= AnyConverter.toString(aStr); 631 assure("", aStr.equals(val)); 632 val= AnyConverter.toString(anyStr); 633 assure("", ((String)anyStr.getObject()).equals(val)); 634 635 // must fail 636 try { AnyConverter.toString(aBool); failed(""); 637 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 638 try { AnyConverter.toString(anyBool); failed(""); 639 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 640 try { AnyConverter.toString(aChar); failed(""); 641 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 642 try { AnyConverter.toString(anyChar); failed(""); 643 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 644 try { AnyConverter.toString(aByte); failed(""); 645 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 646 try { AnyConverter.toString(anyByte); failed(""); 647 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 648 try { AnyConverter.toString(aShort); failed(""); 649 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 650 try { AnyConverter.toString(anyShort); failed(""); 651 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 652 try { AnyConverter.toString(aInt); failed(""); 653 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 654 try { AnyConverter.toString(anyInt); failed(""); 655 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 656 try { AnyConverter.toString(aLong); failed(""); 657 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 658 try { AnyConverter.toString(anyLong); failed(""); 659 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 660 try { AnyConverter.toString(aFloat); failed(""); 661 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 662 try { AnyConverter.toString(anyFloat); failed(""); 663 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 664 try { AnyConverter.toString(aDouble); failed(""); 665 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 666 try { AnyConverter.toString(anyDouble); failed(""); 667 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 668 try { AnyConverter.toString(aObj); failed(""); 669 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 670 try { AnyConverter.toString(aType); failed(""); 671 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 672 try { AnyConverter.toString(anyType); failed(""); 673 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 674 try { AnyConverter.toString(anyVoid); failed(""); 675 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 676 try { AnyConverter.toString(arByte); failed(""); 677 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 678 try { AnyConverter.toString(anyArByte); failed(""); 679 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 680 } 681 test_toType()682 public void test_toType() 683 throws com.sun.star.lang.IllegalArgumentException 684 { 685 // must work 686 Type val= AnyConverter.toType(aType); 687 assure("", val == aType); 688 val= AnyConverter.toType(anyType); 689 assure("", val == anyType.getObject()); 690 691 // must fail 692 try { AnyConverter.toType(aBool); failed(""); 693 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 694 try { AnyConverter.toType(anyBool); failed(""); 695 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 696 try { AnyConverter.toType(aChar); failed(""); 697 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 698 try { AnyConverter.toType(anyChar); failed(""); 699 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 700 try { AnyConverter.toType(aByte); failed(""); 701 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 702 try { AnyConverter.toType(anyByte); failed(""); 703 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 704 try { AnyConverter.toType(aShort); failed(""); 705 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 706 try { AnyConverter.toType(anyShort); failed(""); 707 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 708 try { AnyConverter.toType(aInt); failed(""); 709 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 710 try { AnyConverter.toType(anyInt); failed(""); 711 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 712 try { AnyConverter.toType(aLong); failed(""); 713 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 714 try { AnyConverter.toType(anyLong); failed(""); 715 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 716 try { AnyConverter.toType(aFloat); failed(""); 717 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 718 try { AnyConverter.toType(anyFloat); failed(""); 719 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 720 try { AnyConverter.toType(aDouble); failed(""); 721 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 722 try { AnyConverter.toType(anyDouble); failed(""); 723 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 724 try { AnyConverter.toType(aObj); failed(""); 725 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 726 try { AnyConverter.toType(aStr); failed(""); 727 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 728 try { AnyConverter.toType(anyStr); failed(""); 729 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 730 try { AnyConverter.toType(anyVoid); failed(""); 731 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 732 try { AnyConverter.toType(arByte); failed(""); 733 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 734 try { AnyConverter.toType(anyArByte); failed(""); 735 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 736 } 737 test_toArray()738 public void test_toArray() 739 throws com.sun.star.lang.IllegalArgumentException 740 { 741 // must work 742 Object val= AnyConverter.toArray(arByte); 743 assure("", val == arByte); 744 val= AnyConverter.toArray(anyArByte); 745 assure("", val == anyArByte.getObject()); 746 747 // must fail 748 try { AnyConverter.toType(aBool); failed(""); 749 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 750 try { AnyConverter.toType(anyBool); failed(""); 751 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 752 try { AnyConverter.toType(aChar); failed(""); 753 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 754 try { AnyConverter.toType(anyChar); failed(""); 755 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 756 try { AnyConverter.toType(aByte); failed(""); 757 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 758 try { AnyConverter.toType(anyByte); failed(""); 759 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 760 try { AnyConverter.toType(aShort); failed(""); 761 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 762 try { AnyConverter.toType(anyShort); failed(""); 763 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 764 try { AnyConverter.toType(aInt); failed(""); 765 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 766 try { AnyConverter.toType(anyInt); failed(""); 767 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 768 try { AnyConverter.toType(aLong); failed(""); 769 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 770 try { AnyConverter.toType(anyLong); failed(""); 771 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 772 try { AnyConverter.toType(aFloat); failed(""); 773 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 774 try { AnyConverter.toType(anyFloat); failed(""); 775 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 776 try { AnyConverter.toType(aDouble); failed(""); 777 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 778 try { AnyConverter.toType(anyDouble); failed(""); 779 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 780 try { AnyConverter.toType(aObj); failed(""); 781 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 782 try { AnyConverter.toType(aStr); failed(""); 783 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 784 try { AnyConverter.toType(anyStr); failed(""); 785 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 786 try { AnyConverter.toType(anyVoid); failed(""); 787 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 788 try { AnyConverter.toType(arByte); failed(""); 789 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 790 try { AnyConverter.toType(anyArByte); failed(""); 791 } catch (com.sun.star.lang.IllegalArgumentException ie) {} 792 } 793 test_isBoolean()794 public void test_isBoolean() { 795 assure("", AnyConverter.isBoolean(aBool)); 796 assure("", AnyConverter.isBoolean(anyBool)); 797 assure("", !AnyConverter.isBoolean(aChar)); 798 } 799 test_isChar()800 public void test_isChar() { 801 assure("", AnyConverter.isChar(aChar)); 802 assure("", AnyConverter.isChar(anyChar)); 803 assure("", !AnyConverter.isChar(aBool)); 804 } 805 test_isByte()806 public void test_isByte() { 807 assure("", AnyConverter.isByte(aByte)); 808 assure("", AnyConverter.isByte(anyByte)); 809 assure("", !AnyConverter.isByte(aBool)); 810 } 811 test_isShort()812 public void test_isShort() { 813 assure("", AnyConverter.isShort(aShort)); 814 assure("", AnyConverter.isShort(anyShort)); 815 assure("", Type.SHORT.equals(AnyConverter.getType(anyShort))); 816 Any a = new Any( Type.UNSIGNED_SHORT, new Short((short)5) ); 817 assure("", Type.UNSIGNED_SHORT.equals(AnyConverter.getType(a))); 818 assure("", !AnyConverter.isShort(a)); 819 assure("", !Type.SHORT.equals(AnyConverter.getType(a))); 820 assure("", !AnyConverter.isShort(aBool)); 821 } 822 test_isInt()823 public void test_isInt() { 824 assure("", AnyConverter.isInt(aInt)); 825 assure("", AnyConverter.isInt(anyInt)); 826 assure("", Type.LONG.equals(AnyConverter.getType(anyInt))); 827 Any a = new Any(Type.UNSIGNED_LONG, new Integer(5)); 828 assure("", Type.UNSIGNED_LONG.equals(AnyConverter.getType(a))); 829 assure("", !AnyConverter.isInt(a)); 830 assure("", !Type.LONG.equals(AnyConverter.getType(a))); 831 assure("", !AnyConverter.isInt(aBool)); 832 } 833 test_isLong()834 public void test_isLong() { 835 assure("", AnyConverter.isLong(aLong)); 836 assure("", AnyConverter.isLong(anyLong)); 837 assure("", Type.HYPER.equals(AnyConverter.getType(anyLong))); 838 Any a = new Any( Type.UNSIGNED_HYPER, new Long(5) ); 839 assure("", Type.UNSIGNED_HYPER.equals( AnyConverter.getType(a) )); 840 assure("", !AnyConverter.isLong(a)); 841 assure("", !Type.HYPER.equals( AnyConverter.getType(a) )); 842 assure("", !AnyConverter.isLong(aBool)); 843 } 844 test_isFloat()845 public void test_isFloat() { 846 assure("", AnyConverter.isFloat(aFloat)); 847 assure("", AnyConverter.isFloat(anyFloat)); 848 assure("", !AnyConverter.isFloat(aDouble)); 849 } 850 test_isDouble()851 public void test_isDouble() { 852 assure("", AnyConverter.isDouble(aDouble)); 853 assure("", AnyConverter.isDouble(anyDouble)); 854 assure("", !AnyConverter.isDouble(aFloat)); 855 } 856 test_isObject()857 public void test_isObject() { 858 assure("", AnyConverter.isObject(aObj)); 859 assure("", AnyConverter.isObject( new Any( XInterface.class, null))); 860 assure("", !AnyConverter.isObject(new Object())); 861 } 862 test_isString()863 public void test_isString() { 864 assure("", AnyConverter.isString(aStr)); 865 assure("", AnyConverter.isString(anyStr)); 866 assure("", !AnyConverter.isString(new Object())); 867 } 868 test_isType()869 public void test_isType() { 870 assure("", AnyConverter.isType(aType)); 871 assure("", AnyConverter.isType(anyType)); 872 assure("", !AnyConverter.isType(new Object())); 873 } 874 test_isArray()875 public void test_isArray() { 876 assure("", AnyConverter.isArray(arByte)); 877 assure("", AnyConverter.isArray(anyArByte)); 878 assure("", !AnyConverter.isArray(new Object())); 879 } 880 test_isVoid()881 public void test_isVoid() { 882 assure("", AnyConverter.isVoid(anyVoid)); 883 assure("", !AnyConverter.isVoid(new Object())); 884 } 885 } 886 887 888 class ATypeProvider implements com.sun.star.lang.XTypeProvider 889 { 890 getImplementationId()891 public byte[] getImplementationId() 892 { 893 return new byte[]{1,2,3}; 894 } 895 getTypes()896 public com.sun.star.uno.Type[] getTypes() 897 { 898 return new Type[]{new Type(XTypeProvider.class)}; 899 } 900 901 } 902