>>>>> "Tina" <nahal_ir@yahoo.de> (T) wrote:
>T> Hi,
>T> how could I implement IDL-struct as return value of method in java,
>T> please:
>T> ///IDL
>T> struct info{
>T> long ID
>T> string notice
>T> }
>T> interface XX{
>T> Info delete(in DD, out KK);
>T> }
(By the way, use either info or Info, but not both.)
This kind of thing is described in the Java language binding document,
http://www.omg.org/technology/documents/formal/omg_idl_to_java_language_mapping.htm
An IDL struct is mapped to a final Java class with the same name and
which provides instance variables for the fields in IDL member
ordering, a constructor for all values, and which implements IDLEntity.
A null constructor is also provided so that the fields can be filled in
later. All string fields in the struct are initialized to "".
So in your example:
final public class info
implements org.omg.CORBA.portable.IDLEntity {
// instance variables
public int ID; /* long maps to int */
public String notice = "";
// constructors
public info() {}
public StructType(int f1, String f2) {...}
}
For the out parameter you get a class infoHolder

Signature
Piet van Oostrum <piet@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: piet@vanoostrum.org
Tina - 20 Jun 2005 10:22 GMT
Hi,
thank you very much for your answer.
I try to implement this in server- and client-sided. That would be
great, if you ckeck that code, whether that is correct.
in server sided :
public info delete(int DD, KKHolder obj) {
obj.value = this.KK;
return new info(0, "successfully.");
}
------------------
in client-sided:
KKHolder obj = new KKHolder();
Info inf = acc.delete(11,obj);
thanks
Br,
tina
Piet van Oostrum - 20 Jun 2005 11:46 GMT
>>>>> "Tina" <nahal_ir@yahoo.de> (T) wrote:
>T> Hi,
>T> thank you very much for your answer.
>T> I try to implement this in server- and client-sided. That would be
>T> great, if you ckeck that code, whether that is correct.
>T> in server sided :
>T> public info delete(int DD, KKHolder obj) {
I suppose you are going to use DD here also.
>T> obj.value = this.KK;
>T> return new info(0, "successfully.");
>T> }
>T> ------------------
>T> in client-sided:
>T> KKHolder obj = new KKHolder();
>T> Info inf = acc.delete(11,obj);
That should be info instead of Info. And I suppose you want to use
obj.value also later on.
For the rest it looks Ok to me.

Signature
Piet van Oostrum <piet@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: piet@vanoostrum.org
Tina - 20 Jun 2005 13:33 GMT