summaryrefslogtreecommitdiff
path: root/java/src/Ice/ObjectImpl.java
blob: 4ee185b34f744f738cf100f86d053055a1d98092 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
// **********************************************************************
//
// Copyright (c) 2001
// Mutable Realms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************

package Ice;

public class ObjectImpl implements Object, java.lang.Cloneable
{
    public
    ObjectImpl()
    {
    }

    public boolean
    equals(java.lang.Object rhs)
    {
        try
        {
            Object r = (Object)rhs;
            return this == r;
        }
        catch(ClassCastException ex)
        {
        }
        return false;
    }

    public java.lang.Object
    clone()
        throws java.lang.CloneNotSupportedException
    {
        //
        // Use super.clone() to perform a shallow copy of all members,
        // and then clone the facets manually.
        //
        ObjectImpl result = (ObjectImpl)super.clone();

        result._activeFacetMap = new java.util.HashMap();
        synchronized(_activeFacetMap)
        {
            if(!_activeFacetMap.isEmpty())
            {
                java.util.Iterator p = _activeFacetMap.entrySet().iterator();
                while(p.hasNext())
                {
                    java.util.Map.Entry e = (java.util.Map.Entry)p.next();
                    Object facet = (Object)e.getValue();
                    result._activeFacetMap.put(e.getKey(), facet.clone());
                }
            }
        }

        return result;
    }

    public int
    ice_hash()
    {
        return hashCode();
    }

    public static String[] __ids =
    {
        "::Ice::Object"
    };

    public boolean
    ice_isA(String s, Current current)
    {
        return s.equals(__ids[0]);
    }

    public static IceInternal.DispatchStatus
    ___ice_isA(Ice.Object __obj, IceInternal.Incoming __in, Current __current)
    {
        IceInternal.BasicStream __is = __in.is();
        IceInternal.BasicStream __os = __in.os();
        String __id = __is.readString();
        boolean __ret = __obj.ice_isA(__id, __current);
        __os.writeBool(__ret);
        return IceInternal.DispatchStatus.DispatchOK;
    }

    public void
    ice_ping(Current current)
    {
        // Nothing to do.
    }

    public static IceInternal.DispatchStatus
    ___ice_ping(Ice.Object __obj, IceInternal.Incoming __in, Current __current)
    {
        __obj.ice_ping(__current);
        return IceInternal.DispatchStatus.DispatchOK;
    }

    public String[]
    ice_ids(Current current)
    {
        return __ids;
    }

    public static IceInternal.DispatchStatus
    ___ice_ids(Ice.Object __obj, IceInternal.Incoming __in, Current __current)
    {
        IceInternal.BasicStream __os = __in.os();
        String[] __ret = __obj.ice_ids(__current);
        __os.writeStringSeq(__ret);
        return IceInternal.DispatchStatus.DispatchOK;
    }

    public String
    ice_id(Current current)
    {
        return __ids[0];
    }

    public static IceInternal.DispatchStatus
    ___ice_id(Ice.Object __obj, IceInternal.Incoming __in, Current __current)
    {
        IceInternal.BasicStream __os = __in.os();
        String __ret = __obj.ice_id(__current);
        __os.writeString(__ret);
        return IceInternal.DispatchStatus.DispatchOK;
    }

    public final String[]
    ice_facets(Current current)
    {
        synchronized(_activeFacetMap)
        {
	    java.util.Set keySet = _activeFacetMap.keySet();
	    String[] v = new String[keySet.size()];
	    keySet.toArray(v);
	    return v;
	}
    }

    public static IceInternal.DispatchStatus
    ___ice_facets(Ice.Object __obj, IceInternal.Incoming __in, Current __current)
    {
        IceInternal.BasicStream __os = __in.os();
        String[] __ret = __obj.ice_facets(__current);
        __os.writeStringSeq(__ret);
        return IceInternal.DispatchStatus.DispatchOK;
    }

    public static String
    ice_staticId()
    {
        return __ids[0];
    }

    private static String[] __all =
    {
        "ice_facets",
        "ice_id",
        "ice_ids",
        "ice_isA",
        "ice_ping"
    };

