summaryrefslogtreecommitdiff
path: root/java/test/Ice/serialize/InitialI.java
blob: 2f647da5cbd8ccf1dbfd00fa4a817a90fe976a00 (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
// **********************************************************************
//
// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

package test.Ice.serialize;
import test.Ice.serialize.Test.*;
import java.io.*;

public final class InitialI extends _InitialDisp
{
    InitialI(Ice.ObjectAdapter adapter, Ice.Identity ident)
    {
        _s = new Struct1();
        _s.bo = true;
        _s.by = (byte)1;
        _s.sh = (short)2;
        _s.i = 3;
        _s.l = 4;
        _s.f = (float)5.0;
        _s.d = 6.0;
        _s.str = "7";
        _s.e = MyEnum.enum2;
        _s.p = InitialPrxHelper.uncheckedCast(adapter.createProxy(ident));

        _d = new Derived();
        _d.b = _d;
        _d.o = _d;
        _d.s = _s;
        _d.seq1 = new byte[] { 0, 1, 2, 3, 4 };
        _d.seq2 = new int[] { 5, 6, 7, 8, 9 };
        _d.seq3 = new MyEnum[] { MyEnum.enum3, MyEnum.enum2, MyEnum.enum1 };
        _d.seq4 = new Base[] { _d };
        _d.d1 = new java.util.HashMap<Byte, Boolean>();
        _d.d1.put((byte)1, true);
        _d.d2 = new java.util.HashMap<Short, Integer>();
        _d.d2.put((short)2, 3);
        _d.d3 = new java.util.HashMap<String, MyEnum>();
        _d.d3.put("enum3", MyEnum.enum3);
        _d.d4 = new java.util.HashMap<String, Base>();
        _d.d4.put("b", _d);
        _d.p = _s.p;
    }

    public byte[]
    getStruct1(Ice.Current current)
    {
        try
        {
            ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
            ObjectOutputStream stream = new ObjectOutputStream(byteStream);
            stream.writeObject(_s);
            return byteStream.toByteArray();
        }
        catch(IOException ex)
        {
            Ice.UnknownException e = new Ice.UnknownException();
            e.initCause(ex);
            throw e;
        }
    }

    public byte[]
    getBase(Ice.Current current)
    {
        try
        {
            ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
            ObjectOutputStream stream = new ObjectOutputStream(byteStream);
            stream.writeObject(_d);
            return byteStream.toByteArray();
        }
        catch(IOException ex)
        {
            Ice.UnknownException e = new Ice.UnknownException();
            e.initCause(ex);
            throw e;
        }
    }

    public byte[]
    getEx(Ice.Current current)
    {
        try
        {
            Ex ex = new Ex();
            ex.s = _s;
            ex.b = _d;

            ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
            ObjectOutputStream stream = new ObjectOutputStream(byteStream);
            stream.writeObject(ex);
            return byteStream.toByteArray();
        }
        catch(IOException ex)
        {
            Ice.UnknownException e = new Ice.UnknownException();
            e.initCause(ex);
            throw e;
        }
    }

    public void
    shutdown(Ice.Current current)
    {
        current.adapter.getCommunicator().shutdown();
    }

    private Struct1 _s;
    private Derived _d;
}