IDL Complex Type
stateful valuetype

The CORBA valuetype indicates that the method returns nothing.  It maps to J#'s class type.

Stateful valuetype is passed by value as arguments or result of remote methods.  Each stateful valuetype must be inherited from  Org.Omg.CORBA.Portable.StreamableValue and is marked with attribute Serializable.  The Serializable attribute is used for .Net streaming only, but not for Corba marshalling. 

Inheriated From Base Class:

Inherited From Interfaces:

Methods:

 

Constructors:

 

Fields:

 

Properties:

 

Repository ID:

 

// CORBA IDL
valuetype Account
{
   private string name; 
   public string address;
   private float balance; 
   
   void debit(in float amount );
	
   void credit( in float amount);
   factory init( in string name, in string address, 
                 in float balance); 
};
J#

package demo.obv.valuetype;

/**
 * Value Type definition : Account
 * 
 * @author TomORB J# Native Compiler
 */
public abstract class Account implements org.omg.CORBA.portable.StreamableValue
{
   /**
    * Private member : name
    */
   protected java.lang.String name;

   /**
    *  Public member : address
    */
   public java.lang.String address;

   /**
    * Private member : balance
    */
   protected float balance;

   /**
    * Operation debit
    */
   public abstract void debit(float amount);

   /**
    * Operation credit
    */
   public abstract void credit(float amount);

   /**
    * Return the truncatable ids
    */
   static final java.lang.String[] _ids_list =
   {
      "IDL:demo/obv/valuetype/Account:1.0"
   };

   public java.lang.String[] _truncatable_ids()
   {
      return _ids_list;
   }

   /**
    * Unmarshal the value into an InputStream
    */
   public void _read(org.omg.CORBA.portable.InputStream is)
   {
      name = is.read_string();
      address = is.read_string();
      balance = is.read_float();
   }

   /**
    * Marshal the value into an OutputStream
    */
   public void _write(org.omg.CORBA.portable.OutputStream os)
   {
      os.write_string(name);
      os.write_string(address);
      os.write_float(balance);
   }

   /**
    * Return the value TypeCode
    */
   public org.omg.CORBA.TypeCode _type()
   {
      return demo.obv.valuetype.AccountHelper.type();
   }

}

package demo.obv.valuetype;

/** 
 * Helper class for : Account
 *  
 * @author TomORB J# Native Compiler
 */ 
public class AccountHelper
{
   /**
    * Insert Account into an any
    * @param a an any
    * @param t Account value
    */
   public static void insert(org.omg.CORBA.Any a, demo.obv.valuetype.Account t)
   {
      a.insert_Value(t, type());
   }

   /**
    * Extract Account from an any
    * @param a an any
    * @return the extracted Account value
    */
   public static demo.obv.valuetype.Account extract(org.omg.CORBA.Any a)
   {
      if (!a.type().equal(type()))
         throw new org.omg.CORBA.MARSHAL();
      try {
         return (demo.obv.valuetype.Account)a.extract_Value();
      }
      catch(final java.lang.ClassCastException e) {
         throw new org.omg.CORBA.MARSHAL(e.getMessage());
      }
   }

   //
   // Internal TypeCode value
   //
   private static org.omg.CORBA.TypeCode _tc = null;
   private static boolean _working = false;

   /**
    * Return the Account TypeCode
    * @return a TypeCode
    */
   public static org.omg.CORBA.TypeCode type()
   {
      if (_tc == null) {
         synchronized(org.omg.CORBA.TypeCode.class) {
            if (_tc != null)
               return _tc;
            if (_working)
               return org.omg.CORBA.ORB.init().create_recursive_tc(id());
            _working = true;
            org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
            org.omg.CORBA.ValueMember []_members = new org.omg.CORBA.ValueMember[3];

            _members[0] = new org.omg.CORBA.ValueMember();
            _members[0].name = "name";
            _members[0].type = orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string);
            _members[0].access = org.omg.CORBA.PRIVATE_MEMBER.value;
            _members[1] = new org.omg.CORBA.ValueMember();
            _members[1].name = "address";
            _members[1].type = orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string);
            _members[1].access = org.omg.CORBA.PUBLIC_MEMBER.value;
            _members[2] = new org.omg.CORBA.ValueMember();
            _members[2].name = "balance";
            _members[2].type = orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_float);
            _members[2].access = org.omg.CORBA.PRIVATE_MEMBER.value;

