use of org.omg.DynamicAny.DynEnum in project ACS by ACS-Community.
the class BACIIntrospector method displayAny.
public void displayAny(TypeCode tc, Any argument) {
if (argument == null)
throw new NullPointerException("argument");
switch(tc.kind().value()) {
case TCKind._tk_any:
displayAny(argument.extract_any());
break;
case TCKind._tk_void:
case TCKind._tk_null:
System.out.println("NULL!!!");
break;
case TCKind._tk_objref:
System.out.println(argument.extract_Object());
break;
case TCKind._tk_struct:
case TCKind._tk_except:
System.out.println("Struct!!!");
displayTypedef(tc, argument);
break;
case TCKind._tk_alias:
try {
displayAny(tc.content_type(), argument);
} catch (org.omg.CORBA.TypeCodePackage.BadKind e) {
e.printStackTrace();
}
break;
case TCKind._tk_enum:
DynEnum en;
try {
en = (DynEnum) ra.getDynFact().create_dyn_any(argument);
System.out.println(en.get_as_string());
} catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode e) {
e.printStackTrace();
}
break;
case TCKind._tk_sequence:
case TCKind._tk_array:
System.out.println("Sequence!!!");
displaySequence(tc, argument);
break;
case TCKind._tk_double:
System.out.println(new Double(argument.extract_double()));
break;
case TCKind._tk_float:
System.out.println(new Float(argument.extract_float()));
break;
case TCKind._tk_octet:
//return new Byte(argument.extract_octet());
// use short to get unsigned value
System.out.println(new Short((short) (argument.extract_octet() & 0xFF)));
break;
case TCKind._tk_longlong:
System.out.println(new Long(argument.extract_longlong()));
break;
case TCKind._tk_ulonglong:
System.out.println(new Long(argument.extract_ulonglong()));
break;
case TCKind._tk_long:
System.out.println(new Integer(argument.extract_long()));
break;
case TCKind._tk_ulong:
System.out.println(new Integer(argument.extract_ulong()));
break;
case TCKind._tk_short:
System.out.println(new Short(argument.extract_short()));
break;
case TCKind._tk_ushort:
System.out.println(new Short(argument.extract_ushort()));
break;
case TCKind._tk_string:
System.out.println(argument.extract_string());
break;
case TCKind._tk_char:
System.out.println(new Character(argument.extract_char()));
break;
case TCKind._tk_boolean:
System.out.println(new Boolean(argument.extract_boolean()));
break;
default:
throw new IllegalArgumentException("Argument typecode '" + argument.type().kind().value() + "' is not supported.");
}
}
use of org.omg.DynamicAny.DynEnum in project ACS by ACS-Community.
the class BACIIntrospector method extractAny.
/**
* Insert the method's description here.
* Creation date: (3.11.2000 0:38:21)
*/
public java.lang.Object extractAny(TypeCode tc, Any argument) {
if (argument == null)
throw new NullPointerException("argument");
if (tc == null)
throw new NullPointerException("tc");
switch(tc.kind().value()) {
case TCKind._tk_any:
return extractAny(argument.extract_any());
case TCKind._tk_void:
case TCKind._tk_null:
return null;
case TCKind._tk_objref:
return argument.extract_Object();
case TCKind._tk_struct:
case TCKind._tk_except:
return extractTypedef(argument);
case TCKind._tk_alias:
try {
return extractAny(tc.content_type(), argument);
} catch (org.omg.CORBA.TypeCodePackage.BadKind e) {
e.printStackTrace();
return null;
}
case TCKind._tk_enum:
DynEnum en;
try {
en = (DynEnum) ra.getDynFact().create_dyn_any(argument);
} catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode e) {
e.printStackTrace();
return null;
}
//return en.get_as_string();
DataEnum de = (DataEnum) getDef(tc);
de.set(en.get_as_ulong());
return de;
case TCKind._tk_sequence:
case TCKind._tk_array:
return extractSequence(tc, argument);
case TCKind._tk_double:
return new Double(argument.extract_double());
case TCKind._tk_float:
return new Float(argument.extract_float());
case TCKind._tk_octet:
// use short to get unsigned value
return new Short((short) (argument.extract_octet() & 0xFF));
case TCKind._tk_longlong:
return new Long(argument.extract_longlong());
case TCKind._tk_ulonglong:
return new Long(argument.extract_ulonglong());
case TCKind._tk_long:
return new Integer(argument.extract_long());
case TCKind._tk_ulong:
return new Integer(argument.extract_ulong());
case TCKind._tk_short:
return new Short(argument.extract_short());
case TCKind._tk_ushort:
return new Short(argument.extract_ushort());
case TCKind._tk_string:
return argument.extract_string();
case TCKind._tk_char:
return new Character(argument.extract_char());
case TCKind._tk_boolean:
return new Boolean(argument.extract_boolean());
default:
throw new IllegalArgumentException("Argument typecode '" + argument.type().kind().value() + "' is not supported.");
}
}