    public IceInternal.DispatchStatus
    __dispatch(IceInternal.Incoming in, Current current)
    {
        int pos = java.util.Arrays.binarySearch(__all, current.operation);
        if(pos < 0)
        {
            return IceInternal.DispatchStatus.DispatchOperationNotExist;
        }

        switch(pos)
        {
            case 0:
            {
                return ___ice_facets(this, in, current);
            }
            case 1:
            {
                return ___ice_id(this, in, current);
            }
            case 2:
            {
                return ___ice_ids(this, in, current);
            }
            case 3:
            {
                return ___ice_isA(this, in, current);
            }
            case 4:
            {
                return ___ice_ping(this, in, current);
            }
        }

        assert(false);
        return IceInternal.DispatchStatus.DispatchOperationNotExist;
    }

    public void
    __write(IceInternal.BasicStream __os)
    {
        synchronized(_activeFacetMap)
        {
            final int sz = _activeFacetMap.size();
            __os.writeSize(sz);

            java.util.Set set = _activeFacetMap.keySet();
            String[] keys = new String[sz];
            set.toArray(keys);
            for(int i = 0; i < sz; i++)
            {
                __os.writeString(keys[i]);
                __os.writeObject((Object)_activeFacetMap.get(keys[i]));
            }
        }
    }

    public void
    __read(IceInternal.BasicStream __is)
    {
        synchronized(_activeFacetMap)
        {
            int sz = __is.readSize();

            _activeFacetMap.clear();

            while(sz-- > 0)
            {
                String key = __is.readString();
                Object value = __is.readObject("", null);
                _activeFacetMap.put(key, value);
            }
        }
    }

    public void
    __marshal(Ice.Stream __os)
    {
        synchronized(_activeFacetMap)
        {
            final int sz = _activeFacetMap.size();

            __os.startWriteDictionary("ice:facets", sz);
            java.util.Set set = _activeFacetMap.keySet();
            String[] keys = new String[sz];
            set.toArray(keys);
            for(int i = 0; i < sz; i++)
            {
                __os.startWriteDictionaryElement();
                __os.writeString("key", keys[i]);
                __os.writeObject("value", (Object)_activeFacetMap.get(keys[i]));
                __os.endWriteDictionaryElement();
            }
            __os.endWriteDictionary();
        }
    }

    public void
    __unmarshal(Ice.Stream __is)
    {
        synchronized(_activeFacetMap)
        {
            final String facetsName = "ice:facets";
            final String keyName = "key";
            final String valueName = "value";

            int sz = __is.startReadDictionary(facetsName);

            _activeFacetMap.clear();

            while(sz-- > 0)
            {
                __is.startReadDictionaryElement();
                String key = __is.readString(keyName);
                Object value = __is.readObject(valueName, "", null);
                _activeFacetMap.put(key, value);
                __is.endReadDictionaryElement();
            }
            __is.endReadDictionary();
        }
    }

    public final void
    ice_marshal(String name, Ice.Stream stream)
    {
        stream.writeObject(name, this);
    }

    public static Object
    ice_unmarshal(String name, Ice.Stream stream)
    {
        return stream.readObject(name, "", null);
    }

    public final void
    ice_addFacet(Object facet, String name)
    {
        synchronized(_activeFacetMap)
        {
            _activeFacetMap.put(name, facet);
        }
    }

    public final Object
    ice_removeFacet(String name)
    {
        synchronized(_activeFacetMap)
        {
            return (Object)_activeFacetMap.remove(name);
        }
    }

    public final void
    ice_removeAllFacets()
    {
        synchronized(_activeFacetMap)
        {
            _activeFacetMap.clear();
        }
    }

    public final Object
    ice_findFacet(String name)
    {
        synchronized(_activeFacetMap)
        {
            return (Object)_activeFacetMap.get(name);
	}
    }

    public final Object
    ice_findFacetPath(String[] path, int start)
    {
	int sz = path.length;
	
	if(start > sz)
	{
	    return null;
	}
	
	if(start == sz)
	{
	    return this;
	}

	Object f = ice_findFacet(path[start]);
	if(f != null)
	{
	    return f.ice_findFacetPath(path, start + 1);
	}
	else
	{
	    return f;
        }
    }

    private java.util.HashMap _activeFacetMap = new java.util.HashMap();
}