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