i am stucked on something : i have some .idl files that generates java classes from structs defined in those files like this :
struct MapServiceLayer{
string id;
string name;
string parentId;
OsTypes::StringSeq childrenIds;
};
However I need to have a JAVA class where one of it's Attributes needs to be of type Java.Object because when i will instantiate this class, its attribute could be of different type. So i tried this :
struct MapServiceFeatureAttribute{
OsTypes::ObjectSeq value;
};
and this :
struct MapServiceFeatureAttribute{
OsTypes::AnySeq value;
};
But none of those worked. I also have heard about Unions but i am definitely not sure about how to use them. If someone knows how to get a Java.Object from idls this would be Great. If it's not possible maybe someone knows how to do with unions !
thanks in advance.
After some more deep research it seems that it is not possible to get a java.lang.object. However you can have a behavior that could do the trick using Any corba object :
After having generated your sources you will have a class with an attribute of type Any, this type allows you to store different types in it by using :
Any anyObj;
anyObj.insert_string(String s);
anyObj.insert_long(long l);
anyObj.insert_double(double d);
and you can obviously get the value and the chosen type by using :
String s1 = anyObj.extract_string(String s);
long l1 = anyObj.extract_long(long l);
double d1 = anyObj.extract_double(double d);
i gave the exemple for those 3 types but there is several more.