tests/libjava-mauve/src/gnu/testlet/org/omg/CORBA/ORB/RF11/E_unionHelper.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Tags: not-a-test
       
     2 // Copyright (c) 2000, 2001 NEC Corporation.
       
     3 
       
     4 // Adapted for Mauve by Audrius Meskauskas <audriusa@bluewin.ch>
       
     5 
       
     6 // This file is part of Mauve.
       
     7 
       
     8 // Mauve is free software; you can redistribute it and/or modify
       
     9 // it under the terms of the GNU General Public License as published by
       
    10 // the Free Software Foundation; either version 2, or (at your option)
       
    11 // any later version.
       
    12 
       
    13 // Mauve is distributed in the hope that it will be useful,
       
    14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    16 // GNU General Public License for more details.
       
    17 
       
    18 // You should have received a copy of the GNU General Public License
       
    19 // along with Mauve; see the file COPYING.  If not, write to
       
    20 // the Free Software Foundation, 59 Temple Place - Suite 330,
       
    21 // Boston, MA 02111-1307, USA.
       
    22 
       
    23 /*
       
    24 This code originally came from the OMG's CORBA Open Source Testing project,
       
    25 which lived at cost.omg.org. That site no longer exists.
       
    26 
       
    27 All the contributing companies agreed to release their tests under the
       
    28 terms of the GNU Lesser General Public License, available in the file
       
    29 COPYING.LIB.
       
    30 
       
    31 The code has been modified integrating into Mauve test environment and
       
    32 removing tests that are not yet supported by Suns jre 1.4. Hence the license
       
    33 is now GPL.
       
    34 
       
    35 We downloaded the code from http://sourceforge.net/projects/corba-cost/,
       
    36 administrated by Duncan Grisby.
       
    37 */
       
    38 
       
    39 package gnu.testlet.org.omg.CORBA.ORB.RF11;
       
    40 
       
    41 public abstract class E_unionHelper
       
    42 {
       
    43   private static String _id = "IDL:gnu/testlet/org/omg/CORBA/ORB/RF11/E_union:1.0";
       
    44 
       
    45   public static void insert(org.omg.CORBA.Any a, E_union that)
       
    46   {
       
    47     org.omg.CORBA.portable.OutputStream out = a.create_output_stream();
       
    48     a.type(type());
       
    49     write(out, that);
       
    50     a.read_value(out.create_input_stream(), type());
       
    51   }
       
    52 
       
    53   public static E_union extract(org.omg.CORBA.Any a)
       
    54   {
       
    55     return read(a.create_input_stream());
       
    56   }
       
    57 
       
    58   private static org.omg.CORBA.TypeCode __typeCode = null;
       
    59 
       
    60   public static synchronized org.omg.CORBA.TypeCode type()
       
    61   {
       
    62     if (__typeCode == null)
       
    63       {
       
    64         org.omg.CORBA.TypeCode _disTypeCode0;
       
    65         _disTypeCode0 =
       
    66           org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
       
    67 
       
    68         org.omg.CORBA.UnionMember[] _members0 =
       
    69           new org.omg.CORBA.UnionMember[ 2 ];
       
    70         org.omg.CORBA.TypeCode _tcOf_members0;
       
    71         org.omg.CORBA.Any _anyOf_members0;
       
    72 
       
    73         // Branch for e_b1
       
    74         _anyOf_members0 = org.omg.CORBA.ORB.init().create_any();
       
    75         _anyOf_members0.insert_long((int) 1);
       
    76         _tcOf_members0 = BHelper.type();
       
    77         _members0 [ 0 ] =
       
    78           new org.omg.CORBA.UnionMember("e_b1", _anyOf_members0,
       
    79                                         _tcOf_members0, null
       
    80                                        );
       
    81 
       
    82         // Branch for e_b2
       
    83         _anyOf_members0 = org.omg.CORBA.ORB.init().create_any();
       
    84         _anyOf_members0.insert_long((int) 2);
       
    85         _tcOf_members0 = BHelper.type();
       
    86         _members0 [ 1 ] =
       
    87           new org.omg.CORBA.UnionMember("e_b2", _anyOf_members0,
       
    88                                         _tcOf_members0, null
       
    89                                        );
       
    90         __typeCode =
       
    91           org.omg.CORBA.ORB.init().create_union_tc(E_unionHelper.id(),
       
    92                                                    "E_union", _disTypeCode0,
       
    93                                                    _members0
       
    94                                                   );
       
    95       }
       
    96     return __typeCode;
       
    97   }
       
    98 
       
    99   public static String id()
       
   100   {
       
   101     return _id;
       
   102   }
       
   103 
       
   104   public static E_union read(org.omg.CORBA.portable.InputStream istream)
       
   105   {
       
   106     E_union value = new E_union();
       
   107     int _dis0 = (int) 0;
       
   108     _dis0 = istream.read_long();
       
   109     switch (_dis0)
       
   110       {
       
   111         case 1 :
       
   112 
       
   113           B _e_b1 = null;
       
   114           _e_b1 = BHelper.read(istream);
       
   115           value.e_b1(_e_b1);
       
   116           break;
       
   117 
       
   118         case 2 :
       
   119 
       
   120           B _e_b2 = null;
       
   121           _e_b2 = BHelper.read(istream);
       
   122           value.e_b2(_e_b2);
       
   123           break;
       
   124 
       
   125         default :
       
   126           throw new org.omg.CORBA.BAD_OPERATION();
       
   127       }
       
   128     return value;
       
   129   }
       
   130 
       
   131   public static void write(org.omg.CORBA.portable.OutputStream ostream,
       
   132                            E_union value
       
   133                           )
       
   134   {
       
   135     ostream.write_long(value.discriminator());
       
   136     switch (value.discriminator())
       
   137       {
       
   138         case 1 :
       
   139           BHelper.write(ostream, value.e_b1());
       
   140           break;
       
   141 
       
   142         case 2 :
       
   143           BHelper.write(ostream, value.e_b2());
       
   144           break;
       
   145 
       
   146         default :
       
   147           throw new org.omg.CORBA.BAD_OPERATION();
       
   148       }
       
   149   }
       
   150 }