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: import ;
52: import ;
53:
54: import ;
55: import ;
56: import ;
57: import ;
58: import ;
59: import ;
60: import ;
61: import ;
62: import ;
63: import ;
64: import ;
65: import ;
66: import ;
67: import ;
68: import ;
69: import ;
70: import ;
71: import ;
72: import ;
73: import ;
74: import ;
75: import ;
76:
77: import ;
78: import ;
79: import ;
80: import ;
81:
82: import ;
83:
84:
98: public abstract class AbstractCdrInput
99: extends org.omg.CORBA_2_3.portable.InputStream
100: implements org.omg.CORBA.DataInputStream
101: {
102:
106: public transient gnuRuntime runtime;
107:
108:
113: protected static final String UNEXP_EOF = "Unexpected end of stream";
114:
115:
119: protected AbstractDataInput b;
120:
121:
124: protected java.io.InputStream actual_stream;
125:
126:
129: protected ORB orb;
130:
131:
134: protected Version giop = new Version(1, 2);
135:
136:
139: protected CodeSetServiceContext codeset = CodeSetServiceContext.STANDARD;
140:
141:
145: private String narrow_charset = null;
146:
147:
151: private String wide_charset = null;
152:
153:
158: private boolean narrow_native;
159:
160:
165: private boolean wide_native;
166:
167:
172: private boolean little_endian;
173:
174:
179: public AbstractCdrInput(java.io.InputStream readFrom)
180: {
181: setInputStream(readFrom);
182: setCodeSet(CodeSetServiceContext.STANDARD);
183: }
184:
185:
189: public AbstractCdrInput()
190: {
191: setCodeSet(CodeSetServiceContext.STANDARD);
192: }
193:
194:
202: public void setBigEndian(boolean use_big_endian)
203: {
204: little_endian = !use_big_endian;
205: setInputStream(actual_stream);
206: }
207:
208:
213: public boolean isBigEndian()
214: {
215: return !little_endian;
216: }
217:
218:
221: public void cloneSettings(AbstractCdrInput stream)
222: {
223: stream.setBigEndian(isBigEndian());
224: stream.setCodeSet(getCodeSet());
225: stream.setVersion(giop);
226: stream.setOrb(orb);
227: }
228:
229:
234: public void setInputStream(java.io.InputStream readFrom)
235: {
236: if (little_endian)
237: b = new LittleEndianInputStream(readFrom);
238: else
239: b = new BigEndianInputStream(readFrom);
240:
241: actual_stream = readFrom;
242: }
243:
244:
248: public abstract void setOffset(int offset);
249:
250:
255: public void setOrb(ORB an_orb)
256: {
257: orb = an_orb;
258: }
259:
260:
264: public void setVersion(Version giop_version)
265: {
266: giop = giop_version;
267: }
268:
269:
272: public abstract void align(int boundary);
273:
274:
278: public long gnu_read_ulong()
279: {
280: try
281: {
282: long l = b.readInt();
283: l &= 0xFFFFFFF;
284: return l;
285: }
286: catch (EOFException ex)
287: {
288: MARSHAL t = new MARSHAL(UNEXP_EOF);
289: t.minor = Minor.EOF;
290: t.initCause(ex);
291: throw t;
292: }
293: catch (IOException ex)
294: {
295: throw new Unexpected(ex);
296: }
297: }
298:
299:
303: public int gnu_read_ushort()
304: {
305: try
306: {
307: align(2);
308: return b.readUnsignedShort();
309: }
310: catch (EOFException ex)
311: {
312: MARSHAL t = new MARSHAL(UNEXP_EOF);
313: t.minor = Minor.EOF;
314: t.initCause(ex);
315: throw t;
316: }
317:
318: catch (IOException ex)
319: {
320: throw new Unexpected(ex);
321: }
322: }
323:
324:
329: public ORB orb()
330: {
331: return orb;
332: }
333:
334:
337: public int read()
338: throws java.io.IOException
339: {
340: try
341: {
342: return b.read();
343: }
344: catch (EOFException ex)
345: {
346: MARSHAL t = new MARSHAL(UNEXP_EOF);
347: t.minor = Minor.EOF;
348: t.initCause(ex);
349: throw t;
350: }
351: }
352:
353:
356: public int read(byte[] x, int ofs, int len)
357: throws java.io.IOException
358: {
359: try
360: {
361: return b.read(x, ofs, len);
362: }
363: catch (EOFException ex)
364: {
365: MARSHAL t = new MARSHAL(UNEXP_EOF);
366: t.minor = Minor.EOF;
367: t.initCause(ex);
368: throw t;
369: }
370: }
371:
372:
375: public int read(byte[] x)
376: throws java.io.IOException
377: {
378: try
379: {
380: return b.read(x);
381: }
382: catch (EOFException ex)
383: {
384: MARSHAL t = new MARSHAL(UNEXP_EOF);
385: t.minor = Minor.EOF;
386: t.initCause(ex);
387: throw t;
388: }
389: }
390:
391:
406: public org.omg.CORBA.Object read_Object()
407: {
408: try
409: {
410: IOR ior = new IOR();
411: ior._read_no_endian(this);
412:
413: if (ior.Id == null)
414: return null;
415:
416:
417:
418:
419: if (orb instanceof OrbFunctional)
420: {
421: OrbFunctional forb = (OrbFunctional) orb;
422: org.omg.CORBA.Object local = forb.find_local_object(ior);
423: if (local != null)
424: return local;
425: }
426:
427:
428: ObjectImpl impl = StubLocator.search(orb, ior);
429: try
430: {
431: if (impl._get_delegate() == null)
432: impl._set_delegate(new IorDelegate(orb, ior));
433: }
434: catch (BAD_OPERATION ex)
435: {
436:
437:
438: impl._set_delegate(new IorDelegate(orb, ior));
439: }
440:
441: return impl;
442: }
443: catch (IOException ex)
444: {
445: MARSHAL bad = new MARSHAL();
446: bad.minor = Minor.IOR;
447: bad.initCause(ex);
448: throw bad;
449: }
450: }
451:
452:
456: public TypeCode read_TypeCode()
457: {
458: try
459: {
460: return TypeCodeHelper.read(this);
461: }
462:
463: catch (Bounds ex)
464: {
465: throw new Unexpected();
466: }
467: catch (BadKind ex)
468: {
469: throw new Unexpected();
470: }
471: }
472:
473:
477: public Any read_any()
478: {
479: TypeCode ty = read_TypeCode();
480: gnuAny any = new gnuAny();
481: any.read_value(this, ty);
482: return any;
483: }
484:
485:
488: public boolean read_boolean()
489: {
490: try
491: {
492: return b.read() == 0 ? false : true;
493: }
494: catch (EOFException ex)
495: {
496: MARSHAL t = new MARSHAL(UNEXP_EOF);
497: t.minor = Minor.EOF;
498: t.initCause(ex);
499: throw t;
500: }
501: catch (IOException ex)
502: {
503: throw new Unexpected(ex);
504: }
505: }
506:
507:
510: public void read_boolean_array(boolean[] x, int offs, int len)
511: {
512: try
513: {
514: for (int i = offs; i < offs + len; i++)
515: {
516: x[i] = b.read() == 0 ? false : true;
517: }
518: }
519: catch (EOFException ex)
520: {
521: MARSHAL t = new MARSHAL(UNEXP_EOF);
522: t.minor = Minor.EOF;
523: t.initCause(ex);
524: throw t;
525: }
526:
527: catch (IOException ex)
528: {
529: throw new Unexpected(ex);
530: }
531: }
532:
533:
537: public char read_char()
538: {
539: try
540: {
541: if (narrow_native)
542: return (char) b.read();
543: else
544: return (char) new InputStreamReader((InputStream) b, narrow_charset).read();
545: }
546: catch (EOFException ex)
547: {
548: MARSHAL t = new MARSHAL(UNEXP_EOF);
549: t.minor = Minor.EOF;
550: t.initCause(ex);
551: throw t;
552: }
553:
554: catch (IOException ex)
555: {
556: throw new Unexpected(ex);
557: }
558: }
559:
560:
563: public void read_char_array(char[] x, int offset, int length)
564: {
565: try
566: {
567: if (narrow_native)
568: {
569: for (int i = offset; i < offset + length; i++)
570: x[i] = (char) b.read();
571: }
572: else
573: {
574: InputStreamReader reader = new InputStreamReader((InputStream) b,
575: narrow_charset);
576: reader.read(x, offset, length);
577: }
578: }
579: catch (EOFException ex)
580: {
581: MARSHAL t = new MARSHAL(UNEXP_EOF);
582: t.minor = Minor.EOF;
583: t.initCause(ex);
584: throw t;
585: }
586:
587: catch (IOException ex)
588: {
589: throw new Unexpected(ex);
590: }
591: }
592:
593:
596: public double read_double()
597: {
598: try
599: {
600: align(8);
601: return b.readDouble();
602: }
603: catch (EOFException ex)
604: {
605: MARSHAL t = new MARSHAL(UNEXP_EOF);
606: t.minor = Minor.EOF;
607: t.initCause(ex);
608: throw t;
609: }
610:
611: catch (IOException ex)
612: {
613: throw new Unexpected();
614: }
615: }
616:
617:
620: public void read_double_array(double[] x, int offs, int len)
621: {
622: try
623: {
624: align(8);
625: for (int i = offs; i < offs + len; i++)
626: {
627: x[i] = b.readDouble();
628: }
629: }
630: catch (EOFException ex)
631: {
632: MARSHAL t = new MARSHAL(UNEXP_EOF);
633: t.minor = Minor.EOF;
634: t.initCause(ex);
635: throw t;
636: }
637:
638: catch (IOException ex)
639: {
640: throw new Unexpected(ex);
641: }
642: }
643:
644:
649: public BufferredCdrInput read_encapsulation()
650: {
651: try
652: {
653: int l = read_long();
654:
655: byte[] r = new byte[l];
656: int n = 0;
657: while (n < r.length)
658: {
659: n += read(r, n, r.length - n);
660: }
661:
662: BufferredCdrInput capsule = new BufferredCdrInput(r);
663: capsule.setOrb(orb);
664:
665: int endian = capsule.read_octet();
666:
667: if (endian != 0)
668: {
669: capsule.setBigEndian(false);
670: }
671:
672: return capsule;
673: }
674: catch (EOFException ex)
675: {
676: MARSHAL t = new MARSHAL(UNEXP_EOF);
677: t.minor = Minor.EOF;
678: t.initCause(ex);
679: throw t;
680: }
681:
682: catch (IOException ex)
683: {
684: throw new Unexpected(ex);
685: }
686: }
687:
688:
692: public BigDecimal read_fixed()
693: {
694: try
695: {
696: return BigDecimalHelper.read(this, 0);
697: }
698: catch (EOFException ex)
699: {
700: MARSHAL t = new MARSHAL(UNEXP_EOF);
701: t.minor = Minor.EOF;
702: t.initCause(ex);
703: throw t;
704: }
705:
706: catch (IOException ex)
707: {
708: throw new Unexpected(ex);
709: }
710: }
711:
712:
715: public float read_float()
716: {
717: try
718: {
719: align(4);
720: return b.readFloat();
721: }
722: catch (EOFException ex)
723: {
724: MARSHAL t = new MARSHAL(UNEXP_EOF);
725: t.minor = Minor.EOF;
726: t.initCause(ex);
727: throw t;
728: }
729:
730: catch (IOException ex)
731: {
732: throw new Unexpected(ex);
733: }
734: }
735:
736:
739: public void read_float_array(float[] x, int offs, int len)
740: {
741: try
742: {
743: align(4);
744: for (int i = offs; i < offs + len; i++)
745: {
746: x[i] = b.readFloat();
747: }
748: }
749: catch (EOFException ex)
750: {
751: MARSHAL t = new MARSHAL(UNEXP_EOF);
752: t.minor = Minor.EOF;
753: t.initCause(ex);
754: throw t;
755: }
756:
757: catch (IOException ex)
758: {
759: throw new Unexpected(ex);
760: }
761: }
762:
763:
766: public int read_long()
767: {
768: try
769: {
770: align(4);
771: return b.readInt();
772: }
773: catch (EOFException ex)
774: {
775: MARSHAL t = new MARSHAL(UNEXP_EOF);
776: t.minor = Minor.EOF;
777: t.initCause(ex);
778: throw t;
779: }
780:
781: catch (IOException ex)
782: {
783: throw new Unexpected(ex);
784: }
785: }
786:
787:
790: public void read_long_array(int[] x, int offs, int len)
791: {
792: try
793: {
794: align(4);
795: for (int i = offs; i < offs + len; i++)
796: {
797: x[i] = b.readInt();
798: }
799: }
800: catch (EOFException ex)
801: {
802: MARSHAL t = new MARSHAL(UNEXP_EOF);
803: t.minor = Minor.EOF;
804: t.initCause(ex);
805: throw t;
806: }
807:
808: catch (IOException ex)
809: {
810: throw new Unexpected(ex);
811: }
812: }
813:
814:
817: public long read_longlong()
818: {
819: try
820: {
821: align(8);
822: return b.readLong();
823: }
824: catch (EOFException ex)
825: {
826: MARSHAL t = new MARSHAL(UNEXP_EOF);
827: t.minor = Minor.EOF;
828: throw t;
829: }
830:
831: catch (IOException ex)
832: {
833: throw new Unexpected(ex);
834: }
835: }
836:
837:
840: public void read_longlong_array(long[] x, int offs, int len)
841: {
842: try
843: {
844: align(8);
845: for (int i = offs; i < offs + len; i++)
846: {
847: x[i] = b.readLong();
848: }
849: }
850: catch (EOFException ex)
851: {
852: MARSHAL t = new MARSHAL(UNEXP_EOF);
853: t.minor = Minor.EOF;
854: t.initCause(ex);
855: throw t;
856: }
857:
858: catch (IOException ex)
859: {
860: throw new Unexpected(ex);
861: }
862: }
863:
864:
867: public byte read_octet()
868: {
869: try
870: {
871: return b.readByte();
872: }
873: catch (EOFException ex)
874: {
875: MARSHAL t = new MARSHAL(UNEXP_EOF);
876: t.minor = Minor.EOF;
877: t.initCause(ex);
878: throw t;
879: }
880:
881: catch (IOException ex)
882: {
883: throw new Unexpected(ex);
884: }
885: }
886:
887:
890: public void read_octet_array(byte[] x, int offs, int len)
891: {
892: try
893: {
894: b.read(x, offs, len);
895: }
896: catch (EOFException ex)
897: {
898: MARSHAL t = new MARSHAL(UNEXP_EOF);
899: t.minor = Minor.EOF;
900: t.initCause(ex);
901: throw t;
902: }
903:
904: catch (IOException ex)
905: {
906: throw new Unexpected(ex);
907: }
908: }
909:
910:
913: public byte[] read_sequence()
914: {
915: try
916: {
917: int l = read_long();
918: byte[] buf = new byte[l];
919: if (l > 0)
920: {
921: b.readFully(buf);
922: }
923: return buf;
924: }
925: catch (EOFException ex)
926: {
927: MARSHAL t = new MARSHAL(UNEXP_EOF);
928: t.minor = Minor.EOF;
929: t.initCause(ex);
930: throw t;
931: }
932:
933: catch (IOException ex)
934: {
935: throw new Unexpected(ex);
936: }
937: }
938:
939:
942: public short read_short()
943: {
944: try
945: {
946: align(2);
947: return b.readShort();
948: }
949: catch (EOFException ex)
950: {
951: MARSHAL t = new MARSHAL(UNEXP_EOF);
952: t.minor = Minor.EOF;
953: t.initCause(ex);
954: throw t;
955: }
956:
957: catch (IOException ex)
958: {
959: throw new Unexpected(ex);
960: }
961: }
962:
963:
966: public void read_short_array(short[] x, int offs, int len)
967: {
968: try
969: {
970: align(2);
971: for (int i = offs; i < offs + len; i++)
972: {
973: x[i] = b.readShort();
974: }
975: }
976: catch (EOFException ex)
977: {
978: MARSHAL t = new MARSHAL(UNEXP_EOF);
979: t.minor = Minor.EOF;
980: t.initCause(ex);
981: throw t;
982: }
983:
984: catch (IOException ex)
985: {
986: throw new Unexpected(ex);
987: }
988: }
989:
990:
997: public String read_string()
998: {
999: int n = 0;
1000: try
1001: {
1002: align(4);
1003:
1004: n = b.readInt();
1005: byte[] s = new byte[n];
1006: b.read(s);
1007:
1008:
1009: if (narrow_charset == null)
1010: return new String(s, 0, n - 1);
1011: else
1012: return new String(s, 0, n - 1, narrow_charset);
1013: }
1014: catch (EOFException ex)
1015: {
1016: MARSHAL t = new MARSHAL(UNEXP_EOF);
1017: t.minor = Minor.EOF;
1018: t.initCause(ex);
1019: throw t;
1020: }
1021: catch (IOException ex)
1022: {
1023: throw new Unexpected();
1024: }
1025: catch (NegativeArraySizeException nex)
1026: {
1027: MARSHAL m = new MARSHAL("Input stream broken, got " + n + "(0x"
1028: + Integer.toHexString(n) + ") as a string size");
1029: m.minor = Minor.Negative;
1030: throw m;
1031: }
1032: }
1033:
1034:
1038: public int read_ulong()
1039: {
1040: return read_long();
1041: }
1042:
1043:
1047: public void read_ulong_array(int[] x, int offs, int len)
1048: {
1049: read_long_array(x, offs, len);
1050: }
1051:
1052:
1057: public long read_ulonglong()
1058: {
1059: return read_longlong();
1060: }
1061:
1062:
1066: public void read_ulonglong_array(long[] x, int offs, int len)
1067: {
1068: read_longlong_array(x, offs, len);
1069: }
1070:
1071:
1076: public short read_ushort()
1077: {
1078: return read_short();
1079: }
1080:
1081:
1085: public void read_ushort_array(short[] x, int offs, int len)
1086: {
1087: read_short_array(x, offs, len);
1088: }
1089:
1090:
1093: public char read_wchar()
1094: {
1095: try
1096: {
1097: if (giop.until_inclusive(1, 1))
1098: {
1099: align(2);
1100:
1101: if (wide_native)
1102: return (char) b.readShort();
1103: else
1104: return (char) new InputStreamReader((InputStream) b, wide_charset).read();
1105: }
1106: else
1107: {
1108: int l = b.read();
1109: if (l == 2 && wide_native)
1110: return b.readChar();
1111: else if (l <= 0)
1112: {
1113: MARSHAL m = new MARSHAL("wchar size " + l);
1114: m.minor = Minor.Negative;
1115: throw m;
1116: }
1117: else
1118: {
1119: byte[] bytes = new byte[l];
1120: b.readFully(bytes);
1121: String cs;
1122:
1123: if (bytes.length > 2 && bytes[0] == 0xFE && bytes[1] == 0xFF)
1124: cs = new String(bytes, 2, bytes.length - 2, wide_charset);
1125: else if (bytes.length > 2 && bytes[0] == 0xFF
1126: && bytes[1] == 0xFE)
1127: {
1128:
1129: byte t;
1130: for (int i = 3; i < bytes.length; i = i + 2)
1131: {
1132: t = bytes[i];
1133: bytes[i - 1] = bytes[i];
1134: bytes[i] = t;
1135: }
1136: cs = new String(bytes, 2, bytes.length - 2, wide_charset);
1137: }
1138: else
1139: cs = new String(bytes, wide_charset);
1140:
1141: return cs.charAt(0);
1142: }
1143: }
1144: }
1145: catch (EOFException ex)
1146: {
1147: MARSHAL t = new MARSHAL(UNEXP_EOF);
1148: t.minor = Minor.EOF;
1149: t.initCause(ex);
1150: throw t;
1151: }
1152: catch (IOException ex)
1153: {
1154: throw new Unexpected();
1155: }
1156: }
1157:
1158:
1162: public void read_wchar_array(char[] x, int offset, int length)
1163: {
1164: try
1165: {
1166: if (giop.until_inclusive(1, 1))
1167: align(2);
1168:
1169: if (wide_native)
1170: {
1171: for (int i = offset; i < offset + length; i++)
1172: x[i] = (char) b.readShort();
1173: }
1174: else
1175: {
1176: InputStreamReader reader = new InputStreamReader((InputStream) b,
1177: wide_charset);
1178: reader.read(x, offset, length);
1179: }
1180: }
1181: catch (EOFException ex)
1182: {
1183: MARSHAL t = new MARSHAL(UNEXP_EOF);
1184: t.minor = Minor.EOF;
1185: t.initCause(ex);
1186: throw t;
1187: }
1188:
1189: catch (IOException ex)
1190: {
1191: throw new Unexpected(ex);
1192: }
1193: }
1194:
1195:
1202: public String read_wstring()
1203: {
1204:
1205: if (wide_native || giop.until_inclusive(1, 1))
1206: return read_wstring_UTF_16();
1207: try
1208: {
1209: align(4);
1210:
1211: int n = b.readInt();
1212: byte[] s = new byte[n];
1213: b.read(s);
1214:
1215: return new String(s, 0, n, wide_charset);
1216: }
1217: catch (EOFException ex)
1218: {
1219: MARSHAL t = new MARSHAL(UNEXP_EOF);
1220: t.minor = Minor.EOF;
1221: t.initCause(ex);
1222: throw t;
1223: }
1224:
1225: catch (IOException ex)
1226: {
1227: throw new Unexpected(ex);
1228: }
1229: }
1230:
1231:
1236: public String read_wstring_UTF_16()
1237: {
1238: try
1239: {
1240: int p = 0;
1241: int n = read_long();
1242:
1243: if (n<0)
1244: {
1245: MARSHAL m = new MARSHAL("Negative string size");
1246: m.minor = Minor.Negative;
1247: throw m;
1248: }
1249:
1250:
1251: int nt = giop.since_inclusive(1, 2) ? 0 : 1;
1252:
1253:
1254: n = n / 2;
1255:
1256:
1257: if (n == 0)
1258: return "";
1259:
1260: char[] s = new char[n];
1261:
1262: for (int i = 0; i < s.length; i++)
1263: s[i] = (char) b.readShort();
1264:
1265:
1266: if (s[0] == 0xFEFF)
1267: {
1268:
1269:
1270: p = 1;
1271: }
1272: else if (s[0] == 0xFFFE)
1273: {
1274:
1275:
1276: p = 1;
1277:
1278: for (int i = p; i < s.length; i++)
1279: s[i] = swap(s[i]);
1280: }
1281:
1282:
1283: String r = new String(s, p, n - nt - p);
1284: return r;
1285: }
1286: catch (EOFException ex)
1287: {
1288: MARSHAL t = new MARSHAL(UNEXP_EOF);
1289: t.minor = Minor.EOF;
1290: t.initCause(ex);
1291: throw t;
1292: }
1293:
1294: catch (IOException ex)
1295: {
1296: throw new Unexpected(ex);
1297: }
1298: }
1299:
1300:
1303: public static char swap(char x)
1304: {
1305: int hi;
1306: int lo;
1307:
1308: lo = x & 0xFF;
1309: hi = (x >> 8) & 0xFF;
1310:
1311: return (char) ((lo << 8) | hi);
1312: }
1313:
1314:
1317: public void setCodeSet(CodeSetServiceContext a_codeset)
1318: {
1319: this.codeset = a_codeset;
1320: narrow_charset = CharSets_OSF.getName(codeset.char_data);
1321: wide_charset = CharSets_OSF.getName(codeset.wide_char_data);
1322:
1323: narrow_native = CharSets_OSF.NATIVE_CHARACTER == codeset.char_data;
1324: wide_native = CharSets_OSF.NATIVE_WIDE_CHARACTER == codeset.wide_char_data;
1325: }
1326:
1327:
1330: public CodeSetServiceContext getCodeSet()
1331: {
1332: return codeset;
1333: }
1334:
1335:
1344: public org.omg.CORBA.Object read_Object(Class klass)
1345: {
1346: return read_Object();
1347: }
1348:
1349:
1358: public Serializable read_Value()
1359: {
1360: return read_value();
1361: }
1362:
1363:
1373: public java.lang.Object read_Abstract()
1374: {
1375: return read_abstract_interface();
1376: }
1377:
1378:
1384: public void read_char_array(CharSeqHolder holder, int offset, int length)
1385: {
1386: holder.value = ensureArray(holder.value, offset, length);
1387: read_char_array(holder.value, offset, length);
1388: }
1389:
1390:
1396: public void read_wchar_array(WCharSeqHolder holder, int offset, int length)
1397: {
1398: holder.value = ensureArray(holder.value, offset, length);
1399: read_wchar_array(holder.value, offset, length);
1400: }
1401:
1402:
1413: private char[] ensureArray(char[] holder_value, int offset, int length)
1414: {
1415: if (holder_value == null)
1416: return new char[offset + length];
1417: else if (holder_value.length < offset + length)
1418: {
1419: char[] value = new char[offset + length];
1420: System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1421: return value;
1422: }
1423: else
1424: return holder_value;
1425: }
1426:
1427:
1433: public void read_ulong_array(ULongSeqHolder holder, int offset, int length)
1434: {
1435: holder.value = ensureArray(holder.value, offset, length);
1436: read_ulong_array(holder.value, offset, length);
1437: }
1438:
1439:
1445: public void read_long_array(LongSeqHolder holder, int offset, int length)
1446: {
1447: holder.value = ensureArray(holder.value, offset, length);
1448: read_ulong_array(holder.value, offset, length);
1449: }
1450:
1451:
1461: private int[] ensureArray(int[] holder_value, int offset, int length)
1462: {
1463: if (holder_value == null)
1464: return new int[offset + length];
1465: else if (holder_value.length < offset + length)
1466: {
1467: int[] value = new int[offset + length];
1468: System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1469: return value;
1470: }
1471: else
1472: return holder_value;
1473: }
1474:
1475:
1481: public void read_float_array(FloatSeqHolder holder, int offset, int length)
1482: {
1483: holder.value = ensureArray(holder.value, offset, length);
1484: read_float_array(holder.value, offset, length);
1485: }
1486:
1487:
1498: private float[] ensureArray(float[] holder_value, int offset, int length)
1499: {
1500: if (holder_value == null)
1501: return new float[offset + length];
1502: else if (holder_value.length < offset + length)
1503: {
1504: float[] value = new float[offset + length];
1505: System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1506: return value;
1507: }
1508: else
1509: return holder_value;
1510: }
1511:
1512:
1518: public void read_double_array(DoubleSeqHolder holder, int offset, int length)
1519: {
1520: holder.value = ensureArray(holder.value, offset, length);
1521: read_double_array(holder.value, offset, length);
1522: }
1523:
1524:
1535: private double[] ensureArray(double[] holder_value, int offset, int length)
1536: {
1537: if (holder_value == null)
1538: return new double[offset + length];
1539: else if (holder_value.length < offset + length)
1540: {
1541: double[] value = new double[offset + length];
1542: System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1543: return value;
1544: }
1545: else
1546: return holder_value;
1547: }
1548:
1549:
1555: public void read_short_array(ShortSeqHolder holder, int offset, int length)
1556: {
1557: holder.value = ensureArray(holder.value, offset, length);
1558: read_short_array(holder.value, offset, length);
1559: }
1560:
1561:
1562: public void read_ushort_array(UShortSeqHolder holder, int offset, int length)
1563: {
1564: holder.value = ensureArray(holder.value, offset, length);
1565: read_ushort_array(holder.value, offset, length);
1566: }
1567:
1568:
1579: private short[] ensureArray(short[] holder_value, int offset, int length)
1580: {
1581: if (holder_value == null)
1582: return new short[offset + length];
1583: else if (holder_value.length < offset + length)
1584: {
1585: short[] value = new short[offset + length];
1586: System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1587: return value;
1588: }
1589: else
1590: return holder_value;
1591: }
1592:
1593:
1599: public void read_octet_array(OctetSeqHolder holder, int offset, int length)
1600: {
1601: holder.value = ensureArray(holder.value, offset, length);
1602: read_octet_array(holder.value, offset, length);
1603: }
1604:
1605:
1616: private byte[] ensureArray(byte[] holder_value, int offset, int length)
1617: {
1618: if (holder_value == null)
1619: return new byte[offset + length];
1620: else if (holder_value.length < offset + length)
1621: {
1622: byte[] value = new byte[offset + length];
1623: System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1624: return value;
1625: }
1626: else
1627: return holder_value;
1628: }
1629:
1630:
1636: public void read_longlong_array(LongLongSeqHolder holder, int offset,
1637: int length)
1638: {
1639: holder.value = ensureArray(holder.value, offset, length);
1640: read_longlong_array(holder.value, offset, length);
1641: }
1642:
1643:
1649: public void read_ulonglong_array(ULongLongSeqHolder holder, int offset,
1650: int length)
1651: {
1652: holder.value = ensureArray(holder.value, offset, length);
1653: read_ulonglong_array(holder.value, offset, length);
1654: }
1655:
1656:
1667: private long[] ensureArray(long[] holder_value, int offset, int length)
1668: {
1669: if (holder_value == null)
1670: return new long[offset + length];
1671: else if (holder_value.length < offset + length)
1672: {
1673: long[] value = new long[offset + length];
1674: System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1675: return value;
1676: }
1677: else
1678: return holder_value;
1679: }
1680:
1681:
1687: public void read_boolean_array(BooleanSeqHolder holder, int offset, int length)
1688: {
1689: holder.value = ensureArray(holder.value, offset, length);
1690: read_boolean_array(holder.value, offset, length);
1691: }
1692:
1693:
1704: private boolean[] ensureArray(boolean[] holder_value, int offset, int length)
1705: {
1706: if (holder_value == null)
1707: return new boolean[offset + length];
1708: else if (holder_value.length < offset + length)
1709: {
1710: boolean[] value = new boolean[offset + length];
1711: System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1712: return value;
1713: }
1714: else
1715: return holder_value;
1716: }
1717:
1718:
1724: public void read_any_array(AnySeqHolder holder, int offset, int length)
1725: {
1726: holder.value = ensureArray(holder.value, offset, length);
1727: for (int i = offset; i < offset + length; i++)
1728: {
1729: holder.value[i] = read_any();
1730: }
1731: }
1732:
1733:
1744: private Any[] ensureArray(Any[] holder_value, int offset, int length)
1745: {
1746: if (holder_value == null)
1747: return new Any[offset + length];
1748: else if (holder_value.length < offset + length)
1749: {
1750: Any[] value = new Any[offset + length];
1751: System.arraycopy(holder_value, 0, value, 0, holder_value.length);
1752: return value;
1753: }
1754: else
1755: return holder_value;
1756: }
1757:
1758:
1764: public String[] _truncatable_ids()
1765: {
1766: return new String[] { "IDL:omg.org/CORBA/DataInputStream:1.0" };
1767: }
1768: }