Package org.omg.DynamicAny

Examples of org.omg.DynamicAny.DynAny


    {
        final int _length;

        switch (value.type().kind().value()) {
        case TCKind._tk_array:
            DynAny _dynAny = toDynAny(value);
            _length = _dynAny.component_count();
            break;

        case TCKind._tk_sequence:
            DynSequence _dynSequence = toDynSequence(value);
            _length = _dynSequence.get_length();
View Full Code Here


            if (logger_.isDebugEnabled())
            {
                logger_.debug("evaluateNamedValueList(" + any + ", " + name + ")");
            }

            final DynAny _dynAny = toDynAny(any);
            final int _count = _dynAny.component_count();

            DynAny _cursor;
            Any _ret = null;

            _dynAny.rewind();

            if (logger_.isDebugEnabled())
View Full Code Here

            if (logger_.isDebugEnabled())
            {
                logger_.debug("evaluate array idx " + index + " on a Any of type: " + any.type());
            }

            DynAny _dynAny = toDynAny(any);
            DynAny _cursor;

            _dynAny.rewind();
            _dynAny.seek(index);
            _cursor = _dynAny.current_component();

            if (logger_.isDebugEnabled())
            {
                logger_.debug("evaluation result is of type: " + _cursor.type());
            }

            return _cursor.to_any();
        } catch (TypeMismatch e)
        {
            throw newEvaluationException(e);
        }
    }
View Full Code Here

    private Any evaluateIdentifier(DynAny any, int position) throws EvaluationException
    {
        try
        {
            final DynAny _result;

            switch (any.type().kind().value()) {

            case TCKind._tk_struct:
                any.seek(position);
                _result = any.current_component();
                break;

            default:
                throw new EvaluationException("attempt to access member on non-struct");
            }

            return _result.to_any();
        } catch (TypeMismatch e)
        {
            throw newEvaluationException(e);
        }
    }
View Full Code Here

        if (logger_.isDebugEnabled())
        {
            logger_.debug("evaluate idx " + position + " on Any");
        }

        DynAny _dynAny = toDynAny(any);

        return evaluateIdentifier(_dynAny, position);
    }
