[jacorb-developer] JacOrb extracting enum values
Dimitris Zampouras
dzampouras at gmail.com
Fri Mar 10 13:09:03 CET 2017
I am currently trying to extract a Structured event from a notification
service from a telecommunication server under the MTNM TMF 3.14 standard.
The standard provides the idl files needed for the communication server.
The problem happens when I try to extract the filterable data of the
structured event. A sequence of filterable data is a sequence of
Properties that contain a name and a type Any. Therefore I have a method
extractAny(Any any) that extracts values of any.
for (Property p : ev.filterable_data) {
Object anything = extractAny(p.value);
if(anything instanceof String) {....}
...
}
The extractAny function uses a switch case on the TCKind of any and
extracts accordingly. For the enum value:
case TCKind._tk_enum:
ArrayList<String> enumeration = new ArrayList<>();
try {
for (int v = 0; v < any.type().member_count(); v++) {
enumeration.add(any.type().member_name(v));
}
} catch (BadKind ex) {
ex.printStackTrace();
} catch (Bounds ex) {
ex.printStackTrace();
}
return "" +enumeration.get(any.extract_long()); *<--problem
here*
I take all the values of the enum add them to an array and then by
extracting the integer value of /any/ I conclude to which of all the
enum data /any/ wants to point to.
I assumed this since enums(Java at least) consist of a set of options
but you have to choose only one(i.e. DAY.Monday , you can have only one
present day), therefore the any enum value contains all options but has
a pointer(an int maybe?) to what the actual chosen value is.
Previously I was compiling the idl files with idlj java v1.7 and that
operation was working.
I hope I have given you enough information, and thank you for your support!
I have attached the StructuredEvent.java and the CosNotification.idl
that generates the StructuredEvent
On 10/03/2017 01:06 μμ, Phil Mesnier wrote:
> Hi Dimitris,
>
> Can you show us the code that is causing your trouble?
>
> Are you using IDL enums, or Java Enums?
>
> The point behind enums is that they represent an ordered collection of
> discrete identities. The values used to represent these identities is
> an implementation detail. So it sounds like you are overthinking the
> problem. Perhaps for your use case an enum isn't the correct type to use.
>
> Let see your failing code and go from there. Don't just send a line or
> two, can you make a representative IDL, Client, and Server that
> illustrates what you are trying, but failing to do?
>
>
> On Fri, Mar 10, 2017 at 3:54 AM, Dimitris Zampouras
> <dzampouras at gmail.com <mailto:dzampouras at gmail.com>> wrote:
>
> Hello everyone!
>
> I am new to Corba and I am having a hard time extracting an enum
> value from an any object.
>
> From what I have gathered an enum value holds some data members
> like an array containing all the enum types.
> I suppose there should be some kind of integer inside the Any that
> shows which one of the enums it refers to.
>
> The problem is that I cannot extract from the enum Any that int
> value. All integer extractions fail( the long too etc.).
>
> Am I in the correct path here? Do you have any sample code that
> can help?
>
> I am currently using JacOrb 3.8 and Java 1.7
>
> Prior to changing to JacOrb I could extract the integer value from
> the enum type
>
> Thank you in advance!
>
> dzamp
>
> _______________________________________________
> jacorb-developer maillist -
> jacorb-developer at lists.spline.inf.fu-berlin.de
> <mailto:jacorb-developer at lists.spline.inf.fu-berlin.de>
> https://lists.spline.inf.fu-berlin.de/mailman/listinfo/jacorb-developer
> <https://lists.spline.inf.fu-berlin.de/mailman/listinfo/jacorb-developer>
>
>
>
>
> --
>
> Phil Mesnier
> Principal Engineer & Partner
> OCI | WE ARE SOFTWARE ENGINEERS.
> tel (314) 579-0066 x225 <tel:%28314%29%20579-0066>
> ObjectComputing.com
> <http://objectcomputing.com/>
>
>
More information about the jacorb-developer
mailing list