            org.omg.CORBA.TypeCode _concrete_tc = orb.get_primitive_tc(
                             org.omg.CORBA.TCKind.tk_null);

            _tc = orb.create_value_tc(id(),"Account",org.omg.CORBA.VM_NONE.value,
                             _concrete_tc,_members);
            _working = false;
         }
      }
      return _tc;
   }

   /**
    * Return the Account IDL ID
    * @return an ID
    */
   public static java.lang.String id()
   {
      return _id;
   }

   private final static java.lang.String _id = "IDL:demo/obv/valuetype/Account:1.0";

   /**
    * Read Account from a marshalled stream
    * @param istream the input stream
    * @return the readed Account value
    */
   public static demo.obv.valuetype.Account read(org.omg.CORBA.portable.InputStream istream)
   {
      return (demo.obv.valuetype.Account) 
              ((org.omg.CORBA_2_3.portable.InputStream)istream).read_value(_id.toString());
   }

   /**
    * Write Account into a marshalled stream
    * @param ostream the output stream
    * @param value Account value
    */
   public static void write(org.omg.CORBA.portable.OutputStream ostream, 
                            demo.obv.valuetype.Account value)
   {
      ((org.omg.CORBA_2_3.portable.OutputStream)ostream).write_value(value, _id);
   }

   /**
    * Create a value type (using factory method)
    */
   public static Account init(org.omg.CORBA.ORB orb, java.lang.String name, 
                              java.lang.String address, float balance)
   {
      org.omg.CORBA.portable.ValueFactory _factory = 
                    ((org.omg.CORBA_2_3.ORB)orb).lookup_value_factory(id());
      if (_factory == null)
         throw new org.omg.CORBA.BAD_INV_ORDER();
      return ((demo.obv.valuetype.AccountValueFactory) 
                    (_factory)).init( name,  address,  balance);
   }

}

package demo.obv.valuetype;

/**
 * Holder class for : Account
 * 
 * @author TomORB J# Native Compiler
 */
final public class AccountHolder
      implements org.omg.CORBA.portable.Streamable
{
   /**
    * Internal Account value
    */
   public demo.obv.valuetype.Account value;

   /**
    * Default constructor
    */
   public AccountHolder()
   { }

   /**
    * Constructor with value initialisation
    * @param initial the initial value
    */
   public AccountHolder(demo.obv.valuetype.Account initial)
   {
      value = initial;
   }

   /**
    * Read Account from a marshalled stream
    * @param istream the input stream
   */
   public void _read(org.omg.CORBA.portable.InputStream istream)
   {   
      value = AccountHelper.read(istream);
   }

   /**
    * Write Account into a marshalled stream
    * @param ostream the output stream
    */
   public void _write(org.omg.CORBA.portable.OutputStream ostream)
   {
      AccountHelper.write(ostream,value);
   }

   /**
    * Return the Account TypeCode
    * @return a TypeCode
    */
   public org.omg.CORBA.TypeCode _type()
   {
      return AccountHelper.type();
   }

}

package demo.obv.valuetype;

/**
 * Factory definition : init
 * 
 * @author TomORB J# Native Compiler
 */
public interface AccountValueFactory extends org.omg.CORBA.portable.ValueFactory
{
   /**
    * Return the value type
    */
   public abstract demo.obv.valuetype.Account init(java.lang.String name, 
                                java.lang.String address, float balance);

}