3 import org
.omg
.CORBA
.*;
7 * WChar_PasserImpl.java
9 * Java implemention of the interoperability tests for wchars.
11 * @author Phil Mesnier
15 public class WChar_PasserImpl
16 extends WChar_PasserPOA
19 private WCharReference ref
;
21 public WChar_PasserImpl( ORB o
, boolean v
)
24 this.ref
= new WCharReference(v
);
27 public String
orb_name ()
29 // we don't really know, eh?
33 public boolean wchar_to_server (char test
, short key
)
35 System
.out
.println ("wchar_to_server called, test = " + (int)test
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
)
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);
89 System
.out
.println ("wstructseq_to_server FAILED entry " + i
);
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
);
106 public boolean wunion_to_server (wunion test
, short key
)
111 public wunion
wunion_from_server (short key
, wchar_types type
)
116 public boolean any_to_server (Any test
, short key
)
118 int kind
= test
.type().kind().value();
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
);
126 System
.out
.println ("WChar_PasserImpl.any_to_server " +
127 kind
+ " is not an implemented kind");
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
));
139 case interop
.wchar_types
._is_wstring
:
140 a
.insert_wstring(ref
.get_wstring(key
));
142 case interop
.wchar_types
._is_warray
:
148 public Any
any_echo (Any test
)
153 public void exception_test(short key
)
154 throws interop
.WChar_PasserPackage
.WStringException
158 WStringException(ref
.get_except(key
),ref
.get_wchar(key
));
161 public void shutdown ()
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
));
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());