Search in sources :

Example 1 with DynArray

use of org.omg.DynamicAny.DynArray in project ACS by ACS-Community.

the class BACIIntrospector method insertSequence.

public Any insertSequence(TypeCode tc, Any argument, java.lang.Object obj) {
    if (argument == null)
        throw new NullPointerException("argument");
    if (obj == null)
        throw new NullPointerException("obj");
    if (!obj.getClass().isArray())
        throw new IllegalArgumentException("The parameter obj has to be a sequence");
    java.lang.Object[] objs;
    if (obj.getClass().getComponentType().isPrimitive())
        objs = DataFormatter.convertPrimitiveArray(obj);
    else
        objs = (java.lang.Object[]) obj;
    DynAny dany;
    try {
        dany = ra.getDynFact().create_dyn_any_from_type_code(tc);
    } catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode e) {
        e.printStackTrace();
        return null;
    }
    Any[] els = new Any[objs.length];
    try {
        for (int i = 0; i < els.length; i++) {
            DynAny dany2;
            try {
                dany2 = ra.getDynFact().create_dyn_any_from_type_code(tc.content_type());
            } catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode e) {
                e.printStackTrace();
                return null;
            }
            els[i] = dany2.to_any();
            els[i] = insertAny(tc.content_type(), els[i], objs[i]);
        }
        if (tc.kind() == TCKind.tk_sequence) {
            ((DynSequence) dany).set_elements(els);
            ((DynSequence) dany).set_length(els.length);
        } else if (tc.kind() == TCKind.tk_array)
            ((DynArray) dany).set_elements(els);
    } catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch e) {
        e.printStackTrace();
    } catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue e) {
        e.printStackTrace();
    } catch (org.omg.CORBA.TypeCodePackage.BadKind e) {
        e.printStackTrace();
    }
    return dany.to_any();
}
Also used : DynArray(org.omg.DynamicAny.DynArray) Any(org.omg.CORBA.Any) DynAny(org.omg.DynamicAny.DynAny) DynSequence(org.omg.DynamicAny.DynSequence) DynAny(org.omg.DynamicAny.DynAny) IRObject(org.omg.CORBA.IRObject)

Aggregations

Any (org.omg.CORBA.Any)1 IRObject (org.omg.CORBA.IRObject)1 DynAny (org.omg.DynamicAny.DynAny)1 DynArray (org.omg.DynamicAny.DynArray)1 DynSequence (org.omg.DynamicAny.DynSequence)1