private void writeIDLValue(Serializable object, String repID) { if (object instanceof StreamableValue) { ((StreamableValue)object)._write(parent); } else if (object instanceof CustomValue) { ((CustomValue)object).marshal(parent); } else { BoxedValueHelper helper = Utility.getHelper(object.getClass(), null, repID); boolean isCustom = false; if (helper instanceof ValueHelper && object instanceof CustomMarshal) { try { if (((ValueHelper)helper).get_type().type_modifier() == VM_CUSTOM.value) isCustom = true; } catch(BadKind ex) { throw wrapper.badTypecodeForCustomValue( CompletionStatus.COMPLETED_MAYBE, ex ) ; } } if (isCustom) ((CustomMarshal)object).marshal(parent); else helper.write_value(parent, object); } }
/** * Try to write value supposing that it implements self-streamable interfaces. * Return false if it does not or true on success. */ static boolean writeSelf(OutputStream output, Serializable value) { // User defined write method is present. if (value instanceof CustomMarshal) { ((CustomMarshal) value).marshal((DataOutputStream) output); return true; } else if (value instanceof Streamable) { ((Streamable) value)._write(output); return true; } return false; }
/** * Checks if an instance of this class can write its fields itself. */ public boolean isCustomMarshaled(Class clz) { return CustomMarshal.class.isAssignableFrom(clz) || Streamable.class.isAssignableFrom(clz); }