package com.chirpit;


/**
* com/chirpit/LocationHelper.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from ../idl/chirpit.idl
* Wednesday, October 8, 2014 5:01:55 AM CEST
*/

abstract public class LocationHelper
{
  private static String  _id = "IDL:com/chirpit/Location:1.0";

  public static void insert (org.omg.CORBA.Any a, com.chirpit.Location that)
  {
    org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
    a.type (type ());
    write (out, that);
    a.read_value (out.create_input_stream (), type ());
  }

  public static com.chirpit.Location extract (org.omg.CORBA.Any a)
  {
    return read (a.create_input_stream ());
  }

  private static org.omg.CORBA.TypeCode __typeCode = null;
  synchronized public static org.omg.CORBA.TypeCode type ()
  {
    if (__typeCode == null)
    {
      org.omg.CORBA.TypeCode _disTypeCode0;
      _disTypeCode0 = com.chirpit.LocationKindHelper.type ();
      org.omg.CORBA.UnionMember[] _members0 = new org.omg.CORBA.UnionMember [2];
      org.omg.CORBA.TypeCode _tcOf_members0;
      org.omg.CORBA.Any _anyOf_members0;

      // Branch for location (case label SOME_LOCATION_KIND)
      _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
      com.chirpit.LocationKindHelper.insert (_anyOf_members0, com.chirpit.LocationKind.SOME_LOCATION_KIND);
      _tcOf_members0 = com.chirpit.SomeLocationHelper.type ();
      _members0[0] = new org.omg.CORBA.UnionMember (
        "location",
        _anyOf_members0,
        _tcOf_members0,
        null);

      // Branch for none (case label NONE_KIND)
      _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
      com.chirpit.LocationKindHelper.insert (_anyOf_members0, com.chirpit.LocationKind.NONE_KIND);
      _tcOf_members0 = com.chirpit.NoneHelper.type ();
      _members0[1] = new org.omg.CORBA.UnionMember (
        "none",
        _anyOf_members0,
        _tcOf_members0,
        null);
      __typeCode = org.omg.CORBA.ORB.init ().create_union_tc (com.chirpit.LocationHelper.id (), "Location", _disTypeCode0, _members0);
    }
    return __typeCode;
  }

  public static String id ()
  {
    return _id;
  }

  public static com.chirpit.Location read (org.omg.CORBA.portable.InputStream istream)
  {
    com.chirpit.Location value = new com.chirpit.Location ();
    com.chirpit.LocationKind _dis0 = null;
    _dis0 = com.chirpit.LocationKindHelper.read (istream);
    switch (_dis0.value ())
    {
      case com.chirpit.LocationKind._SOME_LOCATION_KIND:
        com.chirpit.SomeLocation _location = null;
        _location = com.chirpit.SomeLocationHelper.read (istream);
        value.location (_location);
        break;
      case com.chirpit.LocationKind._NONE_KIND:
        com.chirpit.None _none = null;
        _none = com.chirpit.NoneHelper.read (istream);
        value.none (_none);
        break;
    }
    return value;
  }

  public static void write (org.omg.CORBA.portable.OutputStream ostream, com.chirpit.Location value)
  {
    com.chirpit.LocationKindHelper.write (ostream, value.discriminator ());
    switch (value.discriminator ().value ())
    {
      case com.chirpit.LocationKind._SOME_LOCATION_KIND:
        com.chirpit.SomeLocationHelper.write (ostream, value.location ());
        break;
      case com.chirpit.LocationKind._NONE_KIND:
        com.chirpit.NoneHelper.write (ostream, value.none ());
        break;
    }
  }

}
