package org.omg.CosTransactions;

import org.omg.CORBA.Any;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.ORB;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.ObjectImpl;

/**
 * PropagationContextHelper Class generated by the Idl2Java Compiler 3.1 of Jonathan
 */



public class PropagationContextHelper {
	static ORB _orb = ORB.init();
	static TypeCode _type;
	public static String _id = "IDL:omg.org/CosTransactions/PropagationContext:1.0";
	public static String id() {
		return _id;
	}

	public static void insert(Any a,org.omg.CosTransactions.PropagationContext t) {
		a.type(_type);
		write(a.create_output_stream(),t);
	}

	public static org.omg.CosTransactions.PropagationContext extract(Any a) {
		return read(a.create_input_stream());
	}

	static {
		_type = _orb.create_recursive_tc(_id);
		int _nbMemb = 4;
		StructMember[] members = new StructMember[_nbMemb];
		members[0] = new StructMember();
		members[0].name = "timeout";
		members[0].type = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_ulong);
		members[1] = new StructMember();
		members[1].name = "current";
		members[1].type = org.omg.CosTransactions.TransIdentityHelper.type();
		members[2] = new StructMember();
		members[2].name = "parents";
		members[2].type = _orb.create_sequence_tc(0,org.omg.CosTransactions.TransIdentityHelper.type());
		members[3] = new StructMember();
		members[3].name = "implementation_specific_data";
		members[3].type = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_any);
		_type = _orb.create_struct_tc(_id,"PropagationContext",members);
	}
	public static PropagationContext read(InputStream istream) {
		org.omg.CosTransactions.PropagationContext _result = new org.omg.CosTransactions.PropagationContext();
		_result.timeout =  istream.read_ulong();
		_result.current =  org.omg.CosTransactions.TransIdentityHelper.read(istream);
		int _vSize2=istream.read_ulong();
		_result.parents=new org.omg.CosTransactions.TransIdentity[_vSize2];
		for(int _i2=0;_i2<_vSize2;_i2++) {
			_result.parents[_i2] =  org.omg.CosTransactions.TransIdentityHelper.read(istream);
		}
		_result.implementation_specific_data =  istream.read_any();
		return _result;
	}

	public static void write(OutputStream ostream, PropagationContext value) {
		ostream.write_ulong(value.timeout);
		org.omg.CosTransactions.TransIdentityHelper.write(ostream,value.current);
		int _vSize3=value.parents.length;
		ostream.write_ulong(_vSize3);
		for(int _i3=0;_i3<_vSize3;_i3++) {
			org.omg.CosTransactions.TransIdentityHelper.write(ostream,value.parents[_i3]);
		}
		ostream.write_any(value.implementation_specific_data);
	}

	public static TypeCode type() {
		return _type;
	}

}