View Full Code Here

            _dynSequence.rewind();

            do
            {
                final DynAny _currentComponent = _dynSequence.current_component();

                final EvaluationResult _currentElement = EvaluationResult.fromAny(_currentComponent.to_any());

                if (element.compareTo(_currentElement) == 0)
                {
                    return EvaluationResult.BOOL_TRUE;
                }
View Full Code Here

     * expensive
     */
    public Any evaluateIdentifier(Any any, String identifier) throws EvaluationException
    {
        // expensive call
        DynAny _dynAny = toDynAny(any);

        // expensive call
        return evaluateIdentifier(_dynAny, identifier);
    }
View Full Code Here

            if (logger_.isDebugEnabled())
            {
                logger_.debug("evaluate " + _strippedIdentifier + " on Any");
            }

            DynAny _cursor = any;

            SWITCH_LABEL:
            switch (any.type().kind().value()) {

            case TCKind._tk_struct:

                logger_.debug("Any is a struct");

                final DynStruct _dynStruct = DynStructHelper.narrow(any);
                String _currentName;

                _dynStruct.rewind();

                do
                {
                    _currentName = _dynStruct.current_member_name();

                    if (logger_.isDebugEnabled())
                    {
                        logger_.debug(" => " + _currentName);
                    }

                    if (_currentName.equals(_strippedIdentifier))
                    {
                        // expensive operation
                        _cursor = _dynStruct.current_component();
                        break SWITCH_LABEL;
                    }
                } while (_dynStruct.next());

                throw new EvaluationException("struct has no member " + _strippedIdentifier);

            case TCKind._tk_union:

                if (logger_.isDebugEnabled())
                {
                    logger_.debug("Any is a Union");
                }

                DynUnion _dynUnion = toDynUnion(any);

                if (_dynUnion.member_name().equals(_strippedIdentifier))
                {
                    _cursor = _dynUnion.member();
                }
                else
                {
                    if (logger_.isDebugEnabled())
                    {
                        logger_.debug(_dynUnion.member_name() + " != " + _strippedIdentifier);
                    }

                    throw new EvaluationException("member " + _strippedIdentifier
                            + " is not active on struct");
                }

                break;

            case TCKind._tk_any:
                logger_.debug("encapsulated any");

                return evaluateIdentifier(any.get_any(), _strippedIdentifier);

            default:
                logger_.debug("unknown " + any.type());

                return null;
            }

            if (logger_.isDebugEnabled())
            {
                logger_.debug("Result: " + _cursor);
            }

            if (_cursor != null && logger_.isDebugEnabled())
            {
                logger_.debug("evaluation result is of type: " + _cursor.type());
            }

            if (_cursor == null)
            {
                logger_.debug("Member not found");

                throw new EvaluationException("member not found");
            }

            return _cursor.to_any();
        } catch (InvalidValue e)
        {
            throw newEvaluationException(e);
        } catch (TypeMismatch e)
        {
View Full Code Here

    {
        final NVList _expectedParams = getORB().create_list(operation.parameters.length);

        for (int x = 0; x < operation.parameters.length; ++x)
        {
            final DynAny _dynAny = dynAnyFactory_
                    .create_dyn_any_from_type_code(operation.parameters[x].type);

            _expectedParams
                    .add_value(operation.parameters[x].name, _dynAny.to_any(), ARG_OUT.value);
        }

        map.put(operation.name, _expectedParams);
    }
View Full Code Here

    try
      {
        org.omg.CORBA.Object obj;
        Any any = orb.create_any();
        Any av;
        DynAny d1 = null;
        DynAny d2 = null;
        DynAny copy = null;
        TypeCode type;
        TypeCode tc;

        //
        // Test: short
        //
        type = orb.get_primitive_tc(TCKind.tk_short);
        d1 = factory.create_dyn_any_from_type_code(type);
        TEST(d1.get_short() == (short) 0);
        d1.insert_short((short) -53);
        TEST(d1.get_short() == (short) -53);
        d1.insert_short((short) 32000);
        TEST(d1.get_short() == (short) 32000);

        av = d1.to_any();

        short shortVal = av.extract_short();
        TEST(shortVal == (short) 32000);

        any.insert_short((short) 32000);
        d2 = factory.create_dyn_any(any);
        TEST(d1.equal(d2));

        copy = d1.copy();
        TEST(d1.equal(copy));
        TEST(copy.get_short() == (short) 32000);

        any.insert_short((short) -99);
        d2.from_any(any);
        d1.assign(d2);
        TEST(d1.equal(d2));

        d1.destroy();
        d2.destroy();
        copy.destroy();

        testOps(orb, factory, type, false);

        //
        // Test: unsigned short
        //
        type = orb.get_primitive_tc(TCKind.tk_ushort);
        d1 = factory.create_dyn_any_from_type_code(type);
        TEST(d1.get_ushort() == (short) 0);
        d1.insert_ushort((short) 199);
        TEST(d1.get_ushort() == (short) 199);
        d1.insert_ushort((short) 65001);
        TEST(d1.get_ushort() == (short) 65001);

        av = d1.to_any();

        short ushortVal = av.extract_ushort();
        TEST(ushortVal == (short) 65001);

        any.insert_ushort((short) 65001);
        d2 = factory.create_dyn_any(any);
        TEST(d1.equal(d2));

        copy = d1.copy();
        TEST(d1.equal(copy));
        TEST(copy.get_ushort() == (short) 65001);

        any.insert_ushort((short) 501);
        d2.from_any(any);
        d1.assign(d2);
        TEST(d1.equal(d2));

        d1.destroy();
        d2.destroy();
        copy.destroy();

        testOps(orb, factory, type, false);

        //
        // Test: long
        //
        type = orb.get_primitive_tc(TCKind.tk_long);
        d1 = factory.create_dyn_any_from_type_code(type);
        TEST(d1.get_long() == 0);
        d1.insert_long(-530000);
        TEST(d1.get_long() == -530000);
        d1.insert_long(3200000);
        TEST(d1.get_long() == 3200000);

        av = d1.to_any();

        int longVal = av.extract_long();
        TEST(longVal == 3200000);

        any.insert_long(3200000);
        d2 = factory.create_dyn_any(any);
        TEST(d1.equal(d2));

        copy = d1.copy();
        TEST(d1.equal(copy));
        TEST(copy.get_long() == 3200000);

        any.insert_long(-99000);
        d2.from_any(any);
        d1.assign(d2);
        TEST(d1.equal(d2));

        d1.destroy();
        d2.destroy();
        copy.destroy();

        testOps(orb, factory, type, false);

        //
        // Test: unsigned long
        //
        type = orb.get_primitive_tc(TCKind.tk_ulong);
        d1 = factory.create_dyn_any_from_type_code(type);
        TEST(d1.get_ulong() == 0);
        d1.insert_ulong(199000);
        TEST(d1.get_ulong() == 199000);
        d1.insert_ulong(65001000);
        TEST(d1.get_ulong() == 65001000);

        av = d1.to_any();

        int ulongVal = av.extract_ulong();
        TEST(ulongVal == 65001000);

        any.insert_ulong(65001000);
        d2 = factory.create_dyn_any(any);
        TEST(d1.equal(d2));

        copy = d1.copy();
        TEST(d1.equal(copy));
        TEST(copy.get_ulong() == 65001000);

        any.insert_ulong(501000);
        d2.from_any(any);
        d1.assign(d2);
        TEST(d1.equal(d2));

        d1.destroy();
        d2.destroy();
        copy.destroy();

        testOps(orb, factory, type, false);

        //
        // Test: float
        //
        type = orb.get_primitive_tc(TCKind.tk_float);
        d1 = factory.create_dyn_any_from_type_code(type);
        TEST(d1.get_float() == 0.0f);
        d1.insert_float(199.001f);
        TEST(d1.get_float() > 199.0f && d1.get_float() < 199.1f);
        d1.insert_float(6500.10001f);
        TEST(d1.get_float() > 6500.0f && d1.get_float() < 6501.0f);

        av = d1.to_any();

        float floatVal = av.extract_float();
        TEST(floatVal > 6500.1 && floatVal < 6500.2);

        any.insert_float((float) 6500.10001);
        d2 = factory.create_dyn_any(any);
        TEST(d1.equal(d2));

        copy = d1.copy();
        TEST(d1.equal(copy));
        TEST(copy.get_float() > 6500.1 && copy.get_float() < 6500.2);

        any.insert_float((float) 501.001);
        d2.from_any(any);
        d1.assign(d2);
        TEST(d1.equal(d2));

        d1.destroy();
        d2.destroy();
        copy.destroy();

        testOps(orb, factory, type, false);

        //
        // Test: double
        //
        type = orb.get_primitive_tc(TCKind.tk_double);
        d1 = factory.create_dyn_any_from_type_code(type);
        TEST(d1.get_double() == 0.0);
        d1.insert_double(199000.001);
        TEST(d1.get_double() > 199000.0 && d1.get_double() < 199000.1);
        d1.insert_double(6500000.10001);
        TEST(d1.get_double() > 6500000.1 && d1.get_double() < 6500000.2);

        av = d1.to_any();

        double doubleVal = av.extract_double();
        TEST(doubleVal > 6500000.1 && doubleVal < 6500000.2);

        any.insert_double(6500000.10001);
        d2 = factory.create_dyn_any(any);
        TEST(d1.equal(d2));

        copy = d1.copy();
        TEST(d1.equal(copy));
        TEST(copy.get_double() > 6500000.1 && copy.get_double() < 6500000.2);

        any.insert_double(501000.001);
        d2.from_any(any);
        d1.assign(d2);
        TEST(d1.equal(d2));

        d1.destroy();
        d2.destroy();
        copy.destroy();

        testOps(orb, factory, type, false);

        //
        // Test: boolean
        //
        type = orb.get_primitive_tc(TCKind.tk_boolean);
        d1 = factory.create_dyn_any_from_type_code(type);
        TEST(d1.get_boolean() == false);
        d1.insert_boolean(false);
        TEST(d1.get_boolean() == false);
        d1.insert_boolean(true);
        TEST(d1.get_boolean() == true);

        av = d1.to_any();

        boolean boolVal = av.extract_boolean();
        TEST(boolVal == true);

        any.insert_boolean(true);
        d2 = factory.create_dyn_any(any);
        TEST(d1.equal(d2));

        copy = d1.copy();
        TEST(d1.equal(copy));
        TEST(copy.get_boolean() == true);

        any.insert_boolean(false);
        d2.from_any(any);
        d1.assign(d2);
        TEST(d1.equal(d2));

        d1.destroy();
        d2.destroy();
        copy.destroy();

        testOps(orb, factory, type, false);

        //
        // Test: char
        //
        type = orb.get_primitive_tc(TCKind.tk_char);
        d1 = factory.create_dyn_any_from_type_code(type);
        TEST(d1.get_char() == 0);
        d1.insert_char('A');
        TEST(d1.get_char() == 'A');
        d1.insert_char('z');
        TEST(d1.get_char() == 'z');

        av = d1.to_any();

        char charVal = av.extract_char();
        TEST(charVal == 'z');

        any.insert_char('z');
        d2 = factory.create_dyn_any(any);
        TEST(d1.equal(d2));

        copy = d1.copy();
        TEST(d1.equal(copy));
        TEST(copy.get_char() == 'z');

        any.insert_char('@');
        d2.from_any(any);
        d1.assign(d2);
        TEST(d1.equal(d2));

        d1.destroy();
        d2.destroy();
        copy.destroy();

        testOps(orb, factory, type, false);

        //
        // Test: octet
        //
        type = orb.get_primitive_tc(TCKind.tk_octet);
        d1 = factory.create_dyn_any_from_type_code(type);
        TEST(d1.get_octet() == 0);
        d1.insert_octet((byte) 255);
        TEST(d1.get_octet() == (byte) 255);
        d1.insert_octet((byte) 1);
        TEST(d1.get_octet() == (byte) 1);

        av = d1.to_any();

        byte octetVal = av.extract_octet();
        TEST(octetVal == (byte) 1);

        any.insert_octet((byte) 1);
        d2 = factory.create_dyn_any(any);
        TEST(d1.equal(d2));

        copy = d1.copy();
        TEST(d1.equal(copy));
        TEST(copy.get_octet() == (byte) 1);

        any.insert_octet((byte) 127);
        d2.from_any(any);
        d1.assign(d2);
        TEST(d1.equal(d2));

        d1.destroy();
        d2.destroy();
        copy.destroy();

        testOps(orb, factory, type, false);

        //
        // Test: any
        //
        type = orb.get_primitive_tc(TCKind.tk_any);
        d1 = factory.create_dyn_any_from_type_code(type);
        any.insert_long(345678);
        d1.insert_any(any);
        av = d1.get_any();
        longVal = av.extract_long();
        TEST(longVal == 345678);

        any = orb.create_any();

        Any anyVal = orb.create_any();
        anyVal.insert_long(345678);
        any.insert_any(anyVal);
        d2 = factory.create_dyn_any(any);
        TEST(d1.equal(d2));

        av = d1.to_any();

        Any cap = av.extract_any();
        longVal = cap.extract_long();
        TEST(longVal == 345678);

        anyVal.insert_string("anyValue");
        any.insert_any(anyVal);
        d2.from_any(any);
        d1.assign(d2);
        TEST(d1.equal(d2));

        copy = d1.copy();
        TEST(d1.equal(copy));

        d1.destroy();
        d2.destroy();
        copy.destroy();

        testOps(orb, factory, type, false);
      }
    catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode ex)
      {
View Full Code Here

TOP

Related Classes of org.omg.DynamicAny.DynAny

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.