Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / interop-tests / wchar / WChar_PasserImpl.java
blob1136df15fa0ae9aa8762ae4c05883fbb43718b04
1 package interop.wchar;
3 import org.omg.CORBA.*;
4 import interop.*;
6 /**
7 * WChar_PasserImpl.java
9 * Java implemention of the interoperability tests for wchars.
11 * @author Phil Mesnier
12 * @version
15 public class WChar_PasserImpl
16 extends WChar_PasserPOA
18 private ORB orb;
19 private WCharReference ref;
21 public WChar_PasserImpl( ORB o, boolean v )
23 this.orb = o;
24 this.ref = new WCharReference(v);
27 public String orb_name ()
29 // we don't really know, eh?
30 return "Java ORB";
33 public boolean wchar_to_server (char test, short key)
35 System.out.println ("wchar_to_server called, test = " + (int)test
36 + " key = " + key);
37 if (key != 0)
38 return false;
39 return ref.match_wchar(key,test);
42 public char wchar_from_server (short key)
44 return ref.get_wchar(key);
47 public boolean wstring_to_server (String test, short key)
49 return ref.match_wstring (key,test);
52 public String wstring_from_server (short key)
54 return ref.get_wstring (key);
57 public boolean warray_to_server (char test[], short key)
59 return ref.match_warray (key,test);
62 public char[] warray_from_server (short key)
64 return ref.get_warray (key);
67 public boolean wstruct_to_server (wstruct test, short key)
69 return match_wstruct (key, test);
72 public wstruct wstruct_from_server (short key)
74 return new wstruct();
77 public boolean wstructseq_to_server (wstruct[] test, short key)
79 boolean result = true;
80 System.out.println ("wstructseq_to_server called, key = " + key);
81 for (int i = 0; i < test.length; i++)
83 if (wstruct_to_server(test[i],key))
85 // System.out.println ("wstructseq_to_server passed entry " + i);
87 else
89 System.out.println ("wstructseq_to_server FAILED entry " + i);
90 result = false;
93 return result;
96 public wstruct[] wstructseq_from_server (short key)
98 wstruct[] wsList = new wstruct[5];
99 for (int i = 0; i < wsList.length; i++)
101 wsList[i] = get_wstruct(key);
103 return wsList;
106 public boolean wunion_to_server (wunion test, short key)
108 return false;
111 public wunion wunion_from_server (short key, wchar_types type)
113 return new wunion();
116 public boolean any_to_server (Any test, short key)
118 int kind = test.type().kind().value();
119 switch( kind )
121 case TCKind._tk_wchar:
122 return wchar_to_server(test.extract_wchar(),key);
123 case TCKind._tk_wstring:
124 return wstring_to_server(test.extract_wstring(),key);
125 default:
126 System.out.println ("WChar_PasserImpl.any_to_server " +
127 kind + " is not an implemented kind");
129 return false;
132 public Any any_from_server (short key, wchar_types type)
134 Any a = orb.create_any();
135 switch (type.value()) {
136 case interop.wchar_types._is_wchar:
137 a.insert_wchar(ref.get_wchar(key));
138 break;
139 case interop.wchar_types._is_wstring:
140 a.insert_wstring(ref.get_wstring(key));
141 break;
142 case interop.wchar_types._is_warray:
143 break;
145 return a;
148 public Any any_echo (Any test)
150 return test;
153 public void exception_test(short key)
154 throws interop.WChar_PasserPackage.WStringException
156 throw new interop.
157 WChar_PasserPackage.
158 WStringException(ref.get_except(key),ref.get_wchar(key));
161 public void shutdown ()
163 orb.shutdown(false);
166 // TODO: this should have a home where it's accessable to both
167 // client & server, but it doesn't belong in WCharReference
168 public wstruct get_wstruct (short key)
170 wstruct result = new wstruct();
172 result.st_char = ref.get_wchar(key);
173 result.st_string = ref.get_wstring(key);
174 result.st_array = ref.get_warray(key);
175 result.st_any = orb.create_any();
176 result.st_any.insert_wstring(ref.get_wstring(key));
178 return result;
181 // TODO: this should have a home where it's accessable to both
182 // client & server, but it doesn't belong in WCharReference
183 public boolean match_wstruct (short key, wstruct test )
185 boolean result = ref.match_wchar(key, test.st_char);
186 result &= ref.match_wstring(key, test.st_string);
187 result &= ref.match_warray(key, test.st_array);
188 // @@ todo result &= ref.match_wstring (key, test.st_any.extract_wstring());
189 return result;