KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > unions > serverImpl


1 package demo.unions;
2
3 public class serverImpl
4     extends MyServerPOA
5 {
6
7     public void writeUnion(UnitedColors union, UnitedColorsHolder unionh)
8     {
9     switch ( union.discriminator().value() )
10         {
11         case colorT._blue :
12         System.out.println("Blue: " + union.s() );
13         break;
14         case colorT._red :
15         System.out.println("Red: " + union.s() );
16         break;
17         case colorT._black :
18         System.out.println("Black: ");
19         String JavaDoc [] strs = union.strs();
20         for( int i = 0; i < strs.length; i++ )
21             System.out.println(strs[i]);
22         break;
23         default :
24         System.out.println("default: " + union.i() );
25         }
26     UnitedColors new_union = new UnitedColors();
27
28     // change color and write s.th. back
29

30     new_union.s( colorT.blue, "This gets back");
31     unionh.value = new_union;
32     }
33
34
35     public void write2ndUnion(Nums union)
36     {
37     switch ( union.discriminator() )
38         {
39         case 'l' :
40         System.out.println("Long " );
41         break;
42         case 'f' :
43         System.out.println("Float " );
44         break;
45         default :
46         System.out.println("default: " );
47         }
48     }
49 }
50
51
52
Popular Tags