1 package org.jacorb.test.orb.value; 2 3 import java.util.*; 4 5 import org.omg.CORBA.portable.InputStream ; 6 import org.omg.CORBA.portable.OutputStream ; 7 import org.omg.CORBA.portable.ResponseHandler ; 8 import org.omg.CORBA.Any ; 9 10 public class ValueServerImpl extends ValueServerPOA 11 { 12 public String receive_long (boxedLong p1, boxedLong p2) 13 { 14 if (p1 == null || p2 == null) 15 return "one or two null values"; 16 else if (p1 == p2) 17 return "shared long: " + p1.value; 18 else 19 return "two longs: " + p1.value + ", " + p2.value; 20 } 21 22 public String receive_string (String s1, String s2) 23 { 24 if (s1 == null || s2 == null) 25 return "one or two null values"; 26 else if (s1 == s2) 27 return "shared string: `" + s1 + "'"; 28 else 29 return "two strings: `" + s1 + "', `" + s2 + "'"; 30 } 31 32 33 public String receive_list_in_any(Any any) { 34 Node n = NodeHelper.extract(any); 35 36 return receive_list(n); 37 } 38 39 40 public String receive_list (Node n) 41 { 42 List l = new ArrayList(); 43 Node x = n; 44 boolean shared = false; 45 46 while (x != null) 47 { 48 l.add (x); 49 x = x.next; 50 if (l.contains(x)) 51 { 52 shared = true; 53 break; 54 } 55 } 56 57 StringBuffer result = new StringBuffer ("list of length: " 58 + l.size() + " -- "); 59 for (Iterator i = l.iterator(); i.hasNext();) 60 { 61 Node q = (Node)i.next(); 62 result.append (q.id); 63 if (i.hasNext()) result.append (" "); 64 } 65 66 if (shared) 67 result.append(" -- shared"); 68 69 return result.toString(); 70 } 71 72 public String receive_record_sequence(Record[] list) 73 { 74 StringBuffer result = new StringBuffer ("list of length " + list.length); 75 result.append (", null values: "); 76 for (int i=0; i<list.length; i++) 77 { 78 if (list[i] == null) 79 result.append (i + " "); 80 } 81 for (int i=0; i<list.length/2; i++) 82 { 83 if (list[i] != list[list.length-i-1]) 84 return result.toString() + ", no palindrome"; 85 } 86 return result.toString() + ", palindrome"; 87 } 88 89 public Record[] return_record_sequence(int length) 90 { 91 Record[] result = new Record[length]; 92 for (int i=0; i<result.length; i++) 93 { 94 result[i] = new RecordImpl(i, "node: " + i); 95 } 96 return result; 97 } 98 99 } 100 | Popular Tags |