名前
org.omg.CORBA.Any.create_output_stream
形式
public org.omg.CORBA.portable.OutputStream boolean create_output_stream()
機能説明
Anyオブジェクトの出力ストリームを作成します。
復帰値
正常終了した場合は、作成されたOutputStreamオブジェクトを返します。
異常終了した場合は、以下の例外が発生します。
org.omg.CORBA.SystemException
システム例外発生時に設定された例外情報およびマイナーコードの意味については、“メッセージ集”の“CORBAサービスから通知される例外情報/マイナーコード”を参照してください。
IIOPサービス(Java EEクライアント)機能を使用している場合は、“メッセージ集”の“Java EE使用時に出力される例外情報”も合わせて参照してください。
注意事項
IIOPサービス(Java EEクライアント)機能を使用している場合、作成した出力ストリームに書き込んだデータをAny型に反映するには、org.omg.CORBA.Any.read_value()を使用する必要があります。
以下にコーディング例を記述します。
/* write_xxxの場合 */ org.omg.CORBA.ORB orb=org.omg.CORBA.ORB.init(); : org.omg.CORBA.Any any = orb.create_any(); org.omg.CORBA.portable.OutputStream os = any.create_output_stream(); char write_value = ‘a’; os.write_char(write_value); org.omg.CORBA.portable.InputStream is_tmp = os.create_input_stream(); any.read_value(is_tmp, orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_char)); org.omg.CORBA.portable.InputStream is = any.create_input_stream(); char result = is.read_char(); /* write_xxx_arrayの場合 */ org.omg.CORBA.ORB orb=org.omg.CORBA.ORB.init(); : org.omg.CORBA.Any any = orb.create_any(); org.omg.CORBA.portable.OutputStream os = any.create_output_stream(); char write_value[] = {‘a’, ‘b’, ‘c’, ‘d’, ‘e’}; int write_length = write_value.length; int offset = 0; os.write_long(write_length); os.write_char_array(write_value, offset, write_length); org.omg.CORBA.portable.InputStream is_tmp = os.create_input_stream(); any.read_value(is_tmp, orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_long)); org.omg.CORBA.TypeCode write_tc = orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_char); any.read_value(is_tmp, orb.create_array_tc(write_length, write_tc)); org.omg.CORBA.portable.InputStream is = any.create_input_stream(); int read_length = is.read_long(); char result[] = new char[read_length]; is.read_char_array(result, offset, read_length); |