Search in sources :

Example 1 with DataEnum

use of si.ijs.acs.objectexplorer.engine.DataEnum in project ACS by ACS-Community.

the class BACIIntrospector method getEnumDef.

private DataEnum getEnumDef(TypeCode tc) {
    if (tc.kind() != TCKind.tk_enum)
        return null;
    try {
        DataEnum de = new DataEnum(tc.id());
        Contained ctd = ra.lookupId(tc.id());
        EnumDef ed = EnumDefHelper.narrow(ctd);
        String[] mems = ed.members();
        for (int i = 0; i < mems.length; i++) de.add(i, mems[i]);
        return de;
    } catch (org.omg.CORBA.TypeCodePackage.BadKind e) {
        e.printStackTrace();
        return null;
    }
}
Also used : Contained(org.omg.CORBA.Contained) EnumDef(org.omg.CORBA.EnumDef) DataEnum(si.ijs.acs.objectexplorer.engine.DataEnum)

Example 2 with DataEnum

use of si.ijs.acs.objectexplorer.engine.DataEnum 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.");
    }
}
Also used : DynEnum(org.omg.DynamicAny.DynEnum) DataEnum(si.ijs.acs.objectexplorer.engine.DataEnum)

Aggregations

DataEnum (si.ijs.acs.objectexplorer.engine.DataEnum)2 Contained (org.omg.CORBA.Contained)1 EnumDef (org.omg.CORBA.EnumDef)1 DynEnum (org.omg.DynamicAny.DynEnum)1