package nsdb.LocationPackage;


/**
* nsdb/LocationPackage/LocationNode_uHelper.java .
* Generated by the IDL-to-Java compiler (portable), version "3.1"
* from corba/nsdb.idl
* Friday, February 25, 2005 10:35:44 AM GMT
*/

abstract public class LocationNode_uHelper
{
  private static String  _id = "IDL:nsdb/Location/LocationNode_u:1.0";

  public static void insert (org.omg.CORBA.Any a, nsdb.LocationPackage.LocationNode_u 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 nsdb.LocationPackage.LocationNode_u 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 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long);
      _disTypeCode0 = org.omg.CORBA.ORB.init ().create_alias_tc (nsdb.LocationPackage.LocNodeTypeCodeHelper.id (), "LocNodeTypeCode", _disTypeCode0);
      org.omg.CORBA.UnionMember[] _members0 = new org.omg.CORBA.UnionMember [4];
      org.omg.CORBA.TypeCode _tcOf_members0;
      org.omg.CORBA.Any _anyOf_members0;

      // Branch for virtual (case label nsdb.Location.VirtualSegment_ltc)
      _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
      _anyOf_members0.insert_long ((int)nsdb.Location.VirtualSegment_ltc);
      _tcOf_members0 = nsdb.LocationPackage.LocVirtualSegmentHelper.type ();
      _members0[0] = new org.omg.CORBA.UnionMember (
        "virtual",
        _anyOf_members0,
        _tcOf_members0,
        null);

      // Branch for physical (case label nsdb.Location.PhysicalSegment_ltc)
      _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
      _anyOf_members0.insert_long ((int)nsdb.Location.PhysicalSegment_ltc);
      _tcOf_members0 = org.omg.CORBA.ORB.init ().create_string_tc (0);
      _tcOf_members0 = org.omg.CORBA.ORB.init ().create_alias_tc (nsdb.LocationPackage.LocPhysicalSegmentHelper.id (), "LocPhysicalSegment", _tcOf_members0);
      _members0[1] = new org.omg.CORBA.UnionMember (
        "physical",
        _anyOf_members0,
        _tcOf_members0,
        null);

      // Branch for gap (case label nsdb.Location.Gap_ltc)
      _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
      _anyOf_members0.insert_long ((int)nsdb.Location.Gap_ltc);
      _tcOf_members0 = type.FuzzyHelper.type ();
      _tcOf_members0 = org.omg.CORBA.ORB.init ().create_alias_tc (nsdb.LocationPackage.LocGapHelper.id (), "LocGap", _tcOf_members0);
      _members0[2] = new org.omg.CORBA.UnionMember (
        "gap",
        _anyOf_members0,
        _tcOf_members0,
        null);

      // Branch for operator (case label nsdb.Location.Operator_ltc)
      _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any ();
      _anyOf_members0.insert_long ((int)nsdb.Location.Operator_ltc);
      _tcOf_members0 = nsdb.LocationPackage.LocOperatorHelper.type ();
      _members0[3] = new org.omg.CORBA.UnionMember (
        "operator",
        _anyOf_members0,
        _tcOf_members0,
        null);
      __typeCode = org.omg.CORBA.ORB.init ().create_union_tc (nsdb.LocationPackage.LocationNode_uHelper.id (), "LocationNode_u", _disTypeCode0, _members0);
    }
    return __typeCode;
  }

  public static String id ()
  {
    return _id;
  }

  public static nsdb.LocationPackage.LocationNode_u read (org.omg.CORBA.portable.InputStream istream)
  {
    nsdb.LocationPackage.LocationNode_u value = new nsdb.LocationPackage.LocationNode_u ();
    int _dis0 = (int)0;
    _dis0 = istream.read_long ();
    switch (_dis0)
    {
      case nsdb.Location.VirtualSegment_ltc:
        nsdb.LocationPackage.LocVirtualSegment _virtual = null;
        _virtual = nsdb.LocationPackage.LocVirtualSegmentHelper.read (istream);
        value.virtual (_virtual);
        break;
      case nsdb.Location.PhysicalSegment_ltc:
        String _physical = null;
        _physical = nsdb.LocationPackage.LocPhysicalSegmentHelper.read (istream);
        value.physical (_physical);
        break;
      case nsdb.Location.Gap_ltc:
        type.Fuzzy _gap = null;
        _gap = nsdb.LocationPackage.LocGapHelper.read (istream);
        value.gap (_gap);
        break;
      case nsdb.Location.Operator_ltc:
        nsdb.LocationPackage.LocOperator __operator = null;
        __operator = nsdb.LocationPackage.LocOperatorHelper.read (istream);
        value._operator (__operator);
        break;
      default:
        value._default( _dis0 ) ;
        break;
    }
    return value;
  }

  public static void write (org.omg.CORBA.portable.OutputStream ostream, nsdb.LocationPackage.LocationNode_u value)
  {
    ostream.write_long (value.discriminator ());
    switch (value.discriminator ())
    {
      case nsdb.Location.VirtualSegment_ltc:
        nsdb.LocationPackage.LocVirtualSegmentHelper.write (ostream, value.virtual ());
        break;
      case nsdb.Location.PhysicalSegment_ltc:
        nsdb.LocationPackage.LocPhysicalSegmentHelper.write (ostream, value.physical ());
        break;
      case nsdb.Location.Gap_ltc:
        nsdb.LocationPackage.LocGapHelper.write (ostream, value.gap ());
        break;
      case nsdb.Location.Operator_ltc:
        nsdb.LocationPackage.LocOperatorHelper.write (ostream, value._operator ());
        break;
    }
  }

}
