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;

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



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

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

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

	static {
		_type = _orb.create_recursive_tc(_id);
		int _nbMemb = 3;
		StructMember[] members = new StructMember[_nbMemb];
		members[0] = new StructMember();
		members[0].name = "formatID";
		members[0].type = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
		members[1] = new StructMember();
		members[1].name = "bqual_length";
		members[1].type = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
		members[2] = new StructMember();
		members[2].name = "tid";
		members[2].type = _orb.create_sequence_tc(0,_orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_octet));
		_type = _orb.create_struct_tc(_id,"otid_t",members);
	}
	public static otid_t read(InputStream istream) {
		org.omg.CosTransactions.otid_t _result = new org.omg.CosTransactions.otid_t();
		_result.formatID =  istream.read_long();
		_result.bqual_length =  istream.read_long();
		int _vSize0 = istream.read_ulong();
		_result.tid = new byte[_vSize0];
		istream.read_octet_array(_result.tid,0,_vSize0);
		return _result;
	}

	public static void write(OutputStream ostream, otid_t value) {
		ostream.write_long(value.formatID);
		ostream.write_long(value.bqual_length);
		int _vSize1=value.tid.length;
		ostream.write_ulong(_vSize1);
		ostream.write_octet_array(value.tid,0,_vSize1);
	}

	public static TypeCode type() {
		return _type;
	}

}
