Interface BinaryMarshaller<T>
public interface BinaryMarshaller<T>
A marshaller used by the native bridge processor to read or write method parameters and results
of a custom type. Marshallers are used to support types that are not directly implemented by the
native bridge processor.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault intEstimates a size in bytes needed to marshall given object.default intinferUpdateSize(T object) Estimates a size in bytes needed to marshallOutparameter passed back to caller from a foreign method call.static <T> BinaryMarshaller<T> nullable(BinaryMarshaller<T> forMarshaller) read(BinaryInput input) Deserializes and recreates an object passed to a foreign method.default voidreadUpdate(BinaryInput input, T object) Deserializes and updates the mutable state of a given object to supportOutsemantics.voidwrite(BinaryOutput output, T object) Decomposes and serializes the given object passed to a foreign method.default voidwriteUpdate(BinaryOutput output, T object) Decomposes and serializes the mutable state of a given object to supportOutsemantics.
-
Method Details
-
write
Decomposes and serializes the given object passed to a foreign method. -
read
Deserializes and recreates an object passed to a foreign method. -
inferSize
Estimates a size in bytes needed to marshall given object. The returned value is used to pre-allocate theBinaryOutput's buffer. The accuracy of the estimate affects the speed of marshalling. If the estimate is too small, the pre-allocated buffer must be re-allocated and the already marshalled data must be copied. Too large a value may cause the static buffer to be unused and the dynamic buffer to be unnecessarily allocated. -
writeUpdate
Decomposes and serializes the mutable state of a given object to supportOutsemantics. Marshallers that do not supportOutparameters do not need to implement this method. The default implementation throwsUnsupportedOperationException. To supportOutparameters theBinaryMarshallermust implement alsoreadUpdate(BinaryInput, Object)andinferUpdateSize(Object).The
Outparameters are passed in the following way:- The start point method writes the parameter using
write(BinaryOutput, Object). - A foreign method call is made.
- The end point method reads the parameter using
read(BinaryInput). - The end point receiver method is called with the unmarshalled parameter.
- After calling the receiver method, the end point method writes the mutated
Outparameter state usingwriteUpdate(BinaryOutput, Object). - A foreign method returns.
- The state of the
Outparameter is updated usingreadUpdate(BinaryInput, Object).
- See Also:
- The start point method writes the parameter using
-
readUpdate
Deserializes and updates the mutable state of a given object to supportOutsemantics. Marshallers that do not supportOutparameters do not need to implement this method. The default implementation throwsUnsupportedOperationException. To supportOutparameters theBinaryMarshallermust implement alsowriteUpdate(BinaryOutput, Object)andinferUpdateSize(Object).- See Also:
-
inferUpdateSize
Estimates a size in bytes needed to marshallOutparameter passed back to caller from a foreign method call. The accuracy of the estimate affects the speed of marshalling. If the estimate is too small, the pre-allocated buffer must be re-allocated and the already marshalled data must be copied. Too large a value may cause the static buffer to be unused and the dynamic buffer to be unnecessarily allocated. Marshallers that do not supportOutparameters do not need to implement this method. The default implementation throwsUnsupportedOperationException. To supportOutparameters theBinaryMarshallermust implement alsowriteUpdate(BinaryOutput, Object)andreadUpdate(BinaryInput, Object).- See Also:
-
nullable
DecoratesforMarshallerby aBinaryMarshallerhandlingnullvalues. The returnedBinaryMarshallercalls theforMarshalleronly non-null values.
-