}
case TCKind._tk_float: // 6
// fallthrough
case TCKind._tk_double: // 7
{
throw new MARSHAL(
"Invalid union discriminator type: " + disc);
}
case TCKind._tk_boolean: // 8
{
boolean s = input.read_boolean();
write_boolean(s);
for(int i = 0 ; i < typeCode.member_count() ; i++)
{
if(i != def_idx)
{
if(s == typeCode.member_label(i).extract_boolean())
{
member_idx = i;
break;
}
}
}
break;
}
case TCKind._tk_char: // 9
{
char s = input.read_char();
write_char(s);
for(int i = 0 ; i < typeCode.member_count() ; i++)
{
if(i != def_idx)
{
if(s == typeCode.member_label(i).extract_char())
{
member_idx = i;
break;
}
}
}
break;
}
case TCKind._tk_octet: // 10
case TCKind._tk_any: // 11
case TCKind._tk_TypeCode: // 12
case TCKind._tk_Principal: // 13
case TCKind._tk_objref: // 14
case TCKind._tk_struct: // 15
case TCKind._tk_union: // 16
{
throw new MARSHAL(
"Invalid union discriminator type: " + disc);
}
case TCKind._tk_enum: // 17
{
int s = input.read_long();
write_long(s);
for( int i = 0 ; i < typeCode.member_count(); i++ )
{
if( i != def_idx)
{
int label =
typeCode.member_label(i).create_input_stream().read_long();
/* we have to use the any's input
stream because enums are not
inserted as longs */
if( s == label)
{
member_idx = i;
break;
}
}
}
break;
}
case TCKind._tk_string: // 18
case TCKind._tk_sequence: // 19
case TCKind._tk_array: // 20
case TCKind._tk_alias: // 21
case TCKind._tk_except: // 22
{
throw new MARSHAL(
"Invalid union discriminator type: " + disc);
}
case TCKind._tk_longlong: // 23
{
long s = input.read_longlong();
write_longlong(s);
for(int i = 0 ; i < typeCode.member_count() ; i++)
{
if(i != def_idx)
{
if(s == typeCode.member_label(i).extract_longlong())
{
member_idx = i;
break;
}
}
}
break;
}
case TCKind._tk_ulonglong: // 24
{
long s = input.read_ulonglong();
write_ulonglong(s);
for(int i = 0 ; i < typeCode.member_count() ; i++)
{
if(i != def_idx)
{
if(s == typeCode.member_label(i).extract_ulonglong())
{
member_idx = i;
break;
}
}
}
break;
}
default:
{
throw new MARSHAL("Invalid union discriminator type: " + disc);
}
}
// write the member or default value, if any
// (if the union has no explicit default but the
// the case labels do not cover the range of
// possible discriminator values, there may be
// several "implicit defaults" without associated
// union values.
if( member_idx != -1 )
{
write_value( typeCode.member_type( member_idx ), input );
}
else if( def_idx != -1 )
{
write_value( typeCode.member_type( def_idx ), input );
}
break;
}
case TCKind._tk_enum: // 17
{
write_long( input.read_long() );
break;
}
case TCKind._tk_string: // 18
{
write_string( input.read_string());
break;
}
case TCKind._tk_sequence: // 19
{
int len = input.read_long();
write_long(len);
org.omg.CORBA.TypeCode content_tc = typeCode.content_type();
for( int i = 0; i < len; i++ )
{
write_value(content_tc, input);
}
break;
}
case TCKind._tk_array: // 20
{
int length = typeCode.length();
if( typeCode.content_type().kind().value() == TCKind._tk_octet )
{
check( length );
input.read_octet_array( buffer, pos, length);
index+= length;
pos += length;
}
else
{
for( int i = 0; i < length; i++ )
{
write_value( typeCode.content_type(), input );
}
}
break;
}
case TCKind._tk_alias: // 21
{
write_value( typeCode.content_type(), input );
break;
}
case TCKind._tk_except: // 22
{
write_string( input.read_string());
for (int i = 0; i < typeCode.member_count(); i++)
{
write_value(typeCode.member_type(i), input);
}
break;
}
case TCKind._tk_longlong: // 23
{
write_longlong(input.read_longlong());
break;
}
case TCKind._tk_ulonglong: // 24
{
write_ulonglong( input.read_ulonglong());
break;
}
case TCKind._tk_longdouble: // 25
{
throw new org.omg.CORBA.BAD_TYPECODE(
"type longdouble not supported in java");
}
case TCKind._tk_wchar: // 26
{
write_wchar( input.read_wchar());
break;
}
case TCKind._tk_wstring: // 27
{
write_wstring( input.read_wstring());
break;
}
case TCKind._tk_fixed: // 28
{
final short digits = typeCode.fixed_digits();
final short scale = typeCode.fixed_scale();
final BigDecimal value;
if (input instanceof CDRInputStream)
{
value = ((CDRInputStream)input).read_fixed(digits, scale);
}
else
{
// TODO can we remove this? mixed usage orb classes from different vendors ...
value = input.read_fixed();
}
write_fixed(value, digits, scale);
break;
}
case TCKind._tk_value: // 29
{
final Serializable val = ((org.omg.CORBA_2_3.portable.InputStream)input).read_value();
write_value(val, typeCode.id());
break;
}
case TCKind._tk_value_box:
{
String id = typeCode.id();
org.omg.CORBA.portable.BoxedValueHelper helper =
((org.jacorb.orb.ORB)orb()).getBoxedValueHelper(id);
if (helper == null)
{
throw new MARSHAL("No BoxedValueHelper for id " + id);
}
java.io.Serializable value =
((org.omg.CORBA_2_3.portable.InputStream)input).read_value(helper);
write_value (value, helper);
break;
}
default:
{
throw new MARSHAL("Cannot handle TypeCode with kind " + kind);
}
}
}
catch (BadKind ex)
{
throw new MARSHAL
("When processing TypeCode with kind: " + kind + " caught " + ex);
}
catch (Bounds ex)
{
throw new MARSHAL
("When processing TypeCode with kind: " + kind + " caught " + ex);
}
}