public final class SerializationUtil extends Object
Modifier and Type | Method and Description |
---|---|
static InputStream |
convertToInputStream(DataInput in,
int offset) |
static ObjectDataInputStream |
createObjectDataInputStream(InputStream in,
InternalSerializationService ss) |
static ObjectDataOutputStream |
createObjectDataOutputStream(OutputStream out,
InternalSerializationService ss) |
static int |
getPortableVersion(Portable portable,
int defaultVersion) |
static <T> Collection<T> |
readCollection(ObjectDataInput in)
Reads a collection from the given
ObjectDataInput . |
static <K,V> Map<K,V> |
readMap(ObjectDataInput in) |
static <T> List<T> |
readNullableList(ObjectDataInput in)
Read a list written by
writeNullableList(List, ObjectDataOutput)
It does not guarantee to use the same implementation of a list as was written
into the stream. |
static <K,V> Map<K,V> |
readNullableMap(ObjectDataInput in)
Reads a map written by
writeNullableMap(Map, ObjectDataOutput) . |
static <T> void |
writeCollection(Collection<T> items,
ObjectDataOutput out)
Writes a collection to an
ObjectDataOutput . |
static <K,V> void |
writeMap(Map<K,V> map,
ObjectDataOutput out) |
static <T> void |
writeNullableList(List<T> list,
ObjectDataOutput out)
Write items from a list into a ObjectDataOutput.
|
static <K,V> void |
writeNullableMap(Map<K,V> map,
ObjectDataOutput out)
Writes a map to given
ObjectDataOutput . |
public static int getPortableVersion(Portable portable, int defaultVersion)
public static ObjectDataOutputStream createObjectDataOutputStream(OutputStream out, InternalSerializationService ss)
public static ObjectDataInputStream createObjectDataInputStream(InputStream in, InternalSerializationService ss)
public static InputStream convertToInputStream(DataInput in, int offset)
public static <T> void writeNullableList(List<T> list, ObjectDataOutput out) throws IOException
readNullableList(ObjectDataInput)
T
- type of the listlist
- list to write into the outputout
- the output to useIOException
public static <T> List<T> readNullableList(ObjectDataInput in) throws IOException
writeNullableList(List, ObjectDataOutput)
It does not guarantee to use the same implementation of a list as was written
into the stream.T
- type of itemsin
- data input to read fromIOException
public static <K,V> void writeNullableMap(Map<K,V> map, ObjectDataOutput out) throws IOException
ObjectDataOutput
.map
- the map to serialize, can be null
out
- the output to write the map toIOException
public static <K,V> void writeMap(@Nonnull Map<K,V> map, ObjectDataOutput out) throws IOException
IOException
public static <K,V> Map<K,V> readNullableMap(ObjectDataInput in) throws IOException
writeNullableMap(Map, ObjectDataOutput)
. The map itself
may be null
. No guarantee is provided about the type of Map returned or its suitability
to be used in a thread-safe manner.K
- type of key classV
- type of value classin
- the ObjectDataInput
input to read fromMap
containing the keys & values read from the input or null
if the original serialized map was null
IOException
- when an error occurs while reading from the input@Nonnull public static <K,V> Map<K,V> readMap(ObjectDataInput in) throws IOException
IOException
public static <T> void writeCollection(Collection<T> items, ObjectDataOutput out) throws IOException
ObjectDataOutput
. The collection's size is written
to the data output, then each object in the collection is serialized.T
- type of itemsitems
- collection of items to be serializedout
- data output to write toNullPointerException
- if items
or out
is null
IOException
public static <T> Collection<T> readCollection(ObjectDataInput in) throws IOException
ObjectDataInput
. It is expected that
the next int read from the data input is the collection's size, then that
many objects are read from the data input and returned as a collection.T
- type of itemsin
- data input to read fromIOException
Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.