KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > value > idl > ValueServerImpl


1 package demo.value.idl;
2
3 import java.util.*;
4
5 public class ValueServerImpl extends ValueServerPOA
6 {
7     public String JavaDoc receive_long (boxedLong p1, boxedLong p2)
8     {
9         if (p1 == null || p2 == null)
10             return "one or two null values";
11         else if (p1 == p2)
12             return "shared long: " + p1.value;
13         else
14             return "two longs: " + p1.value + ", " + p2.value;
15     }
16
17     public String JavaDoc receive_string (String JavaDoc s1, String JavaDoc s2)
18     {
19         if (s1 == null || s2 == null)
20             return "one or two null values";
21         else if (s1 == s2)
22             return "shared string: " + s1;
23         else
24             return "two strings: `" + s1 + "', `" + s2 + "'";
25     }
26
27     public String JavaDoc receive_list (Node n)
28     {
29         List l = new ArrayList();
30         Node x = n;
31         
32         while (x != null && !l.contains (x))
33         {
34             l.add (x);
35             x = x.next;
36         }
37
38         StringBuffer JavaDoc result = new StringBuffer JavaDoc ("list of length: "
39                                                 + l.size() + " -- ");
40         for (Iterator i = l.iterator(); i.hasNext();)
41         {
42             Node q = (Node)i.next();
43             result.append (q.id);
44             if (i.hasNext()) result.append (" ");
45         }
46         return result.toString();
47     }
48
49 }
50
Popular Tags