Package org.omg.DynamicAny

Examples of org.omg.DynamicAny.NameValuePair


      // test inserting a member with an incorrect type
      pairs = new NameValuePair [2];
      any = orb.create_any ();
      any.insert_char ('a');
      pairs [0] = new NameValuePair (name1, any);
      any = orb.create_any ();
      any.insert_string ("WrongType");
      pairs [0] = new NameValuePair (name2, any);

      msg = "Failed to raise a TypeMismatch exception when passing in a ";
      msg += "name/value pair containing an incorrect member value";
      try
      {
         dynAny.set_members (pairs);

         fail (msg);
      }
      catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch ex)
      {
         // success
      }
      catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue ex)
      {
         fail (msg + ": " + ex);
      }

      // test inserting a member with an incorrect name
      pairs = new NameValuePair [2];
      any = orb.create_any ();
      any.insert_char ('a');
      pairs [0] = new NameValuePair (name1, any);
      any = orb.create_any ();
      any.insert_longlong ((long) 1);
      pairs [1] = new NameValuePair ("WrongName", any);

      msg = "Failed to raise a TypeMismatch exception when passing in a ";
      msg += "name/value pair containing an incorrect member name";
      try
      {
         dynAny.set_members (pairs);

         fail (msg);
      }
      catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch ex)
      {
         // success
      }
      catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue ex)
      {
         fail (msg + ": " + ex);
      }

      // test inserting a sequence with the wrong number of members
      pairs = new NameValuePair [3];
      any = orb.create_any ();
      any.insert_char ('a');
      pairs [0] = new NameValuePair (name1, any);
      any = orb.create_any ();
      any.insert_longlong ((long) 1);
      pairs [1] = new NameValuePair (name2, any);
      any = orb.create_any ();
      any.insert_longlong ((long) 1);
      pairs [2] = new NameValuePair (name2, any);

      msg = "Failed to raise an InvalidValue exception when passing in a ";
      msg += "name/value sequence containing too many members";
      try
      {
View Full Code Here


      // test inserting a sequence with the wrong number of members
      pairs = new NameValuePair [1];
      any = orb.create_any ();
      any.insert_char ('a');
      pairs [0] = new NameValuePair ("name", any);

      msg = "Failed to raise an InvalidValue exception when passing in a ";
      msg += "name/value sequence containing too many members";
      try
      {
View Full Code Here

      assertEquals (msg, oldStr, pairs [1].value.extract_string ());

      pairs = new NameValuePair [2]; // specific to IDL
      any = orb.create_any ();
      any.insert_long (newInt);
      pairs [0] = new NameValuePair (name1, any);
      any = orb.create_any ();
      any.insert_string (newStr);
      pairs [1] = new NameValuePair (name2, any);

      msg = "Failed to set DynStruct members using DynStruct::set_members ";
      msg += "operation";
      dynAny.set_members (pairs);
View Full Code Here

      // test inserting a member with an incorrect type
      pairs = new NameValuePair [2];
      any = orb.create_any ();
      any.insert_char ('a');
      pairs [0] = new NameValuePair (name1, any);
      any = orb.create_any ();
      any.insert_string ("WrongType");
      pairs [0] = new NameValuePair (name2, any);

      msg = "Failed to raise a TypeMismatch exception when passing in a ";
      msg += "name/value pair containing an incorrect member value";
      try
      {
         dynAny.set_members (pairs);

         fail (msg);
      }
      catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch ex)
      {
         // success
      }
      catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue ex)
      {
         fail (msg + ": " + ex);
      }

      // test inserting a member with an incorrect name
      pairs = new NameValuePair [2];
      any = orb.create_any ();
      any.insert_char ('a');
      pairs [0] = new NameValuePair (name1, any);
      any = orb.create_any ();
      any.insert_longlong ((long) 1);
      pairs [1] = new NameValuePair ("WrongName", any);

      msg = "Failed to raise a TypeMismatch exception when passing in a ";
      msg += "name/value pair containing an incorrect member name";
      try
      {
         dynAny.set_members (pairs);

         fail (msg);
      }
      catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch ex)
      {
         // success
      }
      catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue ex)
      {
         fail (msg + ": " + ex);
      }

      // test inserting a sequence with the wrong number of members
      pairs = new NameValuePair [3];
      any = orb.create_any ();
      any.insert_char ('a');
      pairs [0] = new NameValuePair (name1, any);
      any = orb.create_any ();
      any.insert_longlong ((long) 1);
      pairs [1] = new NameValuePair (name2, any);
      any = orb.create_any ();
      any.insert_longlong ((long) 1);
      pairs [2] = new NameValuePair (name2, any);

      msg = "Failed to raise an InvalidValue exception when passing in a ";
      msg += "name/value sequence containing too many members";
      try
      {
View Full Code Here

      assertEquals (msg, oldStr, pairs [1].value.extract_string ());

      pairs = new NameValuePair [2]; // specific to IDL
      any = orb.create_any ();
      any.insert_long (newInt);
      pairs [0] = new NameValuePair (name1, any);
      any = orb.create_any ();
      any.insert_string (newStr);
      pairs [1] = new NameValuePair (name2, any);

      try
      {
         dynAny.set_members (pairs);
      }
View Full Code Here

      // test inserting a member with an incorrect type
      pairs = new NameValuePair [2];
      any = orb.create_any ();
      any.insert_char ('a');
      pairs [0] = new NameValuePair (name1, any);
      any = orb.create_any ();
      any.insert_string ("WrongType");
      pairs [0] = new NameValuePair (name2, any);

      msg = "Failed to raise a TypeMismatch exception when passing in a ";
      msg += "name/value pair containing an incorrect member value";
      try
      {
         dynAny.set_members (pairs);

         fail (msg);
      }
      catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch ex)
      {
         // success
      }
      catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue ex)
      {
         fail (msg + ": " + ex);
      }

      // test inserting a member with an incorrect name
      pairs = new NameValuePair [2];
      any = orb.create_any ();
      any.insert_char ('a');
      pairs [0] = new NameValuePair (name1, any);
      any = orb.create_any ();
      any.insert_longlong ((long) 1);
      pairs [1] = new NameValuePair ("WrongName", any);

      msg = "Failed to raise a TypeMismatch exception when passing in a ";
      msg += "name/value pair containing an incorrect member name";
      try
      {
         dynAny.set_members (pairs);

         fail (msg);
      }
      catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch ex)
      {
         // success
      }
      catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue ex)
      {
         fail (msg + ": " + ex);
      }

      // test inserting a sequence with the wrong number of members
      pairs = new NameValuePair [3];
      any = orb.create_any ();
      any.insert_char ('a');
      pairs [0] = new NameValuePair (name1, any);
      any = orb.create_any ();
      any.insert_longlong ((long) 1);
      pairs [1] = new NameValuePair (name2, any);
      any = orb.create_any ();
      any.insert_longlong ((long) 1);
      pairs [2] = new NameValuePair (name2, any);

      msg = "Failed to raise an InvalidValue exception when passing in a ";
      msg += "name/value sequence containing too many members";
      try
      {
View Full Code Here

            for( int i = 0 ; i < limit; i++ )
            {
                org.omg.CORBA.TypeCode _tc =
                    TypeCode.originalType( typeCode.member_type(i) );
                members[i] =
                    new NameValuePair(
                            typeCode.member_name(i),
                            dynFactory.create_dyn_any_from_type_code( _tc ).to_any());

            }
        }
