Documentation for Ice 3.4. The latest release is Ice 3.7. Refer to the space directory for other releases.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 25 Next »

A Slice enumeration maps to the corresponding enumeration in Java. For example:

Slice
enum Fruit { Apple, Pear, Orange };

The Java mapping for Fruit is shown below:

Java
public enum Fruit implements java.io.Serializable {
    Apple,
    Pear,
    Orange;

    // ...
}

Given the above definitions, we can use enumerated values as follows:

Java
Fruit f1 = Fruit.Apple;
Fruit f2 = Fruit.Orange;

if (f1 == Fruit.Apple) // Compare with constant
    // ...

if (f1 == f2)                     // Compare two enums
    // ...

switch (f2) {             // Switch on enum
case Fruit.Apple:
    // ...
    break;
case Fruit.Pear
    // ...
    break;
case Fruit.Orange
    // ...
    break;
}

Note that the generated class contains a number of other members, which we have not shown. These members are internal to the Ice run time and you must not use them in your application code (because they may change from release to release).

See Also
  • No labels