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;

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



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

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

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

	static {
		_type = _orb.create_interface_tc(_id,"Resource");
	}

	public static Resource read(InputStream istream) {
		return narrow(istream.read_Object());
	}

	public static void write(OutputStream ostream, Resource value) {
		ostream.write_Object(value);
	}

	public static Resource narrow(org.omg.CORBA.Object obj) {
		if (obj == null || obj instanceof Resource) {
			return (Resource) obj;
		} else {
			if (obj._is_a(_id)) {
				Delegate d = ((ObjectImpl) obj)._get_delegate();
				ObjectImpl o = new org.omg.CosTransactions._ResourceStub();
				o._set_delegate(d);
				return (Resource) o;
			} else {
				throw new org.omg.CORBA.BAD_PARAM();
			}
		}
	}
	public static TypeCode type() {
		return _type;
	}

}
