1 7 8 package com.sun.corba.se.impl.dynamicany; 9 10 import org.omg.CORBA.Any ; 11 import org.omg.CORBA.TypeCode ; 12 import org.omg.CORBA.TypeCodePackage.BadKind ; 13 import org.omg.CORBA.TCKind ; 14 15 import org.omg.DynamicAny.*; 16 import org.omg.DynamicAny.DynAnyPackage.TypeMismatch ; 17 import org.omg.DynamicAny.DynAnyPackage.InvalidValue ; 18 import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode ; 19 20 import com.sun.corba.se.spi.orb.ORB ; 21 import com.sun.corba.se.spi.logging.CORBALogDomains ; 22 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 23 24 public class DynAnyBasicImpl extends DynAnyImpl 25 { 26 30 private DynAnyBasicImpl() { 31 this(null, (Any )null, false); 32 } 33 34 protected DynAnyBasicImpl(ORB orb, Any any, boolean copyValue) { 35 super(orb, any, copyValue); 36 index = NO_INDEX; 38 } 39 40 protected DynAnyBasicImpl(ORB orb, TypeCode typeCode) { 41 super(orb, typeCode); 42 index = NO_INDEX; 44 } 45 46 50 public void assign (org.omg.DynamicAny.DynAny dyn_any) 51 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch 52 { 53 if (status == STATUS_DESTROYED) { 54 throw wrapper.dynAnyDestroyed() ; 55 } 56 super.assign(dyn_any); 57 index = NO_INDEX; 58 } 59 60 public void from_any (org.omg.CORBA.Any value) 61 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 62 org.omg.DynamicAny.DynAnyPackage.InvalidValue 63 { 64 if (status == STATUS_DESTROYED) { 65 throw wrapper.dynAnyDestroyed() ; 66 } 67 super.from_any(value); 68 index = NO_INDEX; 69 } 70 71 public org.omg.CORBA.Any to_any() { 73 if (status == STATUS_DESTROYED) { 74 throw wrapper.dynAnyDestroyed() ; 75 } 76 return DynAnyUtil.copy(any, orb); 77 } 78 79 public boolean equal (org.omg.DynamicAny.DynAny dyn_any) { 80 if (status == STATUS_DESTROYED) { 81 throw wrapper.dynAnyDestroyed() ; 82 } 83 if (dyn_any == this) { 84 return true; 85 } 86 if ( ! any.type().equal(dyn_any.type())) { 89 return false; 90 } 91 return any.equal(getAny(dyn_any)); 93 } 94 95 public void destroy() { 96 if (status == STATUS_DESTROYED) { 97 throw wrapper.dynAnyDestroyed() ; 98 } 99 if (status == STATUS_DESTROYABLE) { 100 status = STATUS_DESTROYED; 101 } 102 } 103 104 public org.omg.DynamicAny.DynAny copy() { 105 if (status == STATUS_DESTROYED) { 106 throw wrapper.dynAnyDestroyed() ; 107 } 108 try { 110 return DynAnyUtil.createMostDerivedDynAny(any, orb, true); 111 } catch (InconsistentTypeCode ictc) { 112 return null; } 114 } 115 116 public org.omg.DynamicAny.DynAny current_component() 117 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch 118 { 119 return null; 120 } 121 122 public int component_count() { 123 return 0; 124 } 125 126 public boolean next() { 127 return false; 128 } 129 130 public boolean seek(int index) { 131 return false; 132 } 133 134 public void rewind() { 135 } 136 137 public void insert_boolean(boolean value) 138 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 139 org.omg.DynamicAny.DynAnyPackage.InvalidValue 140 { 141 if (status == STATUS_DESTROYED) { 142 throw wrapper.dynAnyDestroyed() ; 143 } 144 if (any.type().kind().value() != TCKind._tk_boolean) 145 throw new TypeMismatch (); 146 any.insert_boolean(value); 147 } 148 149 public void insert_octet(byte value) 150 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 151 org.omg.DynamicAny.DynAnyPackage.InvalidValue 152 { 153 if (status == STATUS_DESTROYED) { 154 throw wrapper.dynAnyDestroyed() ; 155 } 156 if (any.type().kind().value() != TCKind._tk_octet) 157 throw new TypeMismatch (); 158 any.insert_octet(value); 159 } 160 161 public void insert_char(char value) 162 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 163 org.omg.DynamicAny.DynAnyPackage.InvalidValue 164 { 165 if (status == STATUS_DESTROYED) { 166 throw wrapper.dynAnyDestroyed() ; 167 } 168 if (any.type().kind().value() != TCKind._tk_char) 169 throw new TypeMismatch (); 170 any.insert_char(value); 171 } 172 173 public void insert_short(short value) 174 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 175 org.omg.DynamicAny.DynAnyPackage.InvalidValue 176 { 177 if (status == STATUS_DESTROYED) { 178 throw wrapper.dynAnyDestroyed() ; 179 } 180 if (any.type().kind().value() != TCKind._tk_short) 181 throw new TypeMismatch (); 182 any.insert_short(value); 183 } 184 185 public void insert_ushort(short value) 186 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 187 org.omg.DynamicAny.DynAnyPackage.InvalidValue 188 { 189 if (status == STATUS_DESTROYED) { 190 throw wrapper.dynAnyDestroyed() ; 191 } 192 if (any.type().kind().value() != TCKind._tk_ushort) 193 throw new TypeMismatch (); 194 any.insert_ushort(value); 195 } 196 197 public void insert_long(int value) 198 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 199 org.omg.DynamicAny.DynAnyPackage.InvalidValue 200 { 201 if (status == STATUS_DESTROYED) { 202 throw wrapper.dynAnyDestroyed() ; 203 } 204 if (any.type().kind().value() != TCKind._tk_long) 205 throw new TypeMismatch (); 206 any.insert_long(value); 207 } 208 209 public void insert_ulong(int value) 210 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 211 org.omg.DynamicAny.DynAnyPackage.InvalidValue 212 { 213 if (status == STATUS_DESTROYED) { 214 throw wrapper.dynAnyDestroyed() ; 215 } 216 if (any.type().kind().value() != TCKind._tk_ulong) 217 throw new TypeMismatch (); 218 any.insert_ulong(value); 219 } 220 221 public void insert_float(float value) 222 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 223 org.omg.DynamicAny.DynAnyPackage.InvalidValue 224 { 225 if (status == STATUS_DESTROYED) { 226 throw wrapper.dynAnyDestroyed() ; 227 } 228 if (any.type().kind().value() != TCKind._tk_float) 229 throw new TypeMismatch (); 230 any.insert_float(value); 231 } 232 233 public void insert_double(double value) 234 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 235 org.omg.DynamicAny.DynAnyPackage.InvalidValue 236 { 237 if (status == STATUS_DESTROYED) { 238 throw wrapper.dynAnyDestroyed() ; 239 } 240 if (any.type().kind().value() != TCKind._tk_double) 241 throw new TypeMismatch (); 242 any.insert_double(value); 243 } 244 245 public void insert_string(String value) 246 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 247 org.omg.DynamicAny.DynAnyPackage.InvalidValue 248 { 249 if (status == STATUS_DESTROYED) { 250 throw wrapper.dynAnyDestroyed() ; 251 } 252 if (any.type().kind().value() != TCKind._tk_string) 253 throw new TypeMismatch (); 254 if (value == null) 255 throw new InvalidValue (); 256 try { 258 if (any.type().length() > 0 && any.type().length() < value.length()) 259 throw new InvalidValue (); 260 } catch (BadKind bad) { } 262 any.insert_string(value); 263 } 264 265 public void insert_reference(org.omg.CORBA.Object value) 266 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 267 org.omg.DynamicAny.DynAnyPackage.InvalidValue 268 { 269 if (status == STATUS_DESTROYED) { 270 throw wrapper.dynAnyDestroyed() ; 271 } 272 if (any.type().kind().value() != TCKind._tk_objref) 273 throw new TypeMismatch (); 274 any.insert_Object(value); 275 } 276 277 public void insert_typecode(org.omg.CORBA.TypeCode value) 278 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 279 org.omg.DynamicAny.DynAnyPackage.InvalidValue 280 { 281 if (status == STATUS_DESTROYED) { 282 throw wrapper.dynAnyDestroyed() ; 283 } 284 if (any.type().kind().value() != TCKind._tk_TypeCode) 285 throw new TypeMismatch (); 286 any.insert_TypeCode(value); 287 } 288 289 public void insert_longlong(long value) 290 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 291 org.omg.DynamicAny.DynAnyPackage.InvalidValue 292 { 293 if (status == STATUS_DESTROYED) { 294 throw wrapper.dynAnyDestroyed() ; 295 } 296 if (any.type().kind().value() != TCKind._tk_longlong) 297 throw new TypeMismatch (); 298 any.insert_longlong(value); 299 } 300 301 public void insert_ulonglong(long value) 302 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 303 org.omg.DynamicAny.DynAnyPackage.InvalidValue 304 { 305 if (status == STATUS_DESTROYED) { 306 throw wrapper.dynAnyDestroyed() ; 307 } 308 if (any.type().kind().value() != TCKind._tk_ulonglong) 309 throw new TypeMismatch (); 310 any.insert_ulonglong(value); 311 } 312 313 public void insert_wchar(char value) 314 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 315 org.omg.DynamicAny.DynAnyPackage.InvalidValue 316 { 317 if (status == STATUS_DESTROYED) { 318 throw wrapper.dynAnyDestroyed() ; 319 } 320 if (any.type().kind().value() != TCKind._tk_wchar) 321 throw new TypeMismatch (); 322 any.insert_wchar(value); 323 } 324 325 public void insert_wstring(String value) 326 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 327 org.omg.DynamicAny.DynAnyPackage.InvalidValue 328 { 329 if (status == STATUS_DESTROYED) { 330 throw wrapper.dynAnyDestroyed() ; 331 } 332 if (any.type().kind().value() != TCKind._tk_wstring) 333 throw new TypeMismatch (); 334 if (value == null) 335 throw new InvalidValue (); 336 try { 338 if (any.type().length() > 0 && any.type().length() < value.length()) 339 throw new InvalidValue (); 340 } catch (BadKind bad) { } 342 any.insert_wstring(value); 343 } 344 345 public void insert_any(org.omg.CORBA.Any value) 346 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 347 org.omg.DynamicAny.DynAnyPackage.InvalidValue 348 { 349 if (status == STATUS_DESTROYED) { 350 throw wrapper.dynAnyDestroyed() ; 351 } 352 if (any.type().kind().value() != TCKind._tk_any) 353 throw new TypeMismatch (); 354 any.insert_any(value); 355 } 356 357 public void insert_dyn_any (org.omg.DynamicAny.DynAny value) 358 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 359 org.omg.DynamicAny.DynAnyPackage.InvalidValue 360 { 361 if (status == STATUS_DESTROYED) { 362 throw wrapper.dynAnyDestroyed() ; 363 } 364 if (any.type().kind().value() != TCKind._tk_any) 365 throw new TypeMismatch (); 366 any.insert_any(value.to_any()); 368 } 369 370 public void insert_val(java.io.Serializable value) 371 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 372 org.omg.DynamicAny.DynAnyPackage.InvalidValue 373 { 374 if (status == STATUS_DESTROYED) { 375 throw wrapper.dynAnyDestroyed() ; 376 } 377 int kind = any.type().kind().value(); 378 if (kind != TCKind._tk_value && kind != TCKind._tk_value_box) 379 throw new TypeMismatch (); 380 any.insert_Value(value); 381 } 382 383 public java.io.Serializable get_val() 384 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 385 org.omg.DynamicAny.DynAnyPackage.InvalidValue 386 { 387 if (status == STATUS_DESTROYED) { 388 throw wrapper.dynAnyDestroyed() ; 389 } 390 int kind = any.type().kind().value(); 391 if (kind != TCKind._tk_value && kind != TCKind._tk_value_box) 392 throw new TypeMismatch (); 393 return any.extract_Value(); 394 } 395 396 public boolean get_boolean() 397 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 398 org.omg.DynamicAny.DynAnyPackage.InvalidValue 399 { 400 if (status == STATUS_DESTROYED) { 401 throw wrapper.dynAnyDestroyed() ; 402 } 403 if (any.type().kind().value() != TCKind._tk_boolean) 404 throw new TypeMismatch (); 405 return any.extract_boolean(); 406 } 407 408 public byte get_octet() 409 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 410 org.omg.DynamicAny.DynAnyPackage.InvalidValue 411 { 412 if (status == STATUS_DESTROYED) { 413 throw wrapper.dynAnyDestroyed() ; 414 } 415 if (any.type().kind().value() != TCKind._tk_octet) 416 throw new TypeMismatch (); 417 return any.extract_octet(); 418 } 419 420 public char get_char() 421 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 422 org.omg.DynamicAny.DynAnyPackage.InvalidValue 423 { 424 if (status == STATUS_DESTROYED) { 425 throw wrapper.dynAnyDestroyed() ; 426 } 427 if (any.type().kind().value() != TCKind._tk_char) 428 throw new TypeMismatch (); 429 return any.extract_char(); 430 } 431 432 public short get_short() 433 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 434 org.omg.DynamicAny.DynAnyPackage.InvalidValue 435 { 436 if (status == STATUS_DESTROYED) { 437 throw wrapper.dynAnyDestroyed() ; 438 } 439 if (any.type().kind().value() != TCKind._tk_short) 440 throw new TypeMismatch (); 441 return any.extract_short(); 442 } 443 444 public short get_ushort() 445 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 446 org.omg.DynamicAny.DynAnyPackage.InvalidValue 447 { 448 if (status == STATUS_DESTROYED) { 449 throw wrapper.dynAnyDestroyed() ; 450 } 451 if (any.type().kind().value() != TCKind._tk_ushort) 452 throw new TypeMismatch (); 453 return any.extract_ushort(); 454 } 455 456 public int get_long() 457 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 458 org.omg.DynamicAny.DynAnyPackage.InvalidValue 459 { 460 if (status == STATUS_DESTROYED) { 461 throw wrapper.dynAnyDestroyed() ; 462 } 463 if (any.type().kind().value() != TCKind._tk_long) 464 throw new TypeMismatch (); 465 return any.extract_long(); 466 } 467 468 public int get_ulong() 469 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 470 org.omg.DynamicAny.DynAnyPackage.InvalidValue 471 { 472 if (status == STATUS_DESTROYED) { 473 throw wrapper.dynAnyDestroyed() ; 474 } 475 if (any.type().kind().value() != TCKind._tk_ulong) 476 throw new TypeMismatch (); 477 return any.extract_ulong(); 478 } 479 480 public float get_float() 481 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 482 org.omg.DynamicAny.DynAnyPackage.InvalidValue 483 { 484 if (status == STATUS_DESTROYED) { 485 throw wrapper.dynAnyDestroyed() ; 486 } 487 if (any.type().kind().value() != TCKind._tk_float) 488 throw new TypeMismatch (); 489 return any.extract_float(); 490 } 491 492 public double get_double() 493 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 494 org.omg.DynamicAny.DynAnyPackage.InvalidValue 495 { 496 if (status == STATUS_DESTROYED) { 497 throw wrapper.dynAnyDestroyed() ; 498 } 499 if (any.type().kind().value() != TCKind._tk_double) 500 throw new TypeMismatch (); 501 return any.extract_double(); 502 } 503 504 public String get_string() 505 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 506 org.omg.DynamicAny.DynAnyPackage.InvalidValue 507 { 508 if (status == STATUS_DESTROYED) { 509 throw wrapper.dynAnyDestroyed() ; 510 } 511 if (any.type().kind().value() != TCKind._tk_string) 512 throw new TypeMismatch (); 513 return any.extract_string(); 514 } 515 516 public org.omg.CORBA.Object get_reference() 517 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 518 org.omg.DynamicAny.DynAnyPackage.InvalidValue 519 { 520 if (status == STATUS_DESTROYED) { 521 throw wrapper.dynAnyDestroyed() ; 522 } 523 if (any.type().kind().value() != TCKind._tk_objref) 524 throw new TypeMismatch (); 525 return any.extract_Object(); 526 } 527 528 public org.omg.CORBA.TypeCode get_typecode() 529 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 530 org.omg.DynamicAny.DynAnyPackage.InvalidValue 531 { 532 if (status == STATUS_DESTROYED) { 533 throw wrapper.dynAnyDestroyed() ; 534 } 535 if (any.type().kind().value() != TCKind._tk_TypeCode) 536 throw new TypeMismatch (); 537 return any.extract_TypeCode(); 538 } 539 540 public long get_longlong() 541 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 542 org.omg.DynamicAny.DynAnyPackage.InvalidValue 543 { 544 if (status == STATUS_DESTROYED) { 545 throw wrapper.dynAnyDestroyed() ; 546 } 547 if (any.type().kind().value() != TCKind._tk_longlong) 548 throw new TypeMismatch (); 549 return any.extract_longlong(); 550 } 551 552 public long get_ulonglong() 553 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 554 org.omg.DynamicAny.DynAnyPackage.InvalidValue 555 { 556 if (status == STATUS_DESTROYED) { 557 throw wrapper.dynAnyDestroyed() ; 558 } 559 if (any.type().kind().value() != TCKind._tk_ulonglong) 560 throw new TypeMismatch (); 561 return any.extract_ulonglong(); 562 } 563 564 public char get_wchar() 565 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 566 org.omg.DynamicAny.DynAnyPackage.InvalidValue 567 { 568 if (status == STATUS_DESTROYED) { 569 throw wrapper.dynAnyDestroyed() ; 570 } 571 if (any.type().kind().value() != TCKind._tk_wchar) 572 throw new TypeMismatch (); 573 return any.extract_wchar(); 574 } 575 576 public String get_wstring() 577 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 578 org.omg.DynamicAny.DynAnyPackage.InvalidValue 579 { 580 if (status == STATUS_DESTROYED) { 581 throw wrapper.dynAnyDestroyed() ; 582 } 583 if (any.type().kind().value() != TCKind._tk_wstring) 584 throw new TypeMismatch (); 585 return any.extract_wstring(); 586 } 587 588 public org.omg.CORBA.Any get_any() 589 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 590 org.omg.DynamicAny.DynAnyPackage.InvalidValue 591 { 592 if (status == STATUS_DESTROYED) { 593 throw wrapper.dynAnyDestroyed() ; 594 } 595 if (any.type().kind().value() != TCKind._tk_any) 596 throw new TypeMismatch (); 597 return any.extract_any(); 598 } 599 600 public org.omg.DynamicAny.DynAny get_dyn_any() 601 throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch , 602 org.omg.DynamicAny.DynAnyPackage.InvalidValue 603 { 604 if (status == STATUS_DESTROYED) { 605 throw wrapper.dynAnyDestroyed() ; 606 } 607 if (any.type().kind().value() != TCKind._tk_any) 608 throw new TypeMismatch (); 609 try { 611 return DynAnyUtil.createMostDerivedDynAny(any.extract_any(), orb, true); 612 } catch (InconsistentTypeCode ictc) { 613 return null; 616 } 617 } 618 } 619 | Popular Tags |