1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51:
52: import ;
53:
54:
59: public abstract class DivideableAny
60: extends AbstractAny
61: implements Serializable
62: {
63:
66: private static final long serialVersionUID = 1;
67:
68:
72: protected DynAny[] array;
73:
74:
77: protected int pos = 0;
78:
79: public DivideableAny(TypeCode oType, TypeCode aType,
80: gnuDynAnyFactory aFactory, ORB anOrb
81: )
82: {
83: super(oType, aType, aFactory, anOrb);
84: }
85:
86:
89: public boolean next()
90: {
91: pos++;
92: return array.length > pos;
93: }
94:
95:
98: public void rewind()
99: {
100: pos = 0;
101: }
102:
103:
106: public boolean seek(int p)
107: {
108: pos = p;
109: return pos >= 0 && array.length > pos;
110: }
111:
112:
122: protected DynAny focused()
123: throws InvalidValue, TypeMismatch
124: {
125: if (pos >= 0 && pos < array.length)
126: {
127: if (array [ pos ].component_count() == 0)
128: return array [ pos ];
129: else
130: throw new TypeMismatch("Multiple coponents at " + pos);
131: }
132: else
133: throw new InvalidValue("Out of bounds at " + pos + " valid 0.." +
134: (array.length - 1)
135: );
136: }
137:
138:
139: public int component_count()
140: {
141: return array.length;
142: }
143:
144:
147: public Any get_any()
148: throws TypeMismatch, InvalidValue
149: {
150: return focused().get_any();
151: }
152:
153:
154: public boolean get_boolean()
155: throws TypeMismatch, InvalidValue
156: {
157: return focused().get_boolean();
158: }
159:
160:
161: public char get_char()
162: throws TypeMismatch, InvalidValue
163: {
164: return focused().get_char();
165: }
166:
167:
168: public double get_double()
169: throws TypeMismatch, InvalidValue
170: {
171: return focused().get_double();
172: }
173:
174:
175: public float get_float()
176: throws TypeMismatch, InvalidValue
177: {
178: return focused().get_float();
179: }
180:
181:
182: public int get_long()
183: throws TypeMismatch, InvalidValue
184: {
185: return focused().get_long();
186: }
187:
188:
189: public long get_longlong()
190: throws TypeMismatch, InvalidValue
191: {
192: return focused().get_longlong();
193: }
194:
195:
196: public byte get_octet()
197: throws TypeMismatch, InvalidValue
198: {
199: return focused().get_octet();
200: }
201:
202:
203: public Object get_reference()
204: throws TypeMismatch, InvalidValue
205: {
206: return focused().get_reference();
207: }
208:
209:
210: public short get_short()
211: throws TypeMismatch, InvalidValue
212: {
213: return focused().get_short();
214: }
215:
216:
217: public String get_string()
218: throws TypeMismatch, InvalidValue
219: {
220: return focused().get_string();
221: }
222:
223:
224: public TypeCode get_typecode()
225: throws TypeMismatch, InvalidValue
226: {
227: return focused().get_typecode();
228: }
229:
230:
231: public int get_ulong()
232: throws TypeMismatch, InvalidValue
233: {
234: return focused().get_ulong();
235: }
236:
237:
238: public long get_ulonglong()
239: throws TypeMismatch, InvalidValue
240: {
241: return focused().get_ulonglong();
242: }
243:
244:
245: public short get_ushort()
246: throws TypeMismatch, InvalidValue
247: {
248: return focused().get_ushort();
249: }
250:
251:
252: public Serializable get_val()
253: throws TypeMismatch, InvalidValue
254: {
255: if (pos >= 0 && pos < array.length)
256: {
257: if (array [ pos ] instanceof DynValueCommon)
258: return array [ pos ].get_val();
259: else
260: throw new TypeMismatch();
261: }
262: else
263: throw new InvalidValue("Out of bounds at " + pos + " valid 0.." +
264: (array.length - 1)
265: );
266: }
267:
268:
269: public char get_wchar()
270: throws TypeMismatch, InvalidValue
271: {
272: return focused().get_wchar();
273: }
274:
275:
276: public String get_wstring()
277: throws TypeMismatch, InvalidValue
278: {
279: return focused().get_wstring();
280: }
281:
282:
283: public void insert_any(Any a_x)
284: throws TypeMismatch, InvalidValue
285: {
286: focused().insert_any(a_x);
287: valueChanged();
288: }
289:
290:
291: public void insert_boolean(boolean a_x)
292: throws InvalidValue, TypeMismatch
293: {
294: focused().insert_boolean(a_x);
295: valueChanged();
296: }
297:
298:
299: public void insert_char(char a_x)
300: throws InvalidValue, TypeMismatch
301: {
302: focused().insert_char(a_x);
303: valueChanged();
304: }
305:
306:
307: public void insert_double(double a_x)
308: throws InvalidValue, TypeMismatch
309: {
310: focused().insert_double(a_x);
311: valueChanged();
312: }
313:
314:
315: public void insert_float(float a_x)
316: throws InvalidValue, TypeMismatch
317: {
318: focused().insert_float(a_x);
319: valueChanged();
320: }
321:
322:
323: public void insert_long(int a_x)
324: throws InvalidValue, TypeMismatch
325: {
326: focused().insert_long(a_x);
327: valueChanged();
328: }
329:
330:
331: public void insert_longlong(long a_x)
332: throws InvalidValue, TypeMismatch
333: {
334: focused().insert_longlong(a_x);
335: valueChanged();
336: }
337:
338:
339: public void insert_octet(byte a_x)
340: throws InvalidValue, TypeMismatch
341: {
342: focused().insert_octet(a_x);
343: valueChanged();
344: }
345:
346:
347: public void insert_reference(Object a_x)
348: throws InvalidValue, TypeMismatch
349: {
350: focused().insert_reference(a_x);
351: valueChanged();
352: }
353:
354:
355: public void insert_short(short a_x)
356: throws InvalidValue, TypeMismatch
357: {
358: focused().insert_short(a_x);
359: valueChanged();
360: }
361:
362:
363: public void insert_string(String a_x)
364: throws InvalidValue, TypeMismatch
365: {
366: focused().insert_string(a_x);
367: valueChanged();
368: }
369:
370:
371: public void insert_typecode(TypeCode a_x)
372: throws InvalidValue, TypeMismatch
373: {
374: focused().insert_typecode(a_x);
375: valueChanged();
376: }
377:
378:
379: public void insert_ulong(int a_x)
380: throws InvalidValue, TypeMismatch
381: {
382: focused().insert_ulong(a_x);
383: valueChanged();
384: }
385:
386:
387: public void insert_ulonglong(long a_x)
388: throws InvalidValue, TypeMismatch
389: {
390: focused().insert_ulonglong(a_x);
391: valueChanged();
392: }
393:
394:
395: public void insert_ushort(short a_x)
396: throws InvalidValue, TypeMismatch
397: {
398: focused().insert_ushort(a_x);
399: valueChanged();
400: }
401:
402:
403: public void insert_val(Serializable a_x)
404: throws InvalidValue, TypeMismatch
405: {
406: if (pos >= 0 && pos < array.length)
407: {
408: if (array [ pos ] instanceof DynValueCommon)
409: array [ pos ].insert_val(a_x);
410: else
411: throw new TypeMismatch();
412: }
413: else
414: throw new InvalidValue("Out of bounds at " + pos + " valid 0.." +
415: (array.length - 1)
416: );
417: valueChanged();
418: }
419:
420:
421: public void insert_wchar(char a_x)
422: throws InvalidValue, TypeMismatch
423: {
424: focused().insert_wchar(a_x);
425: valueChanged();
426: }
427:
428:
429: public void insert_wstring(String a_x)
430: throws InvalidValue, TypeMismatch
431: {
432: focused().insert_wstring(a_x);
433: valueChanged();
434: }
435:
436:
437: public DynAny get_dyn_any()
438: throws TypeMismatch, InvalidValue
439: {
440: return focused().get_dyn_any();
441: }
442:
443:
444: public void insert_dyn_any(DynAny insert_it)
445: throws TypeMismatch, InvalidValue
446: {
447: focused().insert_dyn_any(insert_it);
448: }
449:
450:
456: public DynAny current_component()
457: throws TypeMismatch
458: {
459: if (array.length == 0)
460: throw new TypeMismatch("empty");
461: return (pos >= 0 && pos < array.length) ? array [ pos ] : null;
462: }
463:
464:
467: public void destroy()
468: {
469: }
470:
471:
474: public abstract Any to_any()
475: throws TypeMismatch;
476:
477:
481: public boolean equal(DynAny other)
482: {
483: try
484: {
485: if (!official_type.equal(other.type()))
486: return false;
487: else if (other instanceof DivideableAny)
488: {
489: DivideableAny x = (DivideableAny) other;
490: if (x.array.length != array.length)
491: return false;
492:
493: for (int i = 0; i < array.length; i++)
494: {
495: if (!array [ i ].equal(x.array [ i ]))
496: return false;
497: }
498: return true;
499: }
500: else if (other == null || other instanceof AbstractAny)
501: return false;
502: else
503: return other.to_any().equal(to_any());
504: }
505: catch (TypeMismatch e)
506: {
507: UNKNOWN u = new UNKNOWN(MINOR, CompletionStatus.COMPLETED_NO);
508: u.initCause(e);
509: throw u;
510: }
511: }
512: }