01: package demo.unions;
02:
03: public class serverImpl extends MyServerPOA {
04:
05: public void writeUnion(UnitedColors union, UnitedColorsHolder unionh) {
06: switch (union.discriminator().value()) {
07: case colorT._blue:
08: System.out.println("Blue: " + union.s());
09: break;
10: case colorT._red:
11: System.out.println("Red: " + union.s());
12: break;
13: case colorT._black:
14: System.out.println("Black: ");
15: String[] strs = union.strs();
16: for (int i = 0; i < strs.length; i++)
17: System.out.println(strs[i]);
18: break;
19: default:
20: System.out.println("default: " + union.i());
21: }
22: UnitedColors new_union = new UnitedColors();
23:
24: // change color and write s.th. back
25:
26: new_union.s(colorT.blue, "This gets back");
27: unionh.value = new_union;
28: }
29:
30: public void write2ndUnion(Nums union) {
31: switch (union.discriminator()) {
32: case 'l':
33: System.out.println("Long ");
34: break;
35: case 'f':
36: System.out.println("Float ");
37: break;
38: default:
39: System.out.println("default: ");
40: }
41: }
42: }
|