Home Help Center

Java: going from String to Enum Type

nightndaynightnday Member David ChuOrganization: UofHProject: FlightOp
In Java:

I have an ice interface that contains enum declarations.

Does ICE generate a class/method where I can convert a String of enum value, so that I can assign the converted value to the member variable of the same enum type?

Currently I have to do it this way
i.e
enum EmployeePaidType { salary, hourly };

EmployeePaidType myEmployeePaidType;
if( "salary".equals(paidType) )
myEmployeePaidType = EmployeePaidType.salary;
else if( "hourly".equals(paidType) )
myEmployeePaidType = EmployeePaidType.hourly;


I am using ICE 3.0.1 on Windows XP

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi David,

    I'm afraid there isn't a more convenient way to perform this conversion.

    Take care,
    - Mark
  • nightndaynightnday Member David ChuOrganization: UofHProject: FlightOp
    It would seem that this should be a standard for the generated code.

    Also it would be nice to have the size be public accessible by variable or getter.
Sign In or Register to comment.