summaryrefslogtreecommitdiff
path: root/TAO/interop-tests/wchar/WChar_PasserImpl.java
blob: 575ba37fbe20cf7d5de4a84ba6799f37feb365ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package interop.wchar;

import org.omg.CORBA.*;
import interop.*;

/**
 * WChar_PasserImpl.java
 *
 * Java implemention of the interoperability tests for wchars.
 *
 * @author Phil Mesnier
 * @version $Id$
 */

public class WChar_PasserImpl
    extends WChar_PasserPOA
{
    private ORB orb;
    private WCharReference ref;

    public WChar_PasserImpl( ORB o, boolean v )
    {
        this.orb = o;
        this.ref = new WCharReference(v);
    }

    public String orb_name ()
    {
        return "JacORB";
    }

    public boolean wchar_to_server (char test, short key)
    {
        System.out.println ("wchar_to_server called, test = " + (int)test
                            + " key = " + key);
        if (key != 0)
            return false;
        return ref.match_wchar(key,test);
    }

    public char wchar_from_server (short key)
    {
        return ref.get_wchar(key);
    }

    public boolean wstring_to_server (String test, short key)
    {
        return ref.match_wstring (key,test);
    }

    public String wstring_from_server (short key)
    {
        return ref.get_wstring (key);
    }

    public boolean warray_to_server (char test[], short key)
    {
        return ref.match_warray (key,test);
    }

    public char[] warray_from_server (short key)
    {
        return ref.get_warray (key);
    }

    public boolean wstruct_to_server (wstruct test, short key)
    {
        return false;
    }

    public wstruct wstruct_from_server (short key)
    {
        return new wstruct();
    }

    public boolean wunion_to_server (wunion test, short key)
    {
        return false;
    }

    public wunion wunion_from_server (short key, wchar_types type)
    {
        return new wunion();
    }

    public boolean any_to_server (Any test, short key)
    {
        int kind =  test.type().kind().value();
        switch( kind )
	{
        case TCKind._tk_wchar:
            return wchar_to_server(test.extract_wchar(),key);
        case TCKind._tk_wstring:
            return wstring_to_server(test.extract_wstring(),key);
        default:
            System.out.println ("WChar_PasserImpl.any_to_server " +
                                kind + " is not an implemented kind");
        }
        return false;
    }

    public Any any_from_server (short key,  wchar_types type)
    {
        Any a = orb.create_any();
        switch (type.value()) {
        case interop.wchar_types._is_wchar:
            a.insert_wchar(ref.get_wchar(key));
            break;
        case interop.wchar_types._is_wstring:
            a.insert_wstring(ref.get_wstring(key));
            break;
        case interop.wchar_types._is_warray:
            break;
        }
        return a;
    }

    public Any any_echo (Any test)
    {
        return test;
    }

    public void exception_test(short key)
        throws interop.WChar_PasserPackage.WStringException
    {
        throw new interop.
            WChar_PasserPackage.
            WStringException(ref.get_except(key),ref.get_wchar(key));
    }

    public void shutdown ()
    {
        orb.shutdown(false);
    }


}