62 |
import org.omg.CORBA.portable.InputStream; |
import org.omg.CORBA.portable.InputStream; |
63 |
import org.omg.CORBA.portable.ObjectImpl; |
import org.omg.CORBA.portable.ObjectImpl; |
64 |
|
|
65 |
|
import java.io.DataInput; |
66 |
import java.io.DataInputStream; |
import java.io.DataInputStream; |
67 |
import java.io.EOFException; |
import java.io.EOFException; |
68 |
import java.io.IOException; |
import java.io.IOException; |
94 |
* This instance is used to convert primitive data types into the |
* This instance is used to convert primitive data types into the |
95 |
* byte sequences. |
* byte sequences. |
96 |
*/ |
*/ |
97 |
protected DataInputStream b; |
protected abstractDataInputStream b; |
98 |
|
|
99 |
|
/** |
100 |
|
* The input stream, from where the data are actually |
101 |
|
* being read. |
102 |
|
*/ |
103 |
|
protected java.io.InputStream actual_stream; |
104 |
|
|
105 |
/** |
/** |
106 |
* The associated orb, if any. |
* The associated orb, if any. |
144 |
private boolean wide_native; |
private boolean wide_native; |
145 |
|
|
146 |
/** |
/** |
147 |
* Creates the stream. |
* If true, the stream expect |
148 |
|
* the multi-byte data in the form "less significant byte |
149 |
|
* first" (Little Endian). This is the opposite to the |
150 |
|
* java standard (Big Endian). |
151 |
|
*/ |
152 |
|
private boolean little_endian; |
153 |
|
|
154 |
|
/** |
155 |
|
* Creates the stream. The stream reads Big Endian by |
156 |
|
* default. |
157 |
* |
* |
158 |
* @param readFrom a stream to read CORBA input from. |
* @param readFrom a stream to read CORBA input from. |
159 |
*/ |
*/ |
173 |
} |
} |
174 |
|
|
175 |
/** |
/** |
176 |
|
* Set the Big Endian or Little Endian encoding. |
177 |
|
* The stream reads Big Endian by default. |
178 |
|
* |
179 |
|
* @param use_little_endian if true, the stream expect |
180 |
|
* the multi-byte data in the form "less significant byte |
181 |
|
* first" (Little Endian). This is the opposite to the |
182 |
|
* java standard (Big Endian). |
183 |
|
*/ |
184 |
|
public void setBigEndian(boolean use_big_endian) |
185 |
|
{ |
186 |
|
little_endian = !use_big_endian; |
187 |
|
setInputStream(actual_stream); |
188 |
|
} |
189 |
|
|
190 |
|
/** |
191 |
* Set the input stream that receives the CORBA input. |
* Set the input stream that receives the CORBA input. |
192 |
* |
* |
193 |
* @param readFrom the stream. |
* @param readFrom the stream. |
194 |
*/ |
*/ |
195 |
public void setInputStream(java.io.InputStream readFrom) |
public void setInputStream(java.io.InputStream readFrom) |
196 |
{ |
{ |
197 |
b = new DataInputStream(readFrom); |
if (little_endian) |
198 |
|
b = new LittleEndianInputStream(readFrom); |
199 |
|
else |
200 |
|
b = new BigEndianInputStream(readFrom); |
201 |
|
|
202 |
|
actual_stream = readFrom; |
203 |
} |
} |
204 |
|
|
205 |
/** |
/** |
245 |
} |
} |
246 |
catch (EOFException ex) |
catch (EOFException ex) |
247 |
{ |
{ |
248 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
249 |
|
t.initCause(ex); |
250 |
|
throw t; |
251 |
} |
} |
252 |
catch (IOException ex) |
catch (IOException ex) |
253 |
{ |
{ |
268 |
} |
} |
269 |
catch (EOFException ex) |
catch (EOFException ex) |
270 |
{ |
{ |
271 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
272 |
|
t.initCause(ex); |
273 |
|
throw t; |
274 |
} |
} |
275 |
|
|
276 |
catch (IOException ex) |
catch (IOException ex) |
300 |
} |
} |
301 |
catch (EOFException ex) |
catch (EOFException ex) |
302 |
{ |
{ |
303 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
304 |
|
t.initCause(ex); |
305 |
|
throw t; |
306 |
} |
} |
307 |
} |
} |
308 |
|
|
318 |
} |
} |
319 |
catch (EOFException ex) |
catch (EOFException ex) |
320 |
{ |
{ |
321 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
322 |
|
t.initCause(ex); |
323 |
|
throw t; |
324 |
} |
} |
325 |
} |
} |
326 |
|
|
336 |
} |
} |
337 |
catch (EOFException ex) |
catch (EOFException ex) |
338 |
{ |
{ |
339 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
340 |
|
t.initCause(ex); |
341 |
|
throw t; |
342 |
} |
} |
343 |
} |
} |
344 |
|
|
390 |
} |
} |
391 |
catch (IOException ex) |
catch (IOException ex) |
392 |
{ |
{ |
393 |
throw new BAD_OPERATION(ex.toString()); |
BAD_OPERATION bad = new BAD_OPERATION(); |
394 |
|
bad.initCause(ex); |
395 |
|
throw bad; |
396 |
} |
} |
397 |
} |
} |
398 |
|
|
442 |
} |
} |
443 |
catch (EOFException ex) |
catch (EOFException ex) |
444 |
{ |
{ |
445 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
446 |
|
t.initCause(ex); |
447 |
|
throw t; |
448 |
} |
} |
449 |
catch (IOException ex) |
catch (IOException ex) |
450 |
{ |
{ |
466 |
} |
} |
467 |
catch (EOFException ex) |
catch (EOFException ex) |
468 |
{ |
{ |
469 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
470 |
|
t.initCause(ex); |
471 |
|
throw t; |
472 |
} |
} |
473 |
|
|
474 |
catch (IOException ex) |
catch (IOException ex) |
488 |
if (narrow_native) |
if (narrow_native) |
489 |
return (char) b.read(); |
return (char) b.read(); |
490 |
else |
else |
491 |
return (char) new InputStreamReader(b, narrow_charset).read(); |
return (char) new InputStreamReader((InputStream) b, narrow_charset).read(); |
492 |
} |
} |
493 |
catch (EOFException ex) |
catch (EOFException ex) |
494 |
{ |
{ |
495 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
496 |
|
t.initCause(ex); |
497 |
|
throw t; |
498 |
} |
} |
499 |
|
|
500 |
catch (IOException ex) |
catch (IOException ex) |
517 |
} |
} |
518 |
else |
else |
519 |
{ |
{ |
520 |
InputStreamReader reader = new InputStreamReader(b, narrow_charset); |
InputStreamReader reader = |
521 |
|
new InputStreamReader((InputStream) b, narrow_charset); |
522 |
reader.read(x, offset, length); |
reader.read(x, offset, length); |
523 |
} |
} |
524 |
} |
} |
525 |
catch (EOFException ex) |
catch (EOFException ex) |
526 |
{ |
{ |
527 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
528 |
|
t.initCause(ex); |
529 |
|
throw t; |
530 |
} |
} |
531 |
|
|
532 |
catch (IOException ex) |
catch (IOException ex) |
547 |
} |
} |
548 |
catch (EOFException ex) |
catch (EOFException ex) |
549 |
{ |
{ |
550 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
551 |
|
t.initCause(ex); |
552 |
|
throw t; |
553 |
} |
} |
554 |
|
|
555 |
catch (IOException ex) |
catch (IOException ex) |
573 |
} |
} |
574 |
catch (EOFException ex) |
catch (EOFException ex) |
575 |
{ |
{ |
576 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
577 |
|
t.initCause(ex); |
578 |
|
throw t; |
579 |
} |
} |
580 |
|
|
581 |
catch (IOException ex) |
catch (IOException ex) |
585 |
} |
} |
586 |
|
|
587 |
/** |
/** |
588 |
* Read the encapsulated stream. The endian flag is already extracted from |
* Read the encapsulated stream. |
589 |
* the returned stream. |
* If the encapsulated sequence appears to be in the |
590 |
|
* Little endian format, the flag of the returned stream |
591 |
|
* is set to read Little endian. |
592 |
*/ |
*/ |
593 |
public cdrBufInput read_encapsulation() |
public cdrBufInput read_encapsulation() |
594 |
{ |
{ |
601 |
reading: |
reading: |
602 |
while (n < r.length) |
while (n < r.length) |
603 |
{ |
{ |
604 |
n = read(r, n, r.length - n); |
n += read(r, n, r.length - n); |
605 |
} |
} |
606 |
|
|
607 |
cdrBufInput capsule = new cdrBufInput(r); |
cdrBufInput capsule = new cdrBufInput(r); |
609 |
|
|
610 |
int endian = capsule.read_octet(); |
int endian = capsule.read_octet(); |
611 |
|
|
|
// TODO FIXME implement little endian. |
|
612 |
if (endian != 0) |
if (endian != 0) |
613 |
{ |
{ |
614 |
throw new NO_IMPLEMENT("Little endian not supported."); |
capsule.setBigEndian(false); |
615 |
} |
} |
616 |
|
|
617 |
return capsule; |
return capsule; |
618 |
} |
} |
619 |
catch (EOFException ex) |
catch (EOFException ex) |
620 |
{ |
{ |
621 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
622 |
|
t.initCause(ex); |
623 |
|
throw t; |
624 |
} |
} |
625 |
|
|
626 |
catch (IOException ex) |
catch (IOException ex) |
642 |
} |
} |
643 |
catch (EOFException ex) |
catch (EOFException ex) |
644 |
{ |
{ |
645 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
646 |
|
t.initCause(ex); |
647 |
|
throw t; |
648 |
} |
} |
649 |
|
|
650 |
catch (IOException ex) |
catch (IOException ex) |
665 |
} |
} |
666 |
catch (EOFException ex) |
catch (EOFException ex) |
667 |
{ |
{ |
668 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
669 |
|
t.initCause(ex); |
670 |
|
throw t; |
671 |
} |
} |
672 |
|
|
673 |
catch (IOException ex) |
catch (IOException ex) |
691 |
} |
} |
692 |
catch (EOFException ex) |
catch (EOFException ex) |
693 |
{ |
{ |
694 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
695 |
|
t.initCause(ex); |
696 |
|
throw t; |
697 |
} |
} |
698 |
|
|
699 |
catch (IOException ex) |
catch (IOException ex) |
714 |
} |
} |
715 |
catch (EOFException ex) |
catch (EOFException ex) |
716 |
{ |
{ |
717 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
718 |
|
t.initCause(ex); |
719 |
|
throw t; |
720 |
} |
} |
721 |
|
|
722 |
catch (IOException ex) |
catch (IOException ex) |
740 |
} |
} |
741 |
catch (EOFException ex) |
catch (EOFException ex) |
742 |
{ |
{ |
743 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
744 |
|
t.initCause(ex); |
745 |
|
throw t; |
746 |
} |
} |
747 |
|
|
748 |
catch (IOException ex) |
catch (IOException ex) |
787 |
} |
} |
788 |
catch (EOFException ex) |
catch (EOFException ex) |
789 |
{ |
{ |
790 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
791 |
|
t.initCause(ex); |
792 |
|
throw t; |
793 |
} |
} |
794 |
|
|
795 |
catch (IOException ex) |
catch (IOException ex) |
809 |
} |
} |
810 |
catch (EOFException ex) |
catch (EOFException ex) |
811 |
{ |
{ |
812 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
813 |
|
t.initCause(ex); |
814 |
|
throw t; |
815 |
} |
} |
816 |
|
|
817 |
catch (IOException ex) |
catch (IOException ex) |
831 |
} |
} |
832 |
catch (EOFException ex) |
catch (EOFException ex) |
833 |
{ |
{ |
834 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
835 |
|
t.initCause(ex); |
836 |
|
throw t; |
837 |
} |
} |
838 |
|
|
839 |
catch (IOException ex) |
catch (IOException ex) |
860 |
} |
} |
861 |
catch (EOFException ex) |
catch (EOFException ex) |
862 |
{ |
{ |
863 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
864 |
|
t.initCause(ex); |
865 |
|
throw t; |
866 |
} |
} |
867 |
|
|
868 |
catch (IOException ex) |
catch (IOException ex) |
883 |
} |
} |
884 |
catch (EOFException ex) |
catch (EOFException ex) |
885 |
{ |
{ |
886 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
887 |
|
t.initCause(ex); |
888 |
|
throw t; |
889 |
} |
} |
890 |
|
|
891 |
catch (IOException ex) |
catch (IOException ex) |
909 |
} |
} |
910 |
catch (EOFException ex) |
catch (EOFException ex) |
911 |
{ |
{ |
912 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
913 |
|
t.initCause(ex); |
914 |
|
throw t; |
915 |
} |
} |
916 |
|
|
917 |
catch (IOException ex) |
catch (IOException ex) |
946 |
} |
} |
947 |
catch (EOFException ex) |
catch (EOFException ex) |
948 |
{ |
{ |
949 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
950 |
|
t.initCause(ex); |
951 |
|
throw t; |
952 |
} |
} |
953 |
|
|
954 |
catch (IOException ex) |
catch (IOException ex) |
1032 |
if (wide_native) |
if (wide_native) |
1033 |
return (char) b.readShort(); |
return (char) b.readShort(); |
1034 |
else |
else |
1035 |
return (char) new InputStreamReader(b, wide_charset).read(); |
return (char) new InputStreamReader((InputStream) b, wide_charset).read(); |
1036 |
} |
} |
1037 |
catch (EOFException ex) |
catch (EOFException ex) |
1038 |
{ |
{ |
1039 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
1040 |
|
t.initCause(ex); |
1041 |
|
throw t; |
1042 |
} |
} |
1043 |
catch (IOException ex) |
catch (IOException ex) |
1044 |
{ |
{ |
1064 |
} |
} |
1065 |
else |
else |
1066 |
{ |
{ |
1067 |
InputStreamReader reader = new InputStreamReader(b, wide_charset); |
InputStreamReader reader = |
1068 |
|
new InputStreamReader((InputStream) b, wide_charset); |
1069 |
reader.read(x, offset, length); |
reader.read(x, offset, length); |
1070 |
} |
} |
1071 |
} |
} |
1072 |
catch (EOFException ex) |
catch (EOFException ex) |
1073 |
{ |
{ |
1074 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
1075 |
|
t.initCause(ex); |
1076 |
|
throw t; |
1077 |
} |
} |
1078 |
|
|
1079 |
catch (IOException ex) |
catch (IOException ex) |
1094 |
public String read_wstring() |
public String read_wstring() |
1095 |
{ |
{ |
1096 |
// Native encoding or word oriented data. |
// Native encoding or word oriented data. |
1097 |
if (wide_charset == null || giop.until_inclusive(1, 1)) |
if (wide_native || giop.until_inclusive(1, 1)) |
1098 |
return read_wstring_UTF_16(); |
return read_wstring_UTF_16(); |
1099 |
try |
try |
1100 |
{ |
{ |
1108 |
} |
} |
1109 |
catch (EOFException ex) |
catch (EOFException ex) |
1110 |
{ |
{ |
1111 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
1112 |
|
t.initCause(ex); |
1113 |
|
throw t; |
1114 |
} |
} |
1115 |
|
|
1116 |
catch (IOException ex) |
catch (IOException ex) |
1164 |
} |
} |
1165 |
catch (EOFException ex) |
catch (EOFException ex) |
1166 |
{ |
{ |
1167 |
throw new MARSHAL(UNEXP_EOF); |
MARSHAL t = new MARSHAL(UNEXP_EOF); |
1168 |
|
t.initCause(ex); |
1169 |
|
throw t; |
1170 |
} |
} |
1171 |
|
|
1172 |
catch (IOException ex) |
catch (IOException ex) |
1223 |
{ |
{ |
1224 |
return read_Object(); |
return read_Object(); |
1225 |
} |
} |
1226 |
} |
} |