package test.interop.wchar_tao_interop.GoodDayPackage;


/**
 * Generated from IDL exception "WStringException".
 *
 * @author JacORB IDL compiler V @project.version@
 * @version generated at 25-Feb-2014 13:44:21
 */

public abstract class WStringExceptionHelper
{
	private volatile static org.omg.CORBA.TypeCode _type;
	public static org.omg.CORBA.TypeCode type ()
	{
		if (_type == null)
		{
			synchronized(WStringExceptionHelper.class)
			{
				if (_type == null)
				{
					_type = org.omg.CORBA.ORB.init().create_exception_tc(test.interop.wchar_tao_interop.GoodDayPackage.WStringExceptionHelper.id(),"WStringException",new org.omg.CORBA.StructMember[]{new org.omg.CORBA.StructMember("why", org.omg.CORBA.ORB.init().create_wstring_tc(0), null)});
				}
			}
		}
		return _type;
	}

	public static void insert (final org.omg.CORBA.Any any, final test.interop.wchar_tao_interop.GoodDayPackage.WStringException s)
	{
		any.type(type());
		write( any.create_output_stream(),s);
	}

	public static test.interop.wchar_tao_interop.GoodDayPackage.WStringException extract (final org.omg.CORBA.Any any)
	{
		org.omg.CORBA.portable.InputStream in = any.create_input_stream();
		try
		{
			return read (in);
		}
		finally
		{
			try
			{
				in.close();
			}
			catch (java.io.IOException e)
			{
			throw new RuntimeException("Unexpected exception " + e.toString() );
			}
		}
	}

	public static String id()
	{
		return "IDL:test/interop/wchar_tao_interop/GoodDay/WStringException:1.0";
	}
	public static test.interop.wchar_tao_interop.GoodDayPackage.WStringException read (final org.omg.CORBA.portable.InputStream in)
	{
		String id = in.read_string();
		if (!id.equals(id())) throw new org.omg.CORBA.MARSHAL("wrong id: " + id);
		if (in instanceof org.jacorb.orb.giop.ReplyInputStream)
		{
			org.jacorb.orb.giop.ReplyInputStream reply = (org.jacorb.orb.giop.ReplyInputStream) in;
			org.omg.IOP.ServiceContext context = null;
			if ( (context = reply.getServiceContext(org.omg.IOP.ExceptionDetailMessage.value)) != null)
			{
				org.jacorb.orb.CDRInputStream details = new org.jacorb.orb.CDRInputStream(context.context_data);
				details.openEncapsulatedArray();
				id = details.read_wstring();
			}
		}
		java.lang.String x0;
		x0=in.read_wstring();
		final test.interop.wchar_tao_interop.GoodDayPackage.WStringException result = new test.interop.wchar_tao_interop.GoodDayPackage.WStringException(id, x0);
		return result;
	}
	public static void write (final org.omg.CORBA.portable.OutputStream out, final test.interop.wchar_tao_interop.GoodDayPackage.WStringException s)
	{
		out.write_string(id());
		java.lang.String tmpResult3 = s.why;
out.write_wstring( tmpResult3 );
	}
}
