46 |
import org.omg.CORBA.MARSHAL; |
import org.omg.CORBA.MARSHAL; |
47 |
import org.omg.CORBA.NO_IMPLEMENT; |
import org.omg.CORBA.NO_IMPLEMENT; |
48 |
import org.omg.CORBA.StringSeqHelper; |
import org.omg.CORBA.StringSeqHelper; |
49 |
import org.omg.CORBA.portable.*; |
import org.omg.CORBA.portable.BoxedValueHelper; |
50 |
import org.omg.CORBA.portable.InputStream; |
import org.omg.CORBA.portable.InputStream; |
51 |
import org.omg.CORBA.portable.OutputStream; |
import org.omg.CORBA.portable.OutputStream; |
52 |
import org.omg.CORBA.portable.Streamable; |
import org.omg.CORBA.portable.Streamable; |
317 |
* @throws MARSHAL if the reading has failed due any reason. |
* @throws MARSHAL if the reading has failed due any reason. |
318 |
*/ |
*/ |
319 |
public static Object read(InputStream input, Object value_instance, |
public static Object read(InputStream input, Object value_instance, |
320 |
Object helper |
Object helper |
321 |
) |
) |
322 |
{ |
{ |
323 |
try |
try |
324 |
{ |
{ |
399 |
* @return the value that was read. |
* @return the value that was read. |
400 |
*/ |
*/ |
401 |
private static Object read_instance(InputStream input, Object value, |
private static Object read_instance(InputStream input, Object value, |
402 |
int value_tag, Object helper |
int value_tag, Object helper |
403 |
) |
) |
404 |
{ |
{ |
405 |
try |
try |
406 |
{ |
{ |
507 |
|
|
508 |
// Stating the interfaces that the USER should use. |
// Stating the interfaces that the USER should use. |
509 |
throw new MARSHAL("The " + value.getClass().getName() + |
throw new MARSHAL("The " + value.getClass().getName() + |
510 |
" must implement either StreamableValue or CustomValue." |
" must implement either StreamableValue or CustomValue." |
511 |
); |
); |
512 |
|
|
513 |
// The negative end of state marker is expected from OMG standard. |
// The negative end of state marker is expected from OMG standard. |
514 |
// If the chunking is used, this marker is already extracted. |
// If the chunking is used, this marker is already extracted. |
562 |
* @throws MARSHAL if the writing failed due any reason. |
* @throws MARSHAL if the writing failed due any reason. |
563 |
*/ |
*/ |
564 |
public static void write(OutputStream output, Serializable value, |
public static void write(OutputStream output, Serializable value, |
565 |
Class substitute |
Class substitute |
566 |
) |
) |
567 |
{ |
{ |
568 |
// Write null if this is a null value. |
// Write null if this is a null value. |
569 |
if (value == null) |
if (value == null) |
598 |
* not null. |
* not null. |
599 |
*/ |
*/ |
600 |
public static void write(OutputStream output, Serializable value, |
public static void write(OutputStream output, Serializable value, |
601 |
Object helper |
Object helper |
602 |
) |
) |
603 |
{ |
{ |
604 |
if (value == null) |
if (value == null) |
605 |
output.write_long(vt_NULL); |
output.write_long(vt_NULL); |
627 |
* if the value should be written unsing other methods. |
* if the value should be written unsing other methods. |
628 |
*/ |
*/ |
629 |
private static void write_instance(OutputStream output, Serializable value, |
private static void write_instance(OutputStream output, Serializable value, |
630 |
String id, Object helper |
String id, Object helper |
631 |
) |
) |
632 |
{ |
{ |
633 |
// This implementation always writes a single repository id. |
// This implementation always writes a single repository id. |
634 |
// It never writes multiple repository ids and currently does not use |
// It never writes multiple repository ids and currently does not use |
684 |
// for the global boxed value type itself. |
// for the global boxed value type itself. |
685 |
Method write = |
Method write = |
686 |
helperClass.getMethod("write", |
helperClass.getMethod("write", |
687 |
new Class[] |
new Class[] |
688 |
{ |
{ |
689 |
org.omg.CORBA.portable.OutputStream.class, |
org.omg.CORBA.portable.OutputStream.class, value.getClass() |
690 |
value.getClass() |
} |
691 |
} |
); |
|
); |
|
692 |
write.invoke(null, new Object[] { outObj, value }); |
write.invoke(null, new Object[] { outObj, value }); |
693 |
ok = true; |
ok = true; |
694 |
} |
} |
700 |
// Stating the interfaces that the USER should use. |
// Stating the interfaces that the USER should use. |
701 |
if (!ok) |
if (!ok) |
702 |
throw new MARSHAL("The " + value.getClass().getName() + |
throw new MARSHAL("The " + value.getClass().getName() + |
703 |
" must implement either StreamableValue" + |
" must implement either StreamableValue" + " or CustomValue." |
704 |
" or CustomValue." |
); |
|
); |
|
705 |
} |
} |
706 |
|
|
707 |
if (USE_CHUNKING) |
if (USE_CHUNKING) |
729 |
* |
* |
730 |
* @throws NO_IMPLEMENT, always. |
* @throws NO_IMPLEMENT, always. |
731 |
*/ |
*/ |
732 |
static void incorrect_plug_in(Throwable ex) |
static void incorrect_plug_in(Throwable ex) throws NO_IMPLEMENT |
|
throws NO_IMPLEMENT |
|
733 |
{ |
{ |
734 |
NO_IMPLEMENT no = new NO_IMPLEMENT("Incorrect CORBA plug-in"); |
NO_IMPLEMENT no = new NO_IMPLEMENT("Incorrect CORBA plug-in"); |
735 |
no.initCause(ex); |
no.initCause(ex); |
746 |
private static final void checkTag(int value_tag) |
private static final void checkTag(int value_tag) |
747 |
{ |
{ |
748 |
if ((value_tag < 0x7fffff00 || value_tag > 0x7fffffff) && |
if ((value_tag < 0x7fffff00 || value_tag > 0x7fffffff) && |
749 |
value_tag != vt_NULL && value_tag != vt_INDIRECTION |
value_tag != vt_NULL && |
750 |
) |
value_tag != vt_INDIRECTION |
751 |
|
) |
752 |
throw new MARSHAL("Invalid value record, unsupported header tag: " + |
throw new MARSHAL("Invalid value record, unsupported header tag: " + |
753 |
value_tag |
value_tag |
754 |
); |
); |
755 |
} |
} |
756 |
} |
} |