Hitachi

VisiBroker Version 5 Borland(R) Enterprise Server VisiBroker(R) プログラマーズリファレンス


2.5.2 Holderクラス

Holderクラスは,OUTおよびINOUTパラメタ受け渡しモードをサポートし,org.omg.CORBAパッケージのすべての基本IDLデータ型で利用できます。Holderクラスは,typedefsで定義されたものを除いて,すべての名前付きユーザ定義型で生成されます。Holderクラスの詳細については,「3. 生成されるインタフェースとクラス(Java)」を参照してください。

ユーザ定義IDL型では,Holderクラス名は,その型のマッピングされたJava名の後ろにHolderを付けて構成されます。

基本IDLデータ型では,マッピングされたデータ型に対するJava型名(最初の文字が大文字)の後ろにHolderを付けたHolderクラス名になります。例えば,IntHolderがそうです。

各Holderクラスには,インスタンスからのコンストラクタ,デフォルトコンストラクタがあり,型付きのvalueというパブリックインスタンスメンバがあります。デフォルトコンストラクタは,Java言語によって定義されたように,値フィールドを型のデフォルト値に設定します。

ポータブルスタブ,およびスケルトンをサポートするには,ユーザ定義型のHolderクラスもorg.omg.CORBA.portable.Streamableインタフェースをインプリメントします。

基本型のHolderクラスは,次のコードサンプルで定義されます。これらはorg.omg.CORBAパッケージにあります。

コードサンプル2-2 Holderクラス
//Java
package org.omg.CORBA;
 
final public class ShortHolder implements Streamable {
    public short value;
    public ShortHolder( ){}
    public ShortHolder(short initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}
 
final public class IntHolder implements Streamable {
    public int value;
    public IntHolder( ){}
    public IntHolder(int initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}
 
final public class LongHolder implements Streamable {
    public long value;
    public LongHolder( ){}
    public LongHolder(long initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}
 
final public class ByteHolder implements Streamable {
    public byte value;
    public ByteHolder( ){}
    public ByteHolder(byte initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}
 
final public class FloatHolder implements Streamable {
    public float value;
    public FloatHolder( ){}
    public FloatHolder(float initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}
 
final public class DoubleHolder implements Streamable {
    public double value;
    public DoubleHolder( ){}
    public DoubleHolder(double initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}
 
final public class CharHolder implements Streamable {
    public char value;
    public CharHolder( ){}
    public CharHolder(char initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}
 
final public class BooleanHolder implements Streamable {
    public boolean value;
    public BooleanHolder( ){}
    public BooleanHolder(boolean initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}
 
final public class StringHolder implements Streamable {
    public java.lang.String value;
    public StringHolder( ){}
    public StringHolder(java.lang.String initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}
 
final public class ObjectHolder implements Streamable {
    public org.omg.CORBA.Object value;
    public ObjectHolder( ){}
    public ObjectHolder(org.omg.CORBA.Object initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}
 
final public class ValueBaseHolder implements Streamable {
    public java.io.Serializable value;
    public ValueBaseHolder( ){}
    public ValueBaseHolder(java.io.Serializable initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}
 
final public class AnyHolder implements Streamable {
    public Any value;
    public AnyHolder( ){}
    public AnyHolder(Any initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}
 
final public class TypeCodeHolder implements Streamable {
    public TypeCode value;
    public typeCodeHolder( ){}
    public TypeCodeHolder(TypeCode initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}
 
final public class PrincipalHolder implements Streamable {
    public Principal value;
    public PrincipalHolder( ){}
    public PrincipalHolder(Principal initial){
        value =initial;
    }
    ...//implementation of the streamable interface
}

ユーザ定義型<foo>のHolderクラスを次に示します。

コードサンプル2-3 ユーザ定義型のHolderクラス
// Java
final public class <foo>Holder
   implements org.omg.CORBA.portable.Streamable {
   public <foo> value;
   public <foo>Holder( ) {}
   public <foo>Holder(<foo> initial) {}
   public void _read(org.omg.CORBA.portable.InputStream i)
    {...}
   public void _write(org.omg.CORBA.portable.OutputStream o)
    {...}
   public org.omg.CORBA.TypeCode _type( ) {...}
}
Java null

Java nullは,nullCORBAオブジェクトリファレンスとvaluetype(再帰型のvaluetypeを含む)を表すためだけに使用されます。例えば,空の文字列を表すときは,nullを使わないで長さ0の文字列を使用してください。これは配列にも,valuetypeを除く構造型にも当てはまります。構造体用にnullを渡そうとすると,NullPointerExceptionが発生します。