Class ProxySerializer
java.lang.Object
io.fluxzero.proxy.ProxySerializer
- All Implemented Interfaces:
ContentFilter, Serializer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<V> VCreates a deep copy of the given object using serialization.<V> VConverts a given object to another type using the serializer's object mapping rules.<I extends SerializedObject<byte[]>>
Stream<DeserializingObject<byte[], I>> deserialize(Stream<I> stream, UnknownTypeStrategy unknownTypeStrategy) Upcasts and deserializes a stream of serialized objects.Downcasts aDataobject to the specified revision level.Downcasts the given object to a previous revision.<T> TfilterContent(T t, User user) Filters the given value based on the current viewer (user) context.registerDowncasters(Object... casterCandidates) Registers one or more downcaster candidates.registerTypeCaster(String s, String s1) Registers a mapping from an old type identifier to a new one.registerUpcasters(Object... casterCandidates) Registers one or more upcaster candidates.Data<byte[]> Serializes the given object into aDatawrapper using the specified format.upcastType(String s) Returns the upcasted type name for a legacy type identifier.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Serializer
deserialize, deserialize, deserializeMessage, deserializeMessages, deserializeMessages, deserializeMessages, deserializeMessages, registerCasters, serialize
-
Constructor Details
-
ProxySerializer
public ProxySerializer()
-
-
Method Details
-
serialize
Description copied from interface:SerializerSerializes the given object into aDatawrapper using the specified format.- Specified by:
serializein interfaceSerializer- Parameters:
object- the object to serializeformat- the desired serialization format (e.g. \"json\"); may benull- Returns:
- serialized object as
Data
-
deserialize
public <I extends SerializedObject<byte[]>> Stream<DeserializingObject<byte[],I>> deserialize(Stream<I> stream, UnknownTypeStrategy unknownTypeStrategy) Description copied from interface:SerializerUpcasts and deserializes a stream of serialized objects. Each result in the output stream contains both a provider for the deserialized object and the serialized object after upcasting that is used as the source of the deserialized object.Deserialization is performed lazily. This means that actual conversion for a given result in the output stream only happens if
DeserializingObject.getPayload()is invoked on the result. This has the advantage that a caller can inspect what type will be returned viabefore deciding to go through with the deserialization.invalid reference
DeserializingObject#getSerializedObject()You can specify whether deserialization of a result in the output stream should fail with a
DeserializationExceptionif a type is unknown (not a class). It is up to the implementation to determine what should happen if a type is unknown but thefailOnUnknownTypeflag is false.- Specified by:
deserializein interfaceSerializer- Type Parameters:
I- the type of the serialized object- Parameters:
stream- data input stream to deserializeunknownTypeStrategy- value that determines what to do when encountering unknown types- Returns:
- a stream containing deserialization results
-
convert
Description copied from interface:SerializerConverts a given object to another type using the serializer's object mapping rules.- Specified by:
convertin interfaceSerializer- Type Parameters:
V- the result type- Parameters:
o- the input valueaClass- the target type- Returns:
- the converted value
-
clone
Description copied from interface:SerializerCreates a deep copy of the given object using serialization.- Specified by:
clonein interfaceSerializer- Type Parameters:
V- the type of the value- Parameters:
o- the object to clone- Returns:
- a deep copy
-
registerUpcasters
Description copied from interface:SerializerRegisters one or more upcaster candidates.- Specified by:
registerUpcastersin interfaceSerializer- Parameters:
casterCandidates- beans with upcasting logic- Returns:
- a registration handle
-
registerDowncasters
Description copied from interface:SerializerRegisters one or more downcaster candidates.- Specified by:
registerDowncastersin interfaceSerializer- Parameters:
casterCandidates- beans with downcasting logic- Returns:
- a registration handle
-
registerTypeCaster
Description copied from interface:SerializerRegisters a mapping from an old type identifier to a new one.- Specified by:
registerTypeCasterin interfaceSerializer- Parameters:
s- the legacy type names1- the canonical or updated type name- Returns:
- a registration handle
-
upcastType
Description copied from interface:SerializerReturns the upcasted type name for a legacy type identifier.- Specified by:
upcastTypein interfaceSerializer- Parameters:
s- the original type- Returns:
- the remapped (or unchanged) type name
-
downcast
Description copied from interface:SerializerDowncasts the given object to a previous revision.- Specified by:
downcastin interfaceSerializer- Parameters:
o- the object to downcasti- the target revision- Returns:
- a revisioned form of the object
-
downcast
Description copied from interface:SerializerDowncasts aDataobject to the specified revision level.- Specified by:
downcastin interfaceSerializer- Parameters:
data- the serialized datai- the target revision number- Returns:
- a transformed object matching the older revision
-
filterContent
Description copied from interface:ContentFilterFilters the given value based on the current viewer (user) context. If aFilterContenthandler exists in the object's class, it will be invoked to produce a user-specific view of the data.- Specified by:
filterContentin interfaceContentFilter- Type Parameters:
T- the type of the content object- Parameters:
t- the original objectuser- the user viewing the content- Returns:
- the filtered version of the object, or the original object if filtering failed or was not applicable
-