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.lib.uno.helper; 25 import com.sun.star.lang.EventObject; 26 import com.sun.star.lang.DisposedException; 27 import com.sun.star.uno.Type; 28 import com.sun.star.uno.TypeClass; 29 import com.sun.star.uno.XInterface; 30 import com.sun.star.uno.UnoRuntime; 31 import com.sun.star.uno.Any; 32 import com.sun.star.uno.XWeak; 33 import com.sun.star.beans.XPropertySet; 34 import com.sun.star.beans.UnknownPropertyException; 35 import com.sun.star.beans.Property; 36 import com.sun.star.beans.PropertyAttribute; 37 import com.sun.star.beans.XPropertyChangeListener; 38 import com.sun.star.beans.PropertyVetoException; 39 import com.sun.star.beans.PropertyChangeEvent; 40 import com.sun.star.beans.XVetoableChangeListener; 41 import com.sun.star.beans.XPropertySetInfo; 42 import com.sun.star.beans.XPropertiesChangeListener; 43 44 import java.util.Arrays; 45 46 public class PropertySet_Test 47 { 48 49 /** Creates a new instance of PropertySet_Test */ PropertySet_Test()50 public PropertySet_Test() 51 { 52 } 53 convertPropertyValue()54 public boolean convertPropertyValue() 55 { 56 System.out.println("PropertySet.convertPropertyValue"); 57 boolean[] r= new boolean[50]; 58 int i= 0; 59 60 TestClass cl= new TestClass(); 61 try { 62 r[i++]= cl.test_convertPropertyValue(); 63 }catch(java.lang.Exception e){ 64 i++; 65 } 66 boolean bOk= true; 67 for (int c= 0; c < i; c++) 68 bOk= bOk && r[c]; 69 if (bOk == false) 70 System.out.println("Failed"); 71 else 72 System.out.println("Ok"); 73 return bOk; 74 } 75 setPropertyValueNoBroadcast()76 public boolean setPropertyValueNoBroadcast() 77 { 78 System.out.println("PropertySet.setValueNoBroadcast"); 79 boolean[] r= new boolean[50]; 80 int i= 0; 81 82 TestClass cl= new TestClass(); 83 try { 84 r[i++]= cl.test_setPropertyValueNoBroadcast(); 85 }catch(java.lang.Exception e){ 86 i++; 87 } 88 boolean bOk= true; 89 for (int c= 0; c < i; c++) 90 bOk= bOk && r[c]; 91 if (bOk == false) 92 System.out.println("Failed"); 93 else 94 System.out.println("Ok"); 95 return bOk; 96 } 97 setPropertyValue()98 public boolean setPropertyValue() 99 { 100 System.out.println("PropertySet.setPropertyValue"); 101 boolean[] r= new boolean[150]; 102 int i= 0; 103 104 TestClass cl= new TestClass(); 105 try { 106 cl.resetPropertyMembers(); 107 Object value; 108 Object ret; 109 value= new Boolean(true); 110 cl.setPropertyValue("PropBoolA", value); 111 ret= cl.getPropertyValue("PropBoolA"); 112 r[i++]= ((Boolean) ret).equals( (Boolean) value); 113 value= new Character('A'); 114 cl.setPropertyValue("PropCharA",value); 115 ret= cl.getPropertyValue("PropCharA"); 116 r[i++]= ((Character) ret).equals((Character) value); 117 value= new Byte((byte) 111); 118 cl.setPropertyValue("PropByteA",value); 119 ret= cl.getPropertyValue("PropByteA"); 120 r[i++]= ((Byte) ret).equals((Byte) value); 121 value= new Short((short)112); 122 cl.setPropertyValue("PropShortA", value); 123 ret= cl.getPropertyValue("PropShortA"); 124 r[i++]= ((Short) ret).equals((Short) value); 125 value= new Integer(113); 126 cl.setPropertyValue("PropIntA", value); 127 ret= cl.getPropertyValue("PropIntA"); 128 r[i++]= ((Integer) ret).equals((Integer) value); 129 value= new Long(115); 130 cl.setPropertyValue("PropLongA", value); 131 ret= cl.getPropertyValue("PropLongA"); 132 r[i++]= ((Long) ret).equals((Long) value); 133 value= new Float(3.14); 134 cl.setPropertyValue("PropFloatA", value); 135 ret= cl.getPropertyValue("PropFloatA"); 136 r[i++]= ((Float) ret).equals((Float) value); 137 value= new Double(3.145); 138 cl.setPropertyValue("PropDoubleA",value); 139 ret= cl.getPropertyValue("PropDoubleA"); 140 r[i++]= ((Double) ret).equals((Double) value); 141 value= new String("string"); 142 cl.setPropertyValue("PropStringA",value); 143 ret= cl.getPropertyValue("PropStringA"); 144 r[i++]= ((String) ret).equals((String) value); 145 value= new ComponentBase(); 146 cl.setPropertyValue("PropXInterfaceA",value); 147 ret= cl.getPropertyValue("PropXInterfaceA"); 148 r[i++]= ((XInterface) ret).equals((XInterface) value); 149 value= new ComponentBase(); 150 cl.setPropertyValue("PropXWeakA",value); 151 ret= cl.getPropertyValue("PropXWeakA"); 152 r[i++]= ((XWeak) ret).equals((XWeak) value); 153 value = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE; 154 cl.setPropertyValue("PropEnum",value); 155 ret= cl.getPropertyValue("PropEnum"); 156 r[i++]= ret == value; 157 value= new byte[]{1,2,3}; 158 cl.setPropertyValue("PropArrayByteA", value); 159 ret= cl.getPropertyValue("PropArrayByteA"); 160 r[i++]= ((byte[]) ret).equals((byte[]) value); 161 value= new Type(String.class); 162 cl.setPropertyValue("PropTypeA", value); 163 ret= cl.getPropertyValue("PropTypeA"); 164 r[i++]= ((Type) ret).equals(value); 165 166 // test protected,package,private members 167 value= new Boolean(true); 168 cl.setPropertyValue("PropBoolB", value); 169 ret= cl.getPropertyValue("PropBoolB"); 170 r[i++]= ((Boolean) ret).equals((Boolean) value); 171 cl.setPropertyValue("PropBoolC", value); 172 ret= cl.getPropertyValue("PropBoolC"); 173 r[i++]= ((Boolean) ret).equals((Boolean) value); 174 175 try{ 176 cl.setPropertyValue("PropBoolD", value); 177 i++; 178 }catch (Exception e) 179 { 180 r[i++]= true; 181 } 182 cl.resetPropertyMembers(); 183 184 value= new Boolean(true); 185 cl.setPropertyValue("PropObjectA", value); 186 ret= cl.getPropertyValue("PropObjectA"); 187 r[i++]= ((Boolean) ret).equals((Boolean) value); 188 value= new Character('A'); 189 cl.setPropertyValue("PropObjectA",value); 190 ret= cl.getPropertyValue("PropObjectA"); 191 r[i++]= ((Character) ret).equals((Character) value); 192 value= new Byte((byte) 111); 193 cl.setPropertyValue("PropObjectA",value); 194 ret= cl.getPropertyValue("PropObjectA"); 195 r[i++]= ((Byte) ret).equals((Byte) value); 196 value= new Short((short)112); 197 cl.setPropertyValue("PropObjectA", value); 198 ret= cl.getPropertyValue("PropObjectA"); 199 r[i++]= ((Short) ret).equals((Short) value); 200 value= new Integer(113); 201 cl.setPropertyValue("PropObjectA", value); 202 ret= cl.getPropertyValue("PropObjectA"); 203 r[i++]= ((Integer) ret).equals((Integer) value); 204 value= new Long(115); 205 cl.setPropertyValue("PropObjectA", value); 206 ret= cl.getPropertyValue("PropObjectA"); 207 r[i++]= ((Long) ret).equals((Long) value); 208 value= new Float(3.14); 209 cl.setPropertyValue("PropObjectA", value); 210 ret= cl.getPropertyValue("PropObjectA"); 211 r[i++]= ((Float) ret).equals((Float) value); 212 value= new Double(3.145); 213 cl.setPropertyValue("PropObjectA",value); 214 ret= cl.getPropertyValue("PropObjectA"); 215 r[i++]= ((Double) ret).equals((Double) value); 216 value= new String("string"); 217 cl.setPropertyValue("PropObjectA",value); 218 ret= cl.getPropertyValue("PropObjectA"); 219 r[i++]= ((String) ret).equals((String) value); 220 value= new ComponentBase(); 221 cl.setPropertyValue("PropObjectA",value); 222 ret= cl.getPropertyValue("PropObjectA"); 223 r[i++]= ((XInterface) ret).equals((XInterface) value); 224 value= new ComponentBase(); 225 cl.setPropertyValue("PropObjectA",value); 226 ret= cl.getPropertyValue("PropObjectA"); 227 r[i++]= ((XWeak) ret).equals((XWeak) value); 228 value= new byte[]{1,2,3}; 229 cl.setPropertyValue("PropObjectA", value); 230 ret= cl.getPropertyValue("PropObjectA"); 231 r[i++]= ((byte[]) ret).equals((byte[]) value); 232 value= new Type(String.class); 233 cl.setPropertyValue("PropObjectA", value); 234 ret= cl.getPropertyValue("PropObjectA"); 235 r[i++]= ((Type) ret).equals(value); 236 cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), new Byte((byte)1))); 237 ret= cl.getPropertyValue("PropObjectA"); 238 r[i++]= ((Byte) ret).byteValue() == 1; 239 240 cl.resetPropertyMembers(); 241 value= new Boolean(true); 242 cl.setPropertyValue("PropAnyA", value); 243 ret= cl.getPropertyValue("PropAnyA"); 244 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 245 value= new Character('A'); 246 cl.setPropertyValue("PropAnyA",value); 247 ret= cl.getPropertyValue("PropAnyA"); 248 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 249 value= new Byte((byte) 111); 250 cl.setPropertyValue("PropAnyA",value); 251 ret= cl.getPropertyValue("PropAnyA"); 252 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 253 value= new Short((short)112); 254 cl.setPropertyValue("PropAnyA", value); 255 ret= cl.getPropertyValue("PropAnyA"); 256 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 257 value= new Integer(113); 258 cl.setPropertyValue("PropAnyA", value); 259 ret= cl.getPropertyValue("PropAnyA"); 260 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 261 value= new Long(115); 262 cl.setPropertyValue("PropAnyA", value); 263 ret= cl.getPropertyValue("PropAnyA"); 264 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 265 value= new Float(3.14); 266 cl.setPropertyValue("PropAnyA", value); 267 ret= cl.getPropertyValue("PropAnyA"); 268 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 269 value= new Double(3.145); 270 cl.setPropertyValue("PropAnyA",value); 271 ret= cl.getPropertyValue("PropAnyA"); 272 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 273 value= new String("string"); 274 cl.setPropertyValue("PropAnyA",value); 275 ret= cl.getPropertyValue("PropAnyA"); 276 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 277 value= new ComponentBase(); 278 cl.setPropertyValue("PropAnyA",value); 279 ret= cl.getPropertyValue("PropAnyA"); 280 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 281 value= new ComponentBase(); 282 cl.setPropertyValue("PropAnyA",value); 283 ret= cl.getPropertyValue("PropAnyA"); 284 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 285 value= new byte[]{1,2,3}; 286 cl.setPropertyValue("PropAnyA", value); 287 ret= cl.getPropertyValue("PropAnyA"); 288 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 289 value= new Type(String.class); 290 cl.setPropertyValue("PropAnyA", value); 291 ret= cl.getPropertyValue("PropAnyA"); 292 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 293 294 cl.resetPropertyMembers(); 295 value= new Any(new Type(boolean.class), new Boolean(true)); 296 cl.setPropertyValue("PropBoolA", value); 297 ret= cl.getPropertyValue("PropBoolA"); 298 r[i++]= ret instanceof Boolean && util.anyEquals(value, ret); 299 value= new Any (new Type(char.class), new Character('A')); 300 cl.setPropertyValue("PropCharA",value); 301 ret= cl.getPropertyValue("PropCharA"); 302 r[i++]= ret instanceof Character && util.anyEquals(value, ret); 303 value= new Any(new Type(byte.class), new Byte((byte) 111)); 304 cl.setPropertyValue("PropByteA",value); 305 ret= cl.getPropertyValue("PropByteA"); 306 r[i++]= ret instanceof Byte && util.anyEquals(value, ret); 307 value= new Any(new Type(short.class), new Short((short)112)); 308 cl.setPropertyValue("PropShortA", value); 309 ret= cl.getPropertyValue("PropShortA"); 310 r[i++]= ret instanceof Short && util.anyEquals(value, ret); 311 value= new Any(new Type(int.class), new Integer(113)); 312 cl.setPropertyValue("PropIntA", value); 313 ret= cl.getPropertyValue("PropIntA"); 314 r[i++]= ret instanceof Integer && util.anyEquals(value, ret); 315 value= new Any(new Type(long.class), new Long(115)); 316 cl.setPropertyValue("PropLongA", value); 317 ret= cl.getPropertyValue("PropLongA"); 318 r[i++]= ret instanceof Long && util.anyEquals(value, ret); 319 value= new Any(new Type(float.class), new Float(3.14)); 320 cl.setPropertyValue("PropFloatA", value); 321 ret= cl.getPropertyValue("PropFloatA"); 322 r[i++]= ret instanceof Float && util.anyEquals(value, ret); 323 value= new Any(new Type(double.class),new Double(3.145)); 324 cl.setPropertyValue("PropDoubleA",value); 325 ret= cl.getPropertyValue("PropDoubleA"); 326 r[i++]= ret instanceof Double && util.anyEquals(value, ret); 327 value= new Any(new Type(String.class), new String("string")); 328 cl.setPropertyValue("PropStringA",value); 329 ret= cl.getPropertyValue("PropStringA"); 330 r[i++]= ret instanceof String && util.anyEquals(value, ret); 331 value= new Any(new Type(ComponentBase.class), new ComponentBase()); 332 cl.setPropertyValue("PropXInterfaceA",value); 333 ret= cl.getPropertyValue("PropXInterfaceA"); 334 r[i++]= ret instanceof ComponentBase && util.anyEquals(value, ret); 335 value= new Any( new Type(ComponentBase.class), new ComponentBase()); 336 cl.setPropertyValue("PropXWeakA",value); 337 ret= cl.getPropertyValue("PropXWeakA"); 338 r[i++]= ret instanceof ComponentBase && util.anyEquals(value, ret); 339 value= new Any(new Type(byte[].class), new byte[]{1,2,3}); 340 cl.setPropertyValue("PropArrayByteA", value); 341 ret= cl.getPropertyValue("PropArrayByteA"); 342 r[i++]= ret instanceof byte[] && util.anyEquals(value, ret); 343 value= new Any(new Type(Type.class), new Type(String.class)); 344 cl.setPropertyValue("PropTypeA", value); 345 ret= cl.getPropertyValue("PropTypeA"); 346 r[i++]= ret instanceof Type && util.anyEquals(value, ret); 347 348 349 cl.resetPropertyMembers(); 350 value= new Any(new Type(boolean.class), new Boolean(true)); 351 cl.setPropertyValue("PropAnyA", value); 352 ret= cl.getPropertyValue("PropAnyA"); 353 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 354 value= new Any (new Type(char.class), new Character('A')); 355 cl.setPropertyValue("PropAnyA",value); 356 ret= cl.getPropertyValue("PropAnyA"); 357 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 358 value= new Any(new Type(byte.class), new Byte((byte) 111)); 359 cl.setPropertyValue("PropAnyA",value); 360 ret= cl.getPropertyValue("PropAnyA"); 361 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 362 value= new Any(new Type(short.class), new Short((short)112)); 363 cl.setPropertyValue("PropAnyA", value); 364 ret= cl.getPropertyValue("PropAnyA"); 365 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 366 value= new Any(new Type(int.class), new Integer(113)); 367 cl.setPropertyValue("PropAnyA", value); 368 ret= cl.getPropertyValue("PropAnyA"); 369 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 370 value= new Any(new Type(long.class), new Long(115)); 371 cl.setPropertyValue("PropAnyA", value); 372 ret= cl.getPropertyValue("PropAnyA"); 373 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 374 value= new Any(new Type(float.class), new Float(3.14)); 375 cl.setPropertyValue("PropAnyA", value); 376 ret= cl.getPropertyValue("PropAnyA"); 377 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 378 value= new Any(new Type(double.class),new Double(3.145)); 379 cl.setPropertyValue("PropAnyA",value); 380 ret= cl.getPropertyValue("PropAnyA"); 381 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 382 value= new Any(new Type(String.class), new String("string")); 383 cl.setPropertyValue("PropAnyA",value); 384 ret= cl.getPropertyValue("PropAnyA"); 385 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 386 value= new Any(new Type(ComponentBase.class), new ComponentBase()); 387 cl.setPropertyValue("PropAnyA",value); 388 ret= cl.getPropertyValue("PropAnyA"); 389 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 390 value= new Any( new Type(ComponentBase.class), new ComponentBase()); 391 cl.setPropertyValue("PropAnyA",value); 392 ret= cl.getPropertyValue("PropAnyA"); 393 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 394 value= new Any(new Type(byte[].class), new byte[]{1,2,3}); 395 cl.setPropertyValue("PropAnyA", value); 396 ret= cl.getPropertyValue("PropAnyA"); 397 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 398 value= new Any(new Type(Type.class), new Type(String.class)); 399 cl.setPropertyValue("PropAnyA", value); 400 ret= cl.getPropertyValue("PropAnyA"); 401 r[i++]= ret instanceof Any && util.anyEquals(value, ret); 402 403 404 // ------------------------------------------------------------------------------ 405 cl.resetPropertyMembers(); 406 value= new Boolean(true); 407 cl.setPropertyValue("PropBoolClass", value); 408 ret= cl.getPropertyValue("PropBoolClass"); 409 r[i++]= ((Boolean) ret).equals( (Boolean) value); 410 value= new Character('A'); 411 cl.setPropertyValue("PropCharClass",value); 412 ret= cl.getPropertyValue("PropCharClass"); 413 r[i++]= ((Character) ret).equals((Character) value); 414 value= new Byte((byte) 111); 415 cl.setPropertyValue("PropByteClass",value); 416 ret= cl.getPropertyValue("PropByteClass"); 417 r[i++]= ((Byte) ret).equals((Byte) value); 418 value= new Short((short)112); 419 cl.setPropertyValue("PropShortClass", value); 420 ret= cl.getPropertyValue("PropShortClass"); 421 r[i++]= ((Short) ret).equals((Short) value); 422 value= new Integer(113); 423 cl.setPropertyValue("PropIntClass", value); 424 ret= cl.getPropertyValue("PropIntClass"); 425 r[i++]= ((Integer) ret).equals((Integer) value); 426 value= new Long(115); 427 cl.setPropertyValue("PropLongClass", value); 428 ret= cl.getPropertyValue("PropLongClass"); 429 r[i++]= ((Long) ret).equals((Long) value); 430 value= new Float(3.14); 431 cl.setPropertyValue("PropFloatClass", value); 432 ret= cl.getPropertyValue("PropFloatClass"); 433 r[i++]= ((Float) ret).equals((Float) value); 434 value= new Double(3.145); 435 cl.setPropertyValue("PropDoubleClass",value); 436 ret= cl.getPropertyValue("PropDoubleClass"); 437 r[i++]= ((Double) ret).equals((Double) value); 438 439 cl.resetPropertyMembers(); 440 441 cl.resetPropertyMembers(); 442 value= new Any(new Type(boolean.class), new Boolean(true)); 443 cl.setPropertyValue("PropBoolClass", value); 444 ret= cl.getPropertyValue("PropBoolClass"); 445 r[i++]= ret instanceof Boolean && util.anyEquals(value, ret); 446 value= new Any (new Type(char.class), new Character('A')); 447 cl.setPropertyValue("PropCharClass",value); 448 ret= cl.getPropertyValue("PropCharClass"); 449 r[i++]= ret instanceof Character && util.anyEquals(value, ret); 450 value= new Any(new Type(byte.class), new Byte((byte) 111)); 451 cl.setPropertyValue("PropByteClass",value); 452 ret= cl.getPropertyValue("PropByteClass"); 453 r[i++]= ret instanceof Byte && util.anyEquals(value, ret); 454 value= new Any(new Type(short.class), new Short((short)112)); 455 cl.setPropertyValue("PropShortClass", value); 456 ret= cl.getPropertyValue("PropShortClass"); 457 r[i++]= ret instanceof Short && util.anyEquals(value, ret); 458 value= new Any(new Type(int.class), new Integer(113)); 459 cl.setPropertyValue("PropIntClass", value); 460 ret= cl.getPropertyValue("PropIntClass"); 461 r[i++]= ret instanceof Integer && util.anyEquals(value, ret); 462 value= new Any(new Type(long.class), new Long(115)); 463 cl.setPropertyValue("PropLongClass", value); 464 ret= cl.getPropertyValue("PropLongClass"); 465 r[i++]= ret instanceof Long && util.anyEquals(value, ret); 466 value= new Any(new Type(float.class), new Float(3.14)); 467 cl.setPropertyValue("PropFloatClass", value); 468 ret= cl.getPropertyValue("PropFloatClass"); 469 r[i++]= ret instanceof Float && util.anyEquals(value, ret); 470 value= new Any(new Type(double.class),new Double(3.145)); 471 cl.setPropertyValue("PropDoubleClass",value); 472 ret= cl.getPropertyValue("PropDoubleClass"); 473 r[i++]= ret instanceof Double && util.anyEquals(value, ret); 474 value= new Any(new Type(String.class), new String("string")); 475 476 477 478 // PropertyAttribute.READONLY 479 cl.propBoolA.Attributes= PropertyAttribute.READONLY; 480 try{ 481 cl.setPropertyValue("PropBoolA", new Boolean(true)); 482 i++; 483 }catch (com.sun.star.beans.PropertyVetoException e) 484 { 485 r[i++]= true; 486 } 487 cl.propBoolA.Attributes= 0; 488 489 // MAYBEVOID 490 cl.resetPropertyMembers(); 491 // first MAYBEVOID not set 492 493 //primitive members: must not work 494 495 cl.boolPropA= false; 496 try { 497 cl.setPropertyValue("PropBoolA", null); i++; 498 } catch (com.sun.star.lang.IllegalArgumentException e) { 499 r[i++]= true; 500 } 501 try { 502 cl.setPropertyValue("PropBoolA", new Any(new Type(boolean.class), null)); i++; 503 } catch (com.sun.star.lang.IllegalArgumentException e) { 504 r[i++]= true; 505 } 506 cl.propBoolA.Attributes= PropertyAttribute.MAYBEVOID; 507 try{ 508 cl.setPropertyValue("PropBoolA", null); i++; 509 } catch (com.sun.star.lang.IllegalArgumentException e) { 510 r[i++]= true; 511 } 512 cl.propBoolA.Attributes= 0; 513 514 cl.propBoolClass.Attributes= PropertyAttribute.MAYBEVOID; 515 cl.boolClassProp= null; 516 cl.setPropertyValue("PropBoolClass", null); 517 r[i++]= cl.boolClassProp == null; 518 // the returned value must be a void any 519 Object objAny= cl.getPropertyValue("PropBoolClass"); 520 r[i++]= util.isVoidAny( objAny); 521 522 cl.boolClassProp= new Boolean(true); 523 cl.setPropertyValue("PropBoolClass", null); 524 r[i++]= cl.boolClassProp == null; 525 cl.boolClassProp= new Boolean(false); 526 cl.setPropertyValue("PropBoolClass", new Any(new Type(boolean.class),null)); 527 r[i++]= cl.boolClassProp == null; 528 529 cl.propXWeakA.Attributes= PropertyAttribute.MAYBEVOID; 530 cl.setPropertyValue("PropXWeakA", null); 531 r[i++]= util.isVoidAny(cl.getPropertyValue("PropXWeakA")); 532 cl.propXWeakA.Attributes= 0; 533 534 cl.anyPropA= null; 535 try{ 536 cl.setPropertyValue("PropAnyA", null); i++; 537 }catch (com.sun.star.lang.IllegalArgumentException e) { 538 r[i++]= true; 539 } 540 cl.anyPropA= null; 541 cl.propAnyA.Attributes= PropertyAttribute.MAYBEVOID; 542 543 Type _t= new Type(Object.class); 544 cl.setPropertyValue("PropAnyA", null); 545 r[i++]= cl.anyPropA.getType().equals(new Type(void.class)) && 546 cl.anyPropA.getObject() == null; 547 548 cl.anyPropA= new Any(new Type(byte.class),new Byte((byte) 111)); 549 cl.setPropertyValue("PropAnyA", null); 550 r[i++]= cl.anyPropA.getType().equals(new Type(byte.class)) && 551 cl.anyPropA.getObject() == null; 552 553 cl.anyPropA= null; 554 try{ 555 cl.setPropertyValue("PropAnyA", new Object()); i++; 556 }catch (com.sun.star.lang.IllegalArgumentException e) 557 { 558 r[i++]= true; 559 } 560 561 cl.propObjectA.Attributes= 0; 562 try{ 563 cl.setPropertyValue("PropObjectA", null); i++; 564 }catch (com.sun.star.lang.IllegalArgumentException e) 565 { 566 r[i++]= true; 567 } 568 try{ 569 cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), null)); i++; 570 } catch (com.sun.star.lang.IllegalArgumentException e) 571 { 572 r[i++]= true; 573 } 574 575 cl.propObjectA.Attributes= PropertyAttribute.MAYBEVOID; 576 cl.propObjectA= null; 577 cl.setPropertyValue("PropObjectA", null); 578 r[i++]= cl.propObjectA == null; 579 580 cl.propObjectA= null; 581 cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), null)); 582 r[i++]= cl.propObjectA == null; 583 584 585 // 586 587 }catch(java.lang.Exception e){ 588 i++; 589 } 590 boolean bOk= true; 591 for (int c= 0; c < i; c++) 592 bOk= bOk && r[c]; 593 if (bOk == false) 594 System.out.println("Failed"); 595 else 596 System.out.println("Ok"); 597 return bOk; 598 } 599 addPropertyChangeListener()600 public boolean addPropertyChangeListener() 601 { 602 System.out.println("PropertySet.addPropertyChangeListener,\n" + 603 "PropertySet.removePropertChangeListener," + 604 "PropertySet.addVetoableChangeListener, \n" + 605 "PropertySet.removeVetoableChangeListener" + 606 "Notification of listeners"); 607 boolean[] r= new boolean[50]; 608 int i= 0; 609 try { 610 TestClass cl= new TestClass(); 611 Listener li= new Listener(); 612 cl.addPropertyChangeListener("PropByteA", li); 613 Byte val1= new Byte((byte)115); 614 cl.setPropertyValue("PropByteA", val1); 615 r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0; 616 cl.propByteA.Attributes = PropertyAttribute.BOUND; 617 cl.addPropertyChangeListener("PropByteA", li); 618 Byte val2= new Byte((byte)116); 619 cl.setPropertyValue("PropByteA", val2); 620 r[i++]= li.nChangeCalled == 1 && li.nVetoCalled == 0; 621 r[i++]= li.evt.OldValue.equals(val1) && li.evt.NewValue.equals(val2) && li.evt.Source == cl; 622 623 li.reset(); 624 Listener li2= new Listener(); 625 cl.addPropertyChangeListener("PropByteA", li2); 626 Byte val3= new Byte((byte) 117); 627 cl.setPropertyValue("PropByteA", val3); 628 r[i++]= li.nChangeCalled == 1 && li.nVetoCalled == 0 629 && li2.nChangeCalled == 1 && li2.nVetoCalled == 0; 630 r[i++]= li.evt.OldValue.equals(val2) && li.evt.NewValue.equals(val3) && li.evt.Source == cl 631 && li2.evt.OldValue.equals(val2) && li2.evt.NewValue.equals(val3) && li2.evt.Source == cl ; 632 633 li.reset(); 634 li2.reset(); 635 Listener li3= new Listener(); 636 val1= new Byte((byte)118); 637 cl.addPropertyChangeListener("", li3); 638 cl.setPropertyValue("PropByteA", val1); 639 r[i++]= li.nChangeCalled == 1 && li.nVetoCalled == 0 640 && li2.nChangeCalled == 1 && li2.nVetoCalled == 0 641 && li3.nChangeCalled == 1 && li3.nVetoCalled == 0; 642 r[i++]= li.evt.OldValue.equals(val3) && li.evt.NewValue.equals(val1) && li.evt.Source == cl; 643 r[i++]= li2.evt.OldValue.equals(val3) && li2.evt.NewValue.equals(val1) && li2.evt.Source == cl; 644 r[i++]= li3.evt.OldValue.equals(val3) && li3.evt.NewValue.equals(val1) && li3.evt.Source == cl ; 645 646 li.reset(); 647 li2.reset(); 648 li3.reset(); 649 cl.removePropertyChangeListener("PropByteA",li); 650 cl.setPropertyValue("PropByteA", val1); 651 r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0 652 && li2.nChangeCalled == 1 && li2.nVetoCalled == 0 653 && li3.nChangeCalled == 1 && li3.nVetoCalled == 0; 654 cl.removePropertyChangeListener("PropByteA", li2); 655 li.reset(); 656 li2.reset(); 657 li3.reset(); 658 cl.setPropertyValue("PropByteA", val1); 659 r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0 660 && li2.nChangeCalled == 0 && li2.nVetoCalled == 0 661 && li3.nChangeCalled == 1 && li3.nVetoCalled == 0; 662 663 cl.removePropertyChangeListener("", li3); 664 li.reset(); 665 li2.reset(); 666 li3.reset(); 667 cl.setPropertyValue("PropByteA", val2); 668 r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0 669 && li2.nChangeCalled == 0 && li2.nVetoCalled == 0 670 && li3.nChangeCalled == 0 && li3.nVetoCalled == 0; 671 672 cl.addPropertyChangeListener("PropByteA", li); 673 cl.addPropertyChangeListener("PropByteA", li2); 674 cl.addPropertyChangeListener("", li3); 675 cl.dispose(); 676 li.reset(); 677 li2.reset(); 678 li3.reset(); 679 try { 680 cl.setPropertyValue("PropByteA", val2); i++; 681 }catch (DisposedException e) 682 { 683 r[i++]= true; 684 } 685 686 //Vetoable tests 687 cl= new TestClass(); 688 li.reset(); 689 li2.reset(); 690 li3.reset(); 691 cl.addVetoableChangeListener("PropByteA", li); 692 val1= new Byte((byte)115); 693 cl.setPropertyValue("PropByteA", val1); 694 r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0; 695 cl.propByteA.Attributes = PropertyAttribute.CONSTRAINED; 696 cl.addVetoableChangeListener("PropByteA", li); 697 val2= new Byte((byte)116); 698 li.reset(); 699 cl.setPropertyValue("PropByteA", val2); 700 r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 1; 701 r[i++]= li.evt.OldValue.equals(val1) && li.evt.NewValue.equals(val2) && li.evt.Source == cl; 702 703 li.reset(); 704 li2.reset(); 705 li3.reset(); 706 cl.addVetoableChangeListener("PropByteA", li2); 707 val3= new Byte((byte) 117); 708 cl.setPropertyValue("PropByteA", val3); 709 r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 1 710 && li2.nChangeCalled == 0 && li2.nVetoCalled == 1; 711 r[i++]= li.evt.OldValue.equals(val2) && li.evt.NewValue.equals(val3) && li.evt.Source == cl 712 && li2.evt.OldValue.equals(val2) && li2.evt.NewValue.equals(val3) && li2.evt.Source == cl ; 713 714 li.reset(); 715 li2.reset(); 716 li3.reset(); 717 val1= new Byte((byte)118); 718 cl.addVetoableChangeListener("", li3); 719 cl.setPropertyValue("PropByteA", val1); 720 r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 1 721 && li2.nChangeCalled == 0 && li2.nVetoCalled == 1 722 && li3.nChangeCalled == 0 && li3.nVetoCalled == 1; 723 r[i++]= li.evt.OldValue.equals(val3) && li.evt.NewValue.equals(val1) && li.evt.Source == cl; 724 r[i++]= li2.evt.OldValue.equals(val3) && li2.evt.NewValue.equals(val1) && li2.evt.Source == cl; 725 r[i++]= li3.evt.OldValue.equals(val3) && li3.evt.NewValue.equals(val1) && li3.evt.Source == cl ; 726 727 li.reset(); 728 li2.reset(); 729 li3.reset(); 730 // Test Veto Exception 731 cl.setPropertyValue("PropByteA", val1); 732 li.bVeto= true; 733 try { 734 cl.setPropertyValue("PropByteA", val2);i++; 735 } catch (PropertyVetoException e) 736 { 737 r[i++]= true; 738 } 739 r[i++]= cl.bytePropA == val1.byteValue(); 740 li.bVeto= false; 741 742 li.reset(); 743 li2.reset(); 744 li3.reset(); 745 cl.removeVetoableChangeListener("PropByteA",li); 746 cl.setPropertyValue("PropByteA", val1); 747 r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0 748 && li2.nChangeCalled == 0 && li2.nVetoCalled == 1 749 && li3.nChangeCalled == 0 && li3.nVetoCalled == 1; 750 cl.removeVetoableChangeListener("PropByteA", li2); 751 li.reset(); 752 li2.reset(); 753 li3.reset(); 754 cl.setPropertyValue("PropByteA", val1); 755 r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0 756 && li2.nChangeCalled == 0 && li2.nVetoCalled == 0 757 && li3.nChangeCalled == 0 && li3.nVetoCalled == 1; 758 759 cl.removeVetoableChangeListener("", li3); 760 li.reset(); 761 li2.reset(); 762 li3.reset(); 763 cl.setPropertyValue("PropByteA", val2); 764 r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0 765 && li2.nChangeCalled == 0 && li2.nVetoCalled == 0 766 && li3.nChangeCalled == 0 && li3.nVetoCalled == 0; 767 768 cl.addVetoableChangeListener("PropByteA", li); 769 cl.addVetoableChangeListener("PropByteA", li2); 770 cl.addVetoableChangeListener("", li3); 771 cl.dispose(); 772 li.reset(); 773 li2.reset(); 774 li3.reset(); 775 try { 776 cl.setPropertyValue("PropByteA", val2); 777 }catch (DisposedException e) 778 { 779 r[i++]= true; 780 } 781 }catch (Exception e) 782 { 783 i++; 784 } 785 boolean bOk= true; 786 for (int c= 0; c < i; c++) 787 bOk= bOk && r[c]; 788 if (bOk == false) 789 System.out.println("Failed"); 790 else 791 System.out.println("Ok"); 792 return bOk; 793 } 794 getPropertySetInfo()795 public boolean getPropertySetInfo() 796 { 797 System.out.println("PropertySet.getPropertySetInfo"); 798 boolean[] r= new boolean[50]; 799 int i= 0; 800 801 TestClass cl= new TestClass(); 802 try { 803 XPropertySetInfo info= cl.getPropertySetInfo(); 804 Property[] arProps= info.getProperties(); 805 Property[] arRegProps= cl.getRegisteredProperties(); 806 r[i++]= arProps.length == arRegProps.length; 807 for (int j= 0; j < arProps.length; j++) 808 { 809 boolean bFound= false; 810 for (int k= 0; k < arRegProps.length; k++) 811 { 812 if (arProps[j] == arRegProps[k]) 813 { 814 bFound= true; 815 break; 816 } 817 } 818 if ( !bFound) 819 r[i++]= false; 820 } 821 822 for (int j= 0; j < arRegProps.length; j++) 823 { 824 Property prop= info.getPropertyByName(arRegProps[j].Name); 825 if (prop != arRegProps[j]) 826 r[i++]= false; 827 if (! info.hasPropertyByName(arRegProps[j].Name)) 828 r[i++]= false; 829 } 830 831 832 }catch(java.lang.Exception e){ 833 System.out.println(e.getMessage()); 834 i++; 835 } 836 837 boolean bOk= true; 838 for (int c= 0; c < i; c++) 839 bOk= bOk && r[c]; 840 if (bOk == false) 841 System.out.println("Failed"); 842 else 843 System.out.println("Ok"); 844 return bOk; 845 } 846 setFastPropertyValue()847 public boolean setFastPropertyValue() 848 { 849 System.out.println("PropertySet.setFastPropertyValue"); 850 boolean[] r= new boolean[50]; 851 int i= 0; 852 853 TestClass cl= new TestClass(); 854 try { 855 cl.setFastPropertyValue(5, new Integer(111)); 856 r[i++]= cl.intPropA == 111; 857 try { 858 cl.setFastPropertyValue(-1, new Integer(1)); i++; 859 } catch(UnknownPropertyException e) 860 { 861 r[i++]= true; 862 } 863 }catch(java.lang.Exception e){ 864 System.out.println(e.getMessage()); 865 i++; 866 } 867 868 boolean bOk= true; 869 for (int c= 0; c < i; c++) 870 bOk= bOk && r[c]; 871 if (bOk == false) 872 System.out.println("Failed"); 873 else 874 System.out.println("Ok"); 875 return bOk; 876 } 877 getFastPropertyValue()878 public boolean getFastPropertyValue() 879 { 880 System.out.println("PropertySet.setFastPropertyValue"); 881 boolean[] r= new boolean[50]; 882 int i= 0; 883 884 TestClass cl= new TestClass(); 885 try { 886 cl.setFastPropertyValue(5, new Integer(111)); 887 Integer aInt= (Integer) cl.getFastPropertyValue(5); 888 r[i++]= aInt.intValue() == 111; 889 }catch(java.lang.Exception e){ 890 System.out.println(e.getMessage()); 891 i++; 892 } 893 894 boolean bOk= true; 895 for (int c= 0; c < i; c++) 896 bOk= bOk && r[c]; 897 if (bOk == false) 898 System.out.println("Failed"); 899 else 900 System.out.println("Ok"); 901 return bOk; 902 } 903 setPropertyValues()904 public boolean setPropertyValues() 905 { 906 System.out.println("PropertySet.setPropertyValues"); 907 boolean[] r= new boolean[50]; 908 int i= 0; 909 910 TestClass cl= new TestClass(); 911 try { 912 cl.setPropertyValues(new String[0], new Object[0]); 913 String[] arNames= new String[] {"PropCharA","PropIntClass","PropObjectA"}; 914 Character aChar= new Character('A'); 915 Integer aInt= new Integer(111); 916 Byte aByte= new Byte((byte)11); 917 Object[] values= new Object[]{aChar, aInt, aByte}; 918 cl.setPropertyValues(arNames, values); 919 r[i++]= cl.charPropA == 'A' && cl.intClassProp.intValue() == 111 && ((Byte)cl.objectPropA).byteValue() == 11; 920 921 arNames= new String[] {"blabla","PropIntClass","PropObjectA"}; 922 cl.resetPropertyMembers(); 923 cl.setPropertyValues(arNames, values); 924 r[i++]= cl.intClassProp.intValue() == 111 && ((Byte)cl.objectPropA).byteValue() == 11; 925 }catch(java.lang.Exception e){ 926 System.out.println(e.getMessage()); 927 i++; 928 } 929 boolean bOk= true; 930 for (int c= 0; c < i; c++) 931 bOk= bOk && r[c]; 932 if (bOk == false) 933 System.out.println("Failed"); 934 else 935 System.out.println("Ok"); 936 return bOk; 937 } 938 getPropertyValues()939 public boolean getPropertyValues() 940 { 941 System.out.println("PropertySet.getPropertyValues"); 942 boolean[] r= new boolean[50]; 943 int i= 0; 944 945 TestClass cl= new TestClass(); 946 try { 947 cl.charPropA= 'A'; 948 cl.intClassProp= new Integer(111); 949 cl.objectPropA= new Byte((byte)11); 950 Object[] values= cl.getPropertyValues(new String[] {"PropCharA","PropIntClass","PropObjectA"}); 951 952 r[i++]= ((Character) values[0]).charValue() == 'A' && ((Integer) values[1]).intValue() == 111 953 && ((Byte) values[2]).byteValue() == 11; 954 }catch(java.lang.Exception e){ 955 System.out.println(e.getMessage()); 956 i++; 957 } 958 boolean bOk= true; 959 for (int c= 0; c < i; c++) 960 bOk= bOk && r[c]; 961 if (bOk == false) 962 System.out.println("Failed"); 963 else 964 System.out.println("Ok"); 965 return bOk; 966 } 967 968 // Currently the listeners are always notified if one of properties has changed. 969 // The property names in the first argument are ignored. addPropertiesChangeListener()970 public boolean addPropertiesChangeListener() 971 { 972 System.out.println("PropertySet.addPropertiesChangeListener\n" + 973 "PropertySet.removePropertiesChangeListener\n" + 974 "notification of such listeners"); 975 boolean[] r= new boolean[50]; 976 int i= 0; 977 978 TestClass cl= new TestClass(); 979 try { 980 Listener li1= new Listener(); 981 Listener li2= new Listener(); 982 cl.addPropertiesChangeListener(new String[]{"PropCharA"}, li1); 983 cl.setPropertyValue("PropCharA", new Character('B')); 984 r[i++]= li1.nPropertiesChange == 0; 985 cl.propCharA.Attributes= PropertyAttribute.BOUND; 986 cl.setPropertyValue("PropCharA", new Character('C')); 987 r[i++]= li1.nPropertiesChange == 1; 988 989 PropertyChangeEvent evt= li1.arEvt[0]; 990 r[i++]= evt.PropertyName.equals("PropCharA") && ((Character)evt.OldValue).charValue() == 'B' 991 && ((Character) evt.NewValue).charValue() == 'C'; 992 li1.reset(); 993 cl.removePropertiesChangeListener(li1); 994 cl.setPropertyValue("PropCharA", new Character('F')); 995 r[i++]= li1.nPropertiesChange == 0; 996 }catch(java.lang.Exception e){ 997 System.out.println(e.getMessage()); 998 i++; 999 } 1000 boolean bOk= true; 1001 for (int c= 0; c < i; c++) 1002 bOk= bOk && r[c]; 1003 if (bOk == false) 1004 System.out.println("Failed"); 1005 else 1006 System.out.println("Ok"); 1007 return bOk; 1008 } 1009 firePropertiesChangeEvent()1010 public boolean firePropertiesChangeEvent() 1011 { 1012 System.out.println("PropertySet.firePropertiesChangeEvent"); 1013 boolean[] r= new boolean[50]; 1014 int i= 0; 1015 1016 TestClass cl= new TestClass(); 1017 try { 1018 Listener li1= new Listener(); 1019 cl.intClassProp= new Integer(111); 1020 cl.charPropA= 'A'; 1021 cl.firePropertiesChangeEvent(new String[]{"PropCharA","PropIntClass"}, li1); 1022 r[i++]= li1.nPropertiesChange == 1; 1023 PropertyChangeEvent[] arEvt= li1.arEvt; 1024 r[i++]= arEvt[0].PropertyName.equals("PropCharA") 1025 && ((Character) arEvt[0].OldValue).charValue() == 'A' 1026 && ((Character) arEvt[0].NewValue).charValue() == 'A'; 1027 r[i++]= arEvt[1].PropertyName.equals("PropIntClass") 1028 && ((Integer) arEvt[1].OldValue).intValue() == 111 1029 && ((Integer) arEvt[1].NewValue).intValue() == 111; 1030 }catch(java.lang.Exception e){ 1031 System.out.println(e.getMessage()); 1032 i++; 1033 } 1034 boolean bOk= true; 1035 for (int c= 0; c < i; c++) 1036 bOk= bOk && r[c]; 1037 if (bOk == false) 1038 System.out.println("Failed"); 1039 else 1040 System.out.println("Ok"); 1041 return bOk; 1042 } 1043 registerProperty1()1044 public boolean registerProperty1() 1045 { 1046 TestClass2 cl= new TestClass2(); 1047 return cl.test_registerProperty1(); 1048 } 1049 registerProperty2()1050 public boolean registerProperty2() 1051 { 1052 TestClass2 cl= new TestClass2(); 1053 return cl.test_registerProperty2(); 1054 } 1055 test()1056 public static boolean test() 1057 { 1058 PropertySet_Test test= new PropertySet_Test(); 1059 boolean r[]= new boolean[50]; 1060 int i= 0; 1061 r[i++]= test.convertPropertyValue(); 1062 r[i++]= test.setPropertyValueNoBroadcast(); 1063 r[i++]= test.setPropertyValue(); 1064 r[i++]= test.addPropertyChangeListener(); 1065 r[i++]= test.getPropertySetInfo(); 1066 r[i++]= test.setFastPropertyValue(); 1067 r[i++]= test.getFastPropertyValue(); 1068 r[i++]= test.setPropertyValues(); 1069 r[i++]= test.getPropertyValues(); 1070 r[i++]= test.addPropertiesChangeListener(); 1071 r[i++]= test.firePropertiesChangeEvent(); 1072 r[i++]= test.registerProperty1(); 1073 r[i++]= test.registerProperty2(); 1074 boolean bOk= true; 1075 for (int c= 0; c < i; c++) 1076 bOk= bOk && r[c]; 1077 if (bOk == false) 1078 System.out.println("Errors occurred!"); 1079 else 1080 System.out.println("No errors."); 1081 return bOk; 1082 } main(String[] args)1083 public static void main(String[] args) 1084 { 1085 test(); 1086 } 1087 } 1088 1089 class TestClass extends PropertySet 1090 { 1091 public Property propBoolA= new Property("PropBoolA", 1, new Type(Boolean.TYPE), (short)0); 1092 public boolean boolPropA; 1093 public Property propCharA= new Property("PropCharA", 2, new Type(Character.TYPE), (short) 0); 1094 public char charPropA; 1095 public Property propByteA= new Property("PropByteA", 3, new Type(Byte.TYPE), (short) 0); 1096 public byte bytePropA; 1097 public Property propShortA= new Property("PropShortA", 4, new Type(Short.TYPE), (short) 0); 1098 public short shortPropA; 1099 public Property propIntA= new Property("PropIntA", 5, new Type(Integer.TYPE), (short) 0); 1100 public int intPropA; 1101 public Property propLongA= new Property("PropLongA", 6, new Type(Long.TYPE), (short) 0); 1102 public long longPropA; 1103 public Property propFloatA= new Property("PropFloatA", 7, new Type(Float.TYPE), (short) 0); 1104 public float floatPropA; 1105 public Property propDoubleA= new Property("PropDoubleA", 8, new Type(Double.TYPE), (short) 0); 1106 public double doublePropA; 1107 public Property propStringA= new Property("PropStringA", 9, new Type(String.class), (short) 0); 1108 public String stringPropA; 1109 public Property propArrayByteA= new Property("PropArrayByteA", 10, new Type(byte[].class), (short) 0); 1110 public byte[] arBytePropA; 1111 public Property propTypeA= new Property("PropTypeA", 11, new Type(Type.class), (short) 0); 1112 public Type typePropA; 1113 public Property propObjectA= new Property("PropObjectA",12, new Type(Object.class), (short) 0); 1114 public Object objectPropA; 1115 public Property propAnyA= new Property("PropAnyA", 13, new Type(Any.class), (short) 0); 1116 public Any anyPropA; 1117 public Property propXInterfaceA= new Property("PropXInterfaceA", 13, new Type(Any.class), (short) 0); 1118 public XInterface xInterfacePropA; 1119 public Property propXWeakA= new Property("PropXWeakA", 13, new Type(Any.class), (short) 0); 1120 public XWeak xWeakPropA; 1121 public Property propEnum = 1122 new Property("PropEnum", 14, new Type("com.sun.star.beans.PropertyState", TypeClass.ENUM), (short)0); 1123 public com.sun.star.beans.PropertyState enumPropertyState = com.sun.star.beans.PropertyState.DEFAULT_VALUE; 1124 // Test private, protected, package access, Anys as arguments and members, members with a value 1125 1126 public Property propBoolB= new Property("PropBoolB", 101, new Type(Boolean.TYPE), (short) 0); 1127 protected boolean boolPropB; 1128 1129 public Property propBoolC= new Property("PropBoolC", 201, new Type(Boolean.TYPE), (short) 0); 1130 boolean boolPropC; 1131 1132 public Property propBoolD= new Property("PropBoolD", 301, new Type(Boolean.TYPE), (short) 0); 1133 private boolean boolPropD; 1134 1135 public Property propBoolClass= new Property("PropBoolClass", 1001, new Type(Boolean.class), (short) 0); 1136 public Boolean boolClassProp; 1137 public Property propCharClass= new Property("PropCharClass", 1002, new Type(Character.class), (short) 0); 1138 public Character charClassProp; 1139 public Property propByteClass= new Property("PropByteClass", 1003, new Type(Byte.class), (short) 0); 1140 public Byte byteClassProp; 1141 public Property propShortClass= new Property("PropShortClass", 1004, new Type(Short.class), (short) 0); 1142 public Short shortClassProp; 1143 public Property propIntClass= new Property("PropIntClass", 1005, new Type(Integer.class), (short) 0); 1144 public Integer intClassProp; 1145 public Property propLongClass= new Property("PropLongClass", 1006, new Type(Long.class), (short) 0); 1146 public Long longClassProp; 1147 public Property propFloatClass= new Property("PropFloatClass", 1007, new Type(Float.class), (short) 0); 1148 public Float floatClassProp; 1149 public Property propDoubleClass= new Property("PropDoubleClass", 1008, new Type(Double.class), (short) 0); 1150 public Double doubleClassProp; 1151 1152 TestClass()1153 public TestClass() 1154 { 1155 1156 super(); 1157 // When adding properties then modify the getRegisteredProperties method 1158 //registerProperty(String name, int handle, Type type, short attributes, String memberName) 1159 registerProperty(propBoolA, "boolPropA"); 1160 registerProperty(propCharA, "charPropA"); 1161 registerProperty(propByteA, "bytePropA"); 1162 registerProperty(propShortA, "shortPropA"); 1163 registerProperty(propIntA, "intPropA"); 1164 registerProperty(propLongA, "longPropA"); 1165 registerProperty(propFloatA, "floatPropA"); 1166 registerProperty(propDoubleA, "doublePropA"); 1167 registerProperty(propStringA, "stringPropA"); 1168 registerProperty(propArrayByteA, "arBytePropA"); 1169 registerProperty(propTypeA, "typePropA"); 1170 registerProperty(propObjectA, "objectPropA"); 1171 registerProperty(propAnyA, "anyPropA"); 1172 registerProperty(propXInterfaceA, "xInterfacePropA"); 1173 registerProperty(propXWeakA, "xWeakPropA"); 1174 registerProperty(propEnum,"enumPropertyState"); 1175 registerProperty(propBoolB, "boolPropB"); 1176 registerProperty(propBoolC, "boolPropC"); 1177 registerProperty(propBoolD, "boolPropD"); 1178 registerProperty(propBoolClass, "boolClassProp"); 1179 registerProperty(propCharClass, "charClassProp"); 1180 registerProperty(propByteClass, "byteClassProp"); 1181 registerProperty(propShortClass, "shortClassProp"); 1182 registerProperty(propIntClass, "intClassProp"); 1183 registerProperty(propLongClass, "longClassProp"); 1184 registerProperty(propFloatClass, "floatClassProp"); 1185 registerProperty(propDoubleClass, "doubleClassProp"); 1186 } 1187 1188 /** When adding properties then modify the getRegisteredProperties method 1189 */ getRegisteredProperties()1190 public Property[] getRegisteredProperties() 1191 { 1192 return new Property[] { 1193 propBoolA, propCharA, propByteA, propShortA, 1194 propIntA, propLongA, propFloatA, propDoubleA, 1195 propStringA, propArrayByteA, propTypeA, propObjectA, 1196 propAnyA, propXInterfaceA, propXWeakA, propEnum, propBoolB, 1197 propBoolC, propBoolD, propBoolClass, propCharClass, 1198 propByteClass, propShortClass, propIntClass, propLongClass, 1199 propFloatClass, propDoubleClass 1200 }; 1201 1202 } test_convertPropertyValue()1203 public boolean test_convertPropertyValue() 1204 { 1205 boolean[] r= new boolean[150]; 1206 int i= 0; 1207 1208 resetPropertyMembers(); 1209 Object[] outOldVal= new Object[1]; 1210 Object[] outNewVal= new Object[1]; 1211 1212 Object value= new Boolean(true); 1213 try 1214 { 1215 r[i++]= convertPropertyValue(propBoolA, outNewVal, outOldVal, value); 1216 r[i++]= outNewVal[0] instanceof Boolean && outNewVal[0].equals(value) && outOldVal[0].equals(new Boolean(false)); 1217 value= new Character('A'); 1218 r[i++]= convertPropertyValue(propCharA, outNewVal, outOldVal, value); 1219 r[i++]= outNewVal[0] instanceof Character && outNewVal[0].equals(value) && outOldVal[0].equals(new Character((char)0)); 1220 charPropA= 'B'; 1221 r[i++]= convertPropertyValue(propCharA, outNewVal, outOldVal, value); 1222 r[i++]= outNewVal[0] instanceof Character && outNewVal[0].equals(value) && outOldVal[0].equals(new Character('B')); 1223 value= new Byte((byte) 111); 1224 r[i++]= convertPropertyValue(propByteA, outNewVal, outOldVal, value); 1225 r[i++]= outNewVal[0] instanceof Byte && outNewVal[0].equals(value); 1226 value= new Short((short) 112); 1227 r[i++]= convertPropertyValue(propShortA, outNewVal, outOldVal, value); 1228 r[i++]= outNewVal[0] instanceof Short && outNewVal[0].equals(value); 1229 value= new Integer( 113); 1230 r[i++]= convertPropertyValue(propIntA, outNewVal, outOldVal, value); 1231 r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals(value); 1232 value= new Long(114); 1233 r[i++]= convertPropertyValue(propLongA, outNewVal, outOldVal, value); 1234 r[i++]= outNewVal[0] instanceof Long && outNewVal[0].equals(value); 1235 value= new Float(3.14); 1236 r[i++]= convertPropertyValue(propFloatA, outNewVal, outOldVal, value); 1237 r[i++]= outNewVal[0] instanceof Float && outNewVal[0].equals(value); 1238 value= new Double(3.145); 1239 r[i++]= convertPropertyValue(propDoubleA, outNewVal, outOldVal, value); 1240 r[i++]= outNewVal[0] instanceof Double && outNewVal[0].equals(value); 1241 value= "string"; 1242 r[i++]= convertPropertyValue(propStringA, outNewVal, outOldVal, value); 1243 r[i++]= outNewVal[0] instanceof String && outNewVal[0].equals(value); 1244 value= new byte[]{1,2,3}; 1245 arBytePropA= null; 1246 r[i++]= convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value); 1247 r[i++]= outNewVal[0] instanceof byte[] && outNewVal[0].equals(value) && outOldVal[0] == null; 1248 r[i++]= convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value); 1249 r[i++]= outOldVal[0] == null; 1250 value= new Type(XInterface.class); 1251 r[i++]= convertPropertyValue(propTypeA, outNewVal, outOldVal, value); 1252 r[i++]= outNewVal[0] instanceof Type && outNewVal[0].equals(value); 1253 1254 value= new Object(); // TypeClass.VOID 1255 r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value); 1256 r[i++]= outNewVal[0] instanceof Object && outNewVal[0].equals(value); 1257 value= new Integer(111); 1258 r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value); 1259 r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals(value); 1260 value= new ComponentBase(); 1261 r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value); 1262 r[i++]= outNewVal[0] instanceof Object && outNewVal[0].equals(value); 1263 value= new Integer(111); 1264 r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value); 1265 r[i++]= outNewVal[0] instanceof Any && ((Any)outNewVal[0]).getType().equals(new Type(Integer.class)) 1266 && ((Any)outNewVal[0]).getObject().equals(value); 1267 XWeak oWeak= new ComponentBase(); 1268 value= oWeak; 1269 // The returned Any must contain an XInterface 1270 r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value); 1271 r[i++]= ((Any) outNewVal[0]).getType().equals(new Type(XInterface.class)) 1272 && ((Any) outNewVal[0]).getObject() == oWeak; 1273 value= new ComponentBase(); 1274 r[i++]= convertPropertyValue(propXInterfaceA, outNewVal, outOldVal, value); 1275 r[i++]= outNewVal[0] instanceof XInterface && outNewVal[0].equals(value); 1276 r[i++]= convertPropertyValue(propXWeakA, outNewVal, outOldVal, value); 1277 r[i++]= outNewVal[0] instanceof XWeak && outNewVal[0].equals(value); 1278 1279 value = com.sun.star.beans.PropertyState.DIRECT_VALUE; 1280 r[i++]= convertPropertyValue(propEnum, outNewVal, outOldVal, value); 1281 r[i++]= outNewVal[0] instanceof com.sun.star.uno.Enum && outNewVal[0].equals(value); 1282 1283 // Any arguments ------------------------------------------------------------------ 1284 value= new Any( new Type(Integer.class),new Integer(111)); 1285 r[i++]= convertPropertyValue(propIntA, outNewVal, outOldVal, value); 1286 r[i++]= outNewVal[0] instanceof Integer && ((Integer)outNewVal[0]).equals( ((Any)value).getObject()); 1287 value= new Any(new Type(Boolean.class), new Boolean(true)); 1288 r[i++]= convertPropertyValue(propBoolA, outNewVal, outOldVal, value); 1289 r[i++]= outNewVal[0] instanceof Boolean && ((Boolean)outNewVal[0]).equals(((Any) value).getObject()); 1290 //Character, Byte, Short, Long 1291 // must fail 1292 value= new Any(new Type(Object.class), new Object()); 1293 r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value); 1294 r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value); 1295 value= new Any(new Type(Integer.class), new Integer(111)); 1296 r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value); 1297 r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals( ((Any)value).getObject()); 1298 r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value); 1299 r[i++]= outNewVal[0] instanceof Any && ((Any) outNewVal[0]).getType().equals( ((Any) value).getType()) 1300 && ((Any) outNewVal[0]).getObject().equals( ((Any) value).getObject()); 1301 value= new Any(new Type(XInterface.class), new ComponentBase()); 1302 r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value); 1303 r[i++]= outNewVal[0] instanceof XInterface && outNewVal[0] == ((Any) value).getObject(); 1304 r[i++]= convertPropertyValue(propXInterfaceA, outNewVal, outOldVal, value); 1305 r[i++]= outNewVal[0] == ((Any) value).getObject(); 1306 value= new Any(new Type(byte[].class), new byte[]{1,2,3}); 1307 r[i++]= convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value); 1308 r[i++]= outNewVal[0] instanceof byte[]; 1309 1310 1311 1312 // test private, protected, package fields 1313 value= new Boolean(true); 1314 r[i++]= convertPropertyValue(propBoolB, outNewVal, outOldVal, value); 1315 r[i++]= ((Boolean)value).booleanValue() == ((Boolean) outNewVal[0]).booleanValue(); 1316 r[i++]= convertPropertyValue(propBoolC, outNewVal, outOldVal, value); 1317 r[i++]= ((Boolean)value).booleanValue() == ((Boolean) outNewVal[0]).booleanValue(); 1318 // must fail because the member boolPropD is private 1319 try{ 1320 convertPropertyValue(propBoolD, outNewVal, outOldVal, value); 1321 i++; 1322 }catch (Exception e) 1323 { 1324 r[i++]= true; 1325 } 1326 1327 // Properties member of type Byte,Short etc. 1328 value= new Boolean(true); 1329 r[i++]= convertPropertyValue(propBoolClass, outNewVal, outOldVal, value); 1330 r[i++]= outNewVal[0] instanceof Boolean && outNewVal[0].equals(value); 1331 value= new Character('A'); 1332 r[i++]= convertPropertyValue(propCharClass, outNewVal, outOldVal, value); 1333 r[i++]= outNewVal[0] instanceof Character && outNewVal[0].equals(value); 1334 value= new Byte((byte) 111); 1335 r[i++]= convertPropertyValue(propByteClass, outNewVal, outOldVal, value); 1336 r[i++]= outNewVal[0] instanceof Byte && outNewVal[0].equals(value); 1337 value= new Short((short) 112); 1338 r[i++]= convertPropertyValue(propShortClass, outNewVal, outOldVal, value); 1339 r[i++]= outNewVal[0] instanceof Short && outNewVal[0].equals(value); 1340 value= new Integer( 113); 1341 r[i++]= convertPropertyValue(propIntClass, outNewVal, outOldVal, value); 1342 r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals(value); 1343 value= new Long(114); 1344 r[i++]= convertPropertyValue(propLongClass, outNewVal, outOldVal, value); 1345 r[i++]= outNewVal[0] instanceof Long && outNewVal[0].equals(value); 1346 value= new Float(3.14); 1347 r[i++]= convertPropertyValue(propFloatClass, outNewVal, outOldVal, value); 1348 r[i++]= outNewVal[0] instanceof Float && outNewVal[0].equals(value); 1349 value= new Double(3.145); 1350 r[i++]= convertPropertyValue(propDoubleA, outNewVal, outOldVal, value); 1351 r[i++]= outNewVal[0] instanceof Double && outNewVal[0].equals(value); 1352 }catch (com.sun.star.uno.Exception e) 1353 { 1354 i++; 1355 } 1356 boolean bOk= true; 1357 for (int c= 0; c < i; c++) 1358 bOk= bOk && r[c]; 1359 1360 return bOk; 1361 } 1362 test_setPropertyValueNoBroadcast()1363 public boolean test_setPropertyValueNoBroadcast() 1364 { 1365 boolean[] r= new boolean[150]; 1366 int i= 0; 1367 resetPropertyMembers(); 1368 try { 1369 Object value= new Boolean(true); 1370 setPropertyValueNoBroadcast(propBoolA, value); 1371 r[i++]= boolPropA == ((Boolean) value).booleanValue(); 1372 value= new Character('A'); 1373 setPropertyValueNoBroadcast(propCharA, value); 1374 r[i++]= charPropA == ((Character) value).charValue(); 1375 value= new Byte((byte) 111); 1376 setPropertyValueNoBroadcast(propByteA, value); 1377 r[i++]= bytePropA == ((Byte)value).byteValue(); 1378 value= new Short((short) 112); 1379 setPropertyValueNoBroadcast(propShortA, value); 1380 r[i++]= shortPropA == ((Short) value).shortValue(); 1381 value= new Integer( 113); 1382 setPropertyValueNoBroadcast(propIntA, value); 1383 r[i++]= intPropA == ((Integer) value).intValue(); 1384 value= new Long(114); 1385 setPropertyValueNoBroadcast(propLongA, value); 1386 r[i++]= longPropA == ((Long) value).longValue(); 1387 value= new Float(3.14); 1388 setPropertyValueNoBroadcast(propFloatA, value); 1389 r[i++]= floatPropA == ((Float) value).floatValue(); 1390 value= new Double(3.145); 1391 setPropertyValueNoBroadcast(propDoubleA, value); 1392 r[i++]= doublePropA == ((Double) value).doubleValue(); 1393 value= "string"; 1394 setPropertyValueNoBroadcast(propStringA, value); 1395 r[i++]= stringPropA.equals(value); 1396 value= new byte[]{1,2,3}; 1397 setPropertyValueNoBroadcast(propArrayByteA, value); 1398 r[i++]= arBytePropA.equals(value); 1399 value= new Type(XInterface.class); 1400 setPropertyValueNoBroadcast(propTypeA, value); 1401 r[i++]= typePropA.equals(value); 1402 value= new Integer(111); 1403 setPropertyValueNoBroadcast(propObjectA, value); 1404 r[i++]= objectPropA.equals(value); 1405 value= (XInterface) new ComponentBase(); 1406 setPropertyValueNoBroadcast(propObjectA, value); 1407 r[i++]= objectPropA.equals(value); 1408 value= new Any( new Type(Integer.TYPE), new Integer(111)); 1409 setPropertyValueNoBroadcast(propAnyA, value); 1410 r[i++]= util.anyEquals(anyPropA, value); 1411 value= new ComponentBase(); 1412 setPropertyValueNoBroadcast(propXInterfaceA, value); 1413 r[i++]= xInterfacePropA instanceof XInterface && xInterfacePropA.equals(value); 1414 setPropertyValueNoBroadcast(propXWeakA, value); 1415 r[i++]= xInterfacePropA instanceof XWeak && xInterfacePropA.equals(value); 1416 value = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE; 1417 setPropertyValueNoBroadcast(propEnum, value); 1418 r[i++]= enumPropertyState == value; 1419 value= new Boolean(true); 1420 setPropertyValueNoBroadcast(propBoolB, value); 1421 r[i++]= boolPropB == ((Boolean) value).booleanValue(); 1422 setPropertyValueNoBroadcast(propBoolC, value); 1423 r[i++]= boolPropC == ((Boolean) value).booleanValue(); 1424 // must fail because the member boolPropD is private 1425 try{ 1426 setPropertyValueNoBroadcast(propBoolD, value); 1427 }catch(com.sun.star.lang.WrappedTargetException e) 1428 { 1429 r[i++]= true; 1430 } 1431 }catch (java.lang.Exception e) 1432 { 1433 i++; 1434 } 1435 boolean bOk= true; 1436 for (int c= 0; c < i; c++) 1437 bOk= bOk && r[c]; 1438 return bOk; 1439 } 1440 resetPropertyMembers()1441 void resetPropertyMembers() 1442 { 1443 boolPropA= false; 1444 charPropA= (char) 0; 1445 bytePropA= 0; 1446 shortPropA= 0; 1447 intPropA= 0; 1448 longPropA= 0; 1449 floatPropA= 0; 1450 doublePropA= 0.; 1451 stringPropA= null; 1452 arBytePropA= null; 1453 typePropA= null; 1454 objectPropA= null; 1455 anyPropA= null; 1456 xInterfacePropA= null; 1457 xWeakPropA= null; 1458 enumPropertyState = com.sun.star.beans.PropertyState.DEFAULT_VALUE; 1459 boolPropB= false; 1460 boolPropC= false; 1461 boolPropD= false; 1462 boolClassProp= null; 1463 charClassProp= null; 1464 byteClassProp= null; 1465 shortClassProp= null; 1466 intClassProp= null; 1467 longClassProp= null; 1468 floatClassProp= null; 1469 doubleClassProp= null; 1470 } 1471 } 1472 1473 class TestClass2 extends PropertySet 1474 { 1475 1476 public char charA; 1477 protected char charB; 1478 char charC; 1479 1480 int intMemberA; 1481 1482 public Character charClassA; 1483 protected Character charClassB; 1484 Character charClassC; 1485 test_registerProperty1()1486 boolean test_registerProperty1() 1487 { 1488 System.out.println("registerProperty Test 1"); 1489 boolean r[]= new boolean[50]; 1490 int i= 0; 1491 1492 registerProperty("PropChar", new Type(char.class), (short) 0, "PropChar"); 1493 registerProperty("PropInt", new Type(int.class), (short) 0, "PropInt"); 1494 registerProperty("PropString", new Type(String.class), (short) 0, "PropString"); 1495 1496 XPropertySetInfo info= getPropertySetInfo(); 1497 Property[] props= info.getProperties(); 1498 for (int j= 0; j < props.length; j++) 1499 { 1500 Property aProp= props[j]; 1501 if (aProp.Name.equals("PropChar") && aProp.Type.equals(new Type(char.class)) && 1502 aProp.Attributes == 0) 1503 r[i++]= true; 1504 else if (aProp.Name.equals("PropInt") && aProp.Type.equals(new Type(int.class)) && 1505 aProp.Attributes == 0) 1506 r[i++]= true; 1507 else if (aProp.Name.equals("PropString") && aProp.Type.equals(new Type(String.class)) && 1508 aProp.Attributes == 0) 1509 r[i++]= true; 1510 else 1511 r[i++]= false; 1512 } 1513 1514 boolean bOk= true; 1515 for (int c= 0; c < i; c++) 1516 bOk= bOk && r[c]; 1517 if (bOk == false) 1518 System.out.println("Failed"); 1519 else 1520 System.out.println("Ok"); 1521 return bOk; 1522 } 1523 test_registerProperty2()1524 boolean test_registerProperty2() 1525 { 1526 System.out.println("registerProperty Test 2"); 1527 boolean r[]= new boolean[50]; 1528 int i= 0; 1529 1530 registerProperty("charA", "charA", (short) 0); 1531 registerProperty("charB", "charB", (short) 0); 1532 registerProperty("charC", "charC", (short) 0); 1533 registerProperty("charClassB", "charClassB", PropertyAttribute.MAYBEVOID); 1534 registerProperty("IntProp", "intMemberA", (short) 0); 1535 1536 XPropertySetInfo info= getPropertySetInfo(); 1537 Property[] props= info.getProperties(); 1538 for (int j= 0; j < props.length; j++) 1539 { 1540 Property aProp= props[j]; 1541 if (aProp.Name.equals("charA") && aProp.Type.equals(new Type(char.class)) && 1542 aProp.Attributes == 0) 1543 r[i++]= true; 1544 else if (aProp.Name.equals("charB") && aProp.Type.equals(new Type(char.class)) && 1545 aProp.Attributes == 0) 1546 r[i++]= true; 1547 else if (aProp.Name.equals("charC") && aProp.Type.equals(new Type(char.class)) && 1548 aProp.Attributes == 0) 1549 r[i++]= true; 1550 else if (aProp.Name.equals("charClassB") && aProp.Type.equals(new Type(char.class)) && 1551 aProp.Attributes == PropertyAttribute.MAYBEVOID) 1552 r[i++]= true; 1553 else if (aProp.Name.equals("IntProp") && aProp.Type.equals(new Type(int.class)) && 1554 aProp.Attributes == 0) 1555 r[i++]= true; 1556 else 1557 r[i++]= false; 1558 } 1559 Object ret; 1560 Object val= new Character('A'); 1561 try{ 1562 setPropertyValue("charA", val); 1563 ret= getPropertyValue("charA"); 1564 r[i++]= val.equals(ret); 1565 setPropertyValue("charClassB",val); 1566 ret= getPropertyValue("charClassB"); 1567 r[i++]= val.equals(ret); 1568 val= new Integer(111); 1569 setPropertyValue("IntProp",val); 1570 ret= getPropertyValue("IntProp"); 1571 r[i++]= val.equals(ret); 1572 } 1573 catch(Exception e) 1574 { 1575 r[i++]=false; 1576 } 1577 boolean bOk= true; 1578 for (int c= 0; c < i; c++) 1579 bOk= bOk && r[c]; 1580 if (bOk == false) 1581 System.out.println("Failed"); 1582 else 1583 System.out.println("Ok"); 1584 return bOk; 1585 } 1586 1587 } 1588 1589 class util 1590 { 1591 // An Object is considered an Any with TypeClass.VOID and no value. anyEquals(Object val1, Object val2)1592 static boolean anyEquals(Object val1, Object val2) 1593 { 1594 Object obj1= null; 1595 Object obj2= null; 1596 Type t1= null; 1597 Type t2= null; 1598 if (val1 instanceof Any) 1599 { 1600 obj1= ((Any) val1).getObject(); 1601 t1= ((Any) val1).getType(); 1602 } 1603 else 1604 obj1= val1; 1605 1606 if (val2 instanceof Any) 1607 { 1608 obj2= ((Any) val2).getObject(); 1609 t2= ((Any) val2).getType(); 1610 } 1611 else 1612 obj2= val2; 1613 1614 if (obj1 != null && obj1.equals(obj2)) 1615 return true; 1616 else if ((obj1 == null && obj2 == null) && t1 != null && t1.equals(t2)) 1617 return true; 1618 return false; 1619 } 1620 1621 // returns true if obj is an any that contains a void or interface type and the 1622 // object is null isVoidAny(Object obj)1623 static boolean isVoidAny(Object obj) 1624 { 1625 boolean ret= false; 1626 if( obj != null && obj instanceof Any) 1627 { 1628 Any a= (Any) obj; 1629 if( a.getType().getTypeClass().equals( TypeClass.INTERFACE) 1630 && a.getObject() == null) { 1631 ret= true; 1632 } 1633 else if( a.getType().equals( new Type(void.class)) && a.getObject() == null) { 1634 ret= true; 1635 } 1636 } 1637 return ret; 1638 } 1639 } 1640 1641 class Listener implements XPropertyChangeListener, XVetoableChangeListener, 1642 XPropertiesChangeListener 1643 { 1644 int nChangeCalled; 1645 int nPropertiesChange; 1646 int nVetoCalled; 1647 int nDisposingCalled; 1648 boolean bVeto= false; 1649 PropertyChangeEvent evt; 1650 PropertyChangeEvent[] arEvt; 1651 // XPropertyChangeListener propertyChange(PropertyChangeEvent evt )1652 public void propertyChange(PropertyChangeEvent evt ) 1653 { 1654 nChangeCalled++; 1655 this.evt= evt; 1656 } 1657 1658 //VetoableChangeListener vetoableChange(PropertyChangeEvent evt )1659 public void vetoableChange(PropertyChangeEvent evt ) throws PropertyVetoException 1660 { 1661 nVetoCalled++; 1662 this.evt= evt; 1663 if (bVeto) 1664 throw new PropertyVetoException(); 1665 } 1666 disposing( EventObject Source )1667 public void disposing( /*IN*/EventObject Source ) 1668 { 1669 nDisposingCalled++; 1670 } 1671 reset()1672 public void reset() 1673 { 1674 nChangeCalled= 0; 1675 nPropertiesChange= 0; 1676 nVetoCalled= 0; 1677 nDisposingCalled= 0; 1678 evt= null; 1679 arEvt= null; 1680 bVeto= false; 1681 } 1682 // XPropertiesChangeListener propertiesChange(PropertyChangeEvent[] propertyChangeEvent)1683 public void propertiesChange(PropertyChangeEvent[] propertyChangeEvent) 1684 { 1685 nPropertiesChange++; 1686 arEvt= propertyChangeEvent; 1687 } 1688 1689 } 1690