1 /* 2 * %CopyrightBegin% 3 * 4 * Copyright Ericsson AB 1999-2016. All Rights Reserved. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * 18 * %CopyrightEnd% 19 * 20 */ 21 package com.ericsson.otp.ic; 22 23 24 /** 25 26 The Any class is the java mapping of the any OMG-IDL type. 27 28 29 **/ 30 31 32 public class Any { 33 34 // Typecode value holder 35 protected TypeCode tcV; 36 37 // Primitive value holder 38 protected java.lang.String stringV; 39 protected byte byteV; 40 protected boolean booleanV; 41 protected char charV; 42 protected short shortV; 43 protected int intV; 44 protected long longV; 45 protected float floatV; 46 protected double doubleV; 47 48 // Streams used for user defined types 49 protected com.ericsson.otp.erlang.OtpInputStream is; 50 protected com.ericsson.otp.erlang.OtpOutputStream os; 51 52 53 // Constructor Any()54 public Any() { 55 tcV = null; 56 } 57 58 // Equal function 59 60 /** 61 Any comparison method 62 @return true if the input Any is equal to the object, false otherwize 63 **/ equal(com.ericsson.otp.ic.Any _any)64 public boolean equal(com.ericsson.otp.ic.Any _any) { 65 66 int _is1Len,_is2Len; 67 byte _compressed[]; 68 com.ericsson.otp.erlang.OtpInputStream _is1,_is2; 69 TypeCode _tc = _any.type(); 70 71 if (!tcV.equal(_tc)) 72 return false; 73 74 try { 75 76 TCKind _tck = _tc.kind(); 77 78 switch (_tck.value()) { 79 80 case TCKind._tk_short: 81 return (_any.extract_short() == shortV); 82 83 case TCKind._tk_ushort: 84 return (_any.extract_ushort() == shortV); 85 86 case TCKind._tk_long: 87 return (_any.extract_long() == intV); 88 89 case TCKind._tk_longlong: 90 return (_any.extract_longlong() == longV); 91 92 case TCKind._tk_ulong: 93 return (_any.extract_ulong() == intV); 94 95 case TCKind._tk_ulonglong: 96 return (_any.extract_ulonglong() == longV); 97 98 case TCKind._tk_float: 99 return equal(_any.extract_float(),floatV); 100 101 case TCKind._tk_double: 102 return equal(_any.extract_double(),doubleV); 103 104 case TCKind._tk_boolean: 105 return (_any.extract_boolean() == booleanV); 106 107 case TCKind._tk_char: 108 return (_any.extract_char() == charV); 109 110 case TCKind._tk_wchar: 111 return (_any.extract_wchar() == charV); 112 113 case TCKind._tk_octet: 114 return (_any.extract_octet() == byteV); 115 116 case TCKind._tk_string: 117 return (_any.extract_string().compareTo(stringV) == 0); 118 119 case TCKind._tk_wstring: 120 return (_any.extract_wstring().compareTo(stringV) == 0); 121 122 case TCKind._tk_sequence: 123 124 _is1 = new com.ericsson.otp.erlang.OtpInputStream(os.toByteArray()); 125 126 _is2 = _any.extract_Streamable(); 127 128 if (_is1.peek() != _is2.peek()) { 129 130 // _is1's sequence is compressed to string 131 if(_is1.peek() == com.ericsson.otp.erlang.OtpExternal.stringTag) { 132 133 _compressed = (_is1.read_string()).getBytes(); 134 _is1Len = _compressed.length; 135 136 _is2.read_list_head(); 137 138 for(int i = 0; i < _is1Len; i++) { 139 if ((long)(_compressed[i] & 0xff) != _is2.read_long()) 140 return false; 141 } 142 143 _is2.read_nil(); 144 } 145 else { // _is2's sequence is compressed to string 146 147 _compressed = (_is2.read_string()).getBytes(); 148 _is2Len = _compressed.length; 149 150 _is1.read_list_head(); 151 152 for(int i = 0; i < _is2Len; i++) 153 if ((long)(_compressed[i] & 0xff) != _is1.read_long()) 154 return false; 155 156 _is1.read_nil(); 157 } 158 } 159 else { // None of them is compressed 160 161 _is2Len = _is2.available(); 162 163 if (_is1.available() != _is2Len) 164 return false; 165 166 for(int i = 0; i < _is2Len; i++) { 167 if (_is1.read() != _is2.read()) 168 return false; 169 } 170 } 171 172 return true; 173 174 case TCKind._tk_struct: 175 case TCKind._tk_union: 176 case TCKind._tk_array: 177 case TCKind._tk_enum: 178 179 _is1 = new com.ericsson.otp.erlang.OtpInputStream(os.toByteArray()); 180 181 _is2 = _any.extract_Streamable(); 182 183 _is2Len = _is2.available(); 184 185 if (_is1.available() != _is2Len) 186 return false; 187 188 for(int i = 0; i < _is2Len; i++) { 189 if (_is1.read() != _is2.read()) 190 return false; 191 } 192 193 return true; 194 195 // Not used in real 196 case TCKind._tk_any: 197 case TCKind._tk_void: 198 case TCKind._tk_atom: 199 case TCKind._tk_null: 200 case TCKind._tk_TypeCode: 201 case TCKind._tk_Principal: 202 case TCKind._tk_objref: 203 case TCKind._tk_alias: 204 case TCKind._tk_except: 205 case TCKind._tk_longdouble: 206 case TCKind._tk_fixed: 207 return true; 208 209 default : 210 return false; 211 212 } 213 } catch (Exception e) { 214 //e.printStackTrace(); 215 return false; 216 } 217 218 } 219 220 221 /* Equal function for floats ( relative diff ) */ equal(float x, float y)222 boolean equal(float x, float y) { 223 224 if (x != 0) 225 return (java.lang.Math.abs((x-y)/x) < 1.0E-15); 226 227 if (y != 0) 228 return (java.lang.Math.abs((y-x)/y) < 1.0E-15); 229 230 return (x==y); 231 } 232 233 /* Equal function for doubles ( relative diff ) */ equal(double x, double y)234 boolean equal(double x, double y) { 235 236 if (x != 0) 237 return (java.lang.Math.abs((x-y)/x) < 1.0E-15); 238 239 if (y != 0) 240 return (java.lang.Math.abs((y-x)/y) < 1.0E-15); 241 242 return (x==y); 243 } 244 245 246 247 /** 248 TypeCode accessor method 249 @return the Any's TypeCode 250 **/ type()251 public TypeCode type() { 252 return tcV; 253 } 254 255 256 /** 257 TypeCode insertion method 258 **/ type(TypeCode _tc)259 public void type(TypeCode _tc) { 260 tcV = _tc; 261 } 262 263 264 /* Value accessors */ 265 266 /** 267 Reads a value from the stream, according to the inserted TypeCode 268 **/ read_value(com.ericsson.otp.erlang.OtpInputStream _is, TypeCode _tc)269 public void read_value(com.ericsson.otp.erlang.OtpInputStream _is, 270 TypeCode _tc) 271 throws java.lang.Exception { 272 273 tcV = _tc; 274 275 switch(tcV.kind().value()) { 276 277 case TCKind._tk_short : 278 shortV = _is.read_short(); 279 break; 280 case TCKind._tk_ushort : 281 shortV = _is.read_ushort(); 282 break; 283 case TCKind._tk_long : 284 intV = _is.read_int(); 285 break; 286 case TCKind._tk_ulong : 287 intV = _is.read_uint(); 288 break; 289 case TCKind._tk_longlong : 290 longV = _is.read_long(); 291 break; 292 case TCKind._tk_ulonglong : 293 longV = _is.read_ulong(); 294 break; 295 case TCKind._tk_float : 296 floatV = _is.read_float(); 297 break; 298 case TCKind._tk_double : 299 doubleV = _is.read_double(); 300 break; 301 case TCKind._tk_boolean : 302 booleanV = _is.read_boolean(); 303 break; 304 case TCKind._tk_char : 305 case TCKind._tk_wchar : 306 charV = _is.read_char(); 307 break; 308 case TCKind._tk_octet : 309 byteV = _is.read_byte(); 310 break; 311 case TCKind._tk_string : 312 case TCKind._tk_wstring : 313 stringV = _is.read_string(); 314 break; 315 case TCKind._tk_atom : 316 stringV = _is.read_atom(); 317 break; 318 case TCKind._tk_void : 319 _is.read_atom(); 320 break; 321 322 /* 323 * Not supported types 324 */ 325 case TCKind._tk_any : 326 case TCKind._tk_null : 327 case TCKind._tk_TypeCode : 328 case TCKind._tk_Principal : 329 case TCKind._tk_objref : 330 case TCKind._tk_alias : 331 case TCKind._tk_except : 332 case TCKind._tk_longdouble : 333 case TCKind._tk_fixed : 334 throw new java.lang.Exception("Unsupported type"); 335 336 default: // User defined type 337 338 if (os == null) 339 os = new com.ericsson.otp.erlang.OtpOutputStream(); 340 else 341 os.reset(); 342 343 try { 344 read_user_defined(_is, _tc); 345 is = new com.ericsson.otp.erlang.OtpInputStream(os.toByteArray()); 346 } catch (Exception e) { 347 throw new java.lang.Exception("BAD VALUE"); 348 } 349 } 350 351 } 352 read_user_defined(com.ericsson.otp.erlang.OtpInputStream _is, TypeCode _tc)353 void read_user_defined(com.ericsson.otp.erlang.OtpInputStream _is, TypeCode _tc) 354 throws java.lang.Exception { 355 356 TypeCode memberTC = null; 357 int len = -1; 358 int __tag; 359 360 switch(_tc.kind().value()) { 361 362 case TCKind._tk_short : 363 os.write_short(_is.read_short()); 364 break; 365 case TCKind._tk_ushort : 366 os.write_ushort(_is.read_ushort()); 367 break; 368 case TCKind._tk_long : 369 os.write_int(_is.read_int()); 370 break; 371 case TCKind._tk_longlong : 372 os.write_long(_is.read_long()); 373 break; 374 case TCKind._tk_ulong : 375 os.write_uint(_is.read_uint()); 376 break; 377 case TCKind._tk_ulonglong : 378 os.write_ulong(_is.read_ulong()); 379 break; 380 case TCKind._tk_float : 381 os.write_float(_is.read_float()); 382 break; 383 case TCKind._tk_double : 384 os.write_double(_is.read_double()); 385 break; 386 case TCKind._tk_boolean : 387 os.write_boolean(_is.read_boolean()); 388 break; 389 case TCKind._tk_char : 390 case TCKind._tk_wchar : 391 os.write_char(_is.read_char()); 392 break; 393 case TCKind._tk_octet : 394 os.write_byte(_is.read_byte()); 395 break; 396 case TCKind._tk_string : 397 case TCKind._tk_wstring : 398 os.write_string(_is.read_string()); 399 break; 400 401 case TCKind._tk_struct: 402 len = _is.read_tuple_head(); 403 os.write_tuple_head(len); 404 os.write_atom(_is.read_atom()); 405 // Member list 406 len -=1; 407 for(int i=0; i<len; i++) 408 read_user_defined(_is,_tc.member_type(i)); 409 break; 410 411 case TCKind._tk_union: 412 os.write_tuple_head(_is.read_tuple_head()); 413 os.write_atom(_is.read_atom()); 414 415 int __mlen = _tc.member_count(); 416 __tag = _is.peek(); 417 boolean __found = false; 418 419 switch (__tag) { 420 case (com.ericsson.otp.erlang.OtpExternal.atomTag): 421 case (com.ericsson.otp.erlang.OtpExternal.atomUtf8Tag): 422 case (com.ericsson.otp.erlang.OtpExternal.smallAtomUtf8Tag): 423 java.lang.String __elabel = _is.read_atom(); // Enumerant or Boolean 424 os.write_atom(__elabel); 425 426 for (int i=0; i<__mlen; i++) { 427 java.lang.String __mlabel; 428 if (_tc.member_label(i).type().kind().value() == TCKind._tk_string) 429 __mlabel = _tc.member_label(i).extract_string(); 430 else // Default 431 __mlabel = _tc.member_label(i).extract_atom(); 432 433 if (__elabel.compareTo(__mlabel)==0) { 434 read_user_defined(_is,_tc.member_type(i)); 435 i = __mlen; 436 __found = true; 437 } 438 } 439 break; 440 441 default: // Integer type 442 long __ilabel = _is.read_long(); 443 os.write_long(__ilabel); 444 445 for (int i=0; i<__mlen; i++) { 446 boolean __itype = true; 447 long __mlabel = 0; 448 449 switch (_tc.member_label(i).type().kind().value()) { 450 451 case TCKind._tk_short : 452 __mlabel = _tc.member_label(i).extract_short(); 453 break; 454 case TCKind._tk_ushort : 455 __mlabel = _tc.member_label(i).extract_ushort(); 456 break; 457 case TCKind._tk_long : 458 __mlabel = _tc.member_label(i).extract_long(); 459 break; 460 case TCKind._tk_longlong : 461 __mlabel = _tc.member_label(i).extract_longlong(); 462 break; 463 case TCKind._tk_ulong : 464 __mlabel = _tc.member_label(i).extract_ulong(); 465 break; 466 case TCKind._tk_ulonglong : 467 __mlabel = _tc.member_label(i).extract_ulonglong(); 468 break; 469 case TCKind._tk_char : 470 __mlabel = _tc.member_label(i).extract_char(); 471 break; 472 case TCKind._tk_wchar : 473 __mlabel = _tc.member_label(i).extract_wchar(); 474 break; 475 476 default : // Default label 477 __itype = false; 478 479 } 480 481 if (__itype) { 482 if (__ilabel == __mlabel) { 483 read_user_defined(_is,_tc.member_type(i)); 484 i = __mlen; 485 __found = true; 486 } 487 } 488 } 489 } 490 491 // Use the default label instead 492 if (!__found) 493 read_user_defined(_is,_tc.member_type(_tc.default_index())); 494 495 break; 496 497 case TCKind._tk_sequence: 498 __tag = _is.peek(); 499 500 switch(__tag) { 501 case com.ericsson.otp.erlang.OtpExternal.stringTag: 502 os.write_string(_is.read_string()); 503 break; 504 default: 505 len = _is.read_list_head(); 506 os.write_list_head(len); 507 508 for (int i=0; i<len; i++) 509 read_user_defined(_is,_tc.content_type()); 510 511 _is.read_nil(); 512 os.write_nil(); 513 } 514 break; 515 516 case TCKind._tk_array: 517 len = _is.read_tuple_head(); 518 os.write_tuple_head(len); 519 for (int i=0; i<len; i++) 520 read_user_defined(_is,_tc.content_type()); 521 break; 522 523 case TCKind._tk_enum: 524 os.write_atom(_is.read_atom()); 525 break; 526 527 case TCKind._tk_void : 528 os.write_atom(_is.read_atom()); 529 break; 530 531 case TCKind._tk_any : 532 AnyHelper.marshal(os,AnyHelper.unmarshal(_is)); 533 break; 534 535 /* 536 * Not supported types 537 */ 538 default : 539 throw new java.lang.Exception(""); 540 541 } 542 543 } 544 545 546 /** 547 Writes the Any's value to the ouput stream 548 **/ write_value(com.ericsson.otp.erlang.OtpOutputStream _os)549 public void write_value(com.ericsson.otp.erlang.OtpOutputStream _os) 550 throws java.lang.Exception { 551 552 switch(tcV.kind().value()) { 553 554 case TCKind._tk_short : 555 _os.write_short(shortV); 556 break; 557 case TCKind._tk_ushort : 558 _os.write_ushort(shortV); 559 break; 560 case TCKind._tk_long : 561 _os.write_int(intV); 562 break; 563 case TCKind._tk_ulong : 564 _os.write_uint(intV); 565 break; 566 case TCKind._tk_longlong : 567 _os.write_long(longV); 568 break; 569 case TCKind._tk_ulonglong : 570 _os.write_ulong(longV); 571 break; 572 case TCKind._tk_float : 573 _os.write_float(floatV); 574 break; 575 case TCKind._tk_double : 576 _os.write_double(doubleV); 577 break; 578 case TCKind._tk_boolean : 579 _os.write_boolean(booleanV); 580 break; 581 case TCKind._tk_char : 582 case TCKind._tk_wchar : 583 _os.write_char(charV); 584 break; 585 case TCKind._tk_octet : 586 _os.write_byte(byteV); 587 break; 588 case TCKind._tk_string : 589 case TCKind._tk_wstring : 590 _os.write_string(stringV); 591 break; 592 case TCKind._tk_atom : 593 _os.write_atom(stringV); 594 break; 595 case TCKind._tk_void : 596 _os.write_atom("ok"); 597 break; 598 599 /* 600 * Not supported types 601 */ 602 case TCKind._tk_any : 603 case TCKind._tk_null : 604 case TCKind._tk_TypeCode : 605 case TCKind._tk_Principal : 606 case TCKind._tk_objref : 607 case TCKind._tk_alias : 608 case TCKind._tk_except : 609 case TCKind._tk_longdouble : 610 case TCKind._tk_fixed : 611 throw new java.lang.Exception("BAD KIND"); 612 613 default: 614 _os.write(os.toByteArray()); 615 } 616 } 617 618 619 /* 620 * Insert and extract each primitive type 621 */ 622 623 /* short */ 624 625 /** 626 Short value extractor method 627 @return short, the value of Any 628 **/ extract_short()629 public short extract_short() 630 throws java.lang.Exception { 631 if (tcV.kind() == TCKind.tk_short) 632 return shortV; 633 634 throw new java.lang.Exception(""); 635 } 636 637 /** 638 Short value insertion method 639 **/ insert_short(short s)640 public void insert_short(short s) { 641 shortV = s; 642 tcV = new TypeCode(TCKind.tk_short); 643 }; 644 645 646 /* long */ 647 /** 648 Long value extractor method 649 @return int, the value of Any 650 **/ extract_long()651 public int extract_long() 652 throws java.lang.Exception { 653 if (tcV.kind() == TCKind.tk_long) 654 return intV; 655 656 throw new java.lang.Exception(""); 657 } 658 659 /** 660 Long value insertion method 661 **/ insert_long(int i)662 public void insert_long(int i){ 663 intV = i; 664 tcV = new TypeCode(TCKind.tk_long); 665 } 666 667 668 669 /* long long */ 670 /** 671 Long Long value extractor method 672 @return long, the value of Any 673 **/ extract_longlong()674 public long extract_longlong() 675 throws java.lang.Exception { 676 if (tcV.kind() == TCKind.tk_longlong) 677 return longV; 678 679 throw new java.lang.Exception(""); 680 } 681 682 /** 683 Long Long value insertion method 684 **/ insert_longlong(long l)685 public void insert_longlong(long l){ 686 longV = l; 687 tcV = new TypeCode(TCKind.tk_longlong); 688 } 689 690 691 /* ushort */ 692 /** 693 Unsigned Short value extractor method 694 @return short, the value of Any 695 **/ extract_ushort()696 public short extract_ushort() 697 throws java.lang.Exception { 698 if (tcV.kind() == TCKind.tk_ushort) 699 return shortV; 700 701 throw new java.lang.Exception(""); 702 } 703 704 /** 705 Unsigned Short value insertion method 706 **/ insert_ushort(short s)707 public void insert_ushort(short s){ 708 shortV = s; 709 tcV = new TypeCode(TCKind.tk_ushort); 710 } 711 712 713 /* ulong */ 714 715 /** 716 Unsigned Long value extractor method 717 @return int, the value of Any 718 **/ extract_ulong()719 public int extract_ulong() 720 throws java.lang.Exception{ 721 if (tcV.kind() == TCKind.tk_ulong) 722 return intV; 723 724 throw new java.lang.Exception(""); 725 } 726 727 /** 728 Unsigned Long value insertion method 729 **/ insert_ulong(int i)730 public void insert_ulong(int i){ 731 intV = i; 732 tcV = new TypeCode(TCKind.tk_ulong); 733 } 734 735 736 737 738 /* unsigned long long */ 739 /** 740 Unsigned Long Long value extractor method 741 @return long, the value of Any 742 **/ extract_ulonglong()743 public long extract_ulonglong() 744 throws java.lang.Exception { 745 if (tcV.kind() == TCKind.tk_ulonglong) 746 return longV; 747 748 throw new java.lang.Exception(""); 749 } 750 751 /** 752 Unsigned Long Long value insertion method 753 **/ insert_ulonglong(long l)754 public void insert_ulonglong(long l){ 755 longV = l; 756 tcV = new TypeCode(TCKind.tk_ulonglong); 757 } 758 759 760 /* float */ 761 /** 762 Float value extractor method 763 @return float, the value of Any 764 **/ extract_float()765 public float extract_float() 766 throws java.lang.Exception{ 767 if (tcV.kind() == TCKind.tk_float) 768 return floatV; 769 770 throw new java.lang.Exception(""); 771 } 772 773 /** 774 Float value insertion method 775 **/ insert_float(float f)776 public void insert_float(float f){ 777 floatV = f; 778 tcV = new TypeCode(TCKind.tk_float); 779 } 780 781 782 /* double */ 783 /** 784 Double value extractor method 785 @return double, the value of Any 786 **/ extract_double()787 public double extract_double() 788 throws java.lang.Exception{ 789 if (tcV.kind() == TCKind.tk_double) 790 return doubleV; 791 792 throw new java.lang.Exception(""); 793 } 794 795 /** 796 Double value insertion method 797 **/ insert_double(double d)798 public void insert_double(double d){ 799 doubleV = d; 800 tcV = new TypeCode(TCKind.tk_double); 801 } 802 803 804 /* boolean */ 805 /** 806 Boolean value extractor method 807 @return boolean, the value of Any 808 **/ extract_boolean()809 public boolean extract_boolean() 810 throws java.lang.Exception{ 811 if (tcV.kind() == TCKind.tk_boolean) 812 return booleanV; 813 814 throw new java.lang.Exception(""); 815 } 816 817 /** 818 Boolean value insertion method 819 **/ insert_boolean(boolean b)820 public void insert_boolean(boolean b){ 821 booleanV = b; 822 tcV = new TypeCode(TCKind.tk_boolean); 823 } 824 825 826 827 /* char */ 828 /** 829 Char value extractor method 830 @return char, the value of Any 831 **/ extract_char()832 public char extract_char() 833 throws java.lang.Exception{ 834 if (tcV.kind() == TCKind.tk_char) 835 return charV; 836 837 throw new java.lang.Exception(""); 838 } 839 840 /** 841 Char value insertion method 842 **/ insert_char(char c)843 public void insert_char(char c) { 844 charV = c; 845 tcV = new TypeCode(TCKind.tk_char); 846 } 847 848 849 /* wchar */ 850 /** 851 Wchar value extractor method 852 @return char, the value of Any 853 **/ extract_wchar()854 public char extract_wchar() 855 throws java.lang.Exception{ 856 if (tcV.kind() == TCKind.tk_wchar) 857 return charV; 858 859 throw new java.lang.Exception(""); 860 } 861 862 /** 863 Wchar value insertion method 864 **/ insert_wchar(char c)865 public void insert_wchar(char c) { 866 charV = c; 867 tcV = new TypeCode(TCKind.tk_wchar); 868 } 869 870 871 872 /* octet */ 873 /** 874 Octet value extractor method 875 @return byte, the value of Any 876 **/ extract_octet()877 public byte extract_octet() 878 throws java.lang.Exception{ 879 if (tcV.kind() == TCKind.tk_octet) 880 return byteV; 881 882 throw new java.lang.Exception(""); 883 } 884 885 /** 886 Octet value insertion method 887 **/ insert_octet(byte b)888 public void insert_octet(byte b){ 889 byteV = b; 890 tcV = new TypeCode(TCKind.tk_octet); 891 } 892 893 894 /* string */ 895 /** 896 String value extractor method 897 @return String, the value of Any 898 **/ extract_string()899 public java.lang.String extract_string() 900 throws java.lang.Exception{ 901 if (tcV.kind() == TCKind.tk_string) 902 return stringV; 903 904 throw new java.lang.Exception(""); 905 } 906 907 /** 908 String value insertion method 909 **/ insert_string(java.lang.String s)910 public void insert_string(java.lang.String s) { 911 stringV = s; 912 tcV = new TypeCode(TCKind.tk_string); 913 } 914 915 916 917 /* wstring */ 918 /** 919 Wstring value extractor method 920 @return String, the value of Any 921 **/ extract_wstring()922 public java.lang.String extract_wstring() 923 throws java.lang.Exception{ 924 if (tcV.kind() == TCKind.tk_wstring) 925 return stringV; 926 927 throw new java.lang.Exception(""); 928 } 929 930 /** 931 Wstring value insertion method 932 **/ insert_wstring(java.lang.String s)933 public void insert_wstring(java.lang.String s) { 934 stringV = s; 935 tcV = new TypeCode(TCKind.tk_wstring); 936 } 937 938 939 940 /* atom */ 941 /** 942 Atom value extractor method 943 @return atom, the value of Any 944 **/ extract_atom()945 public java.lang.String extract_atom() 946 throws java.lang.Exception{ 947 if (tcV.kind() == TCKind.tk_atom) 948 return stringV; 949 950 throw new java.lang.Exception(""); 951 } 952 953 /** 954 Atom value insertion method 955 **/ insert_atom(java.lang.String s)956 public void insert_atom(java.lang.String s) { 957 stringV = s; 958 tcV = new TypeCode(TCKind.tk_atom); 959 } 960 961 962 /** 963 Object Stream insertion method 964 **/ insert_Streamable(com.ericsson.otp.erlang.OtpOutputStream _os)965 public void insert_Streamable(com.ericsson.otp.erlang.OtpOutputStream _os) { 966 os = _os; 967 } 968 969 /** 970 Object Stream extractor method 971 @return OtpInputStream, the stream value of Any 972 **/ extract_Streamable()973 public com.ericsson.otp.erlang.OtpInputStream extract_Streamable() { 974 975 if (is == null) { 976 if (os == null) 977 return null; 978 else { 979 is = new com.ericsson.otp.erlang.OtpInputStream(os.toByteArray()); 980 } 981 } 982 983 is.reset(); 984 return is; 985 } 986 987 } 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027