View Full Code Here

                {
                    Any any = (org.jacorb.orb.Any)orb.create_any();
                    any.read_value(is,
                                 TypeCode.originalType(typeCode.member_type(i)));

                    members[i] = new NameValuePair( type().member_name(i), any);
                }
                catch( org.omg.CORBA.TypeCodePackage.Bounds e )
                {
                    throw unexpectedException(e);
                }
View Full Code Here

        }
        members = new NameValuePair[nvp.length];
        for( int i = 0; i < limit; i++ )
        {
            members[i] = new NameValuePair( nvp[i].id, nvp[i].value.to_any() );
        }
    }
View Full Code Here

        // the member name is "first"

        NameValuePair[]  nvp_seq = new NameValuePair[2];
        Any first_member_any = orb.create_any();
        first_member_any.insert_string("first");
        nvp_seq[0] = new NameValuePair("first", first_member_any );

        /*
         the second member is a recursive sequence, ie. the element
             type of the sequence is that of the enclosing  struct, the
             member name is "second". We'll leave that sequence empty,
             but we have to provide an initialized any for the empty
             sequence, so we create a DynAny that initializes an any
             as an empty sequence
         */

        DynSequence second_member =
            (DynSequence)dynFactory.create_dyn_any_from_type_code(
                    struct_tc.member_type(1) );
        nvp_seq[1] =
            new NameValuePair("second", second_member.to_any() );

        // insert the nvp list into the DynStruct
        dyn_struct.set_members( nvp_seq );

        System.out.println("[Client]: Passing a struct..." +
View Full Code Here

TOP

Related Classes of org.omg.DynamicAny.NameValuePair

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.