final class Serialization
extends java.lang.Object
This class assists the implementation of collection classes. Do not use this class to serialize collections that are defined elsewhere.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
Serialization.FieldSetter<T> |
Modifier | Constructor and Description |
---|---|
private |
Serialization() |
Modifier and Type | Method and Description |
---|---|
(package private) static <T> Serialization.FieldSetter<T> |
getFieldSetter(java.lang.Class<T> clazz,
java.lang.String fieldName) |
(package private) static <K,V> void |
populateMap(java.util.Map<K,V> map,
java.io.ObjectInputStream stream)
Populates a map by reading an input stream, as part of deserialization.
|
(package private) static <K,V> void |
populateMap(java.util.Map<K,V> map,
java.io.ObjectInputStream stream,
int size)
Populates a map by reading an input stream, as part of deserialization.
|
(package private) static <K,V> void |
populateMultimap(Multimap<K,V> multimap,
java.io.ObjectInputStream stream)
Populates a multimap by reading an input stream, as part of
deserialization.
|
(package private) static <K,V> void |
populateMultimap(Multimap<K,V> multimap,
java.io.ObjectInputStream stream,
int distinctKeys)
Populates a multimap by reading an input stream, as part of
deserialization.
|
(package private) static <E> void |
populateMultiset(Multiset<E> multiset,
java.io.ObjectInputStream stream)
Populates a multiset by reading an input stream, as part of
deserialization.
|
(package private) static <E> void |
populateMultiset(Multiset<E> multiset,
java.io.ObjectInputStream stream,
int distinctElements)
Populates a multiset by reading an input stream, as part of
deserialization.
|
(package private) static int |
readCount(java.io.ObjectInputStream stream)
Reads a count corresponding to a serialized map, multiset, or multimap.
|
(package private) static <K,V> void |
writeMap(java.util.Map<K,V> map,
java.io.ObjectOutputStream stream)
Stores the contents of a map in an output stream, as part of serialization.
|
(package private) static <K,V> void |
writeMultimap(Multimap<K,V> multimap,
java.io.ObjectOutputStream stream)
Stores the contents of a multimap in an output stream, as part of
serialization.
|
(package private) static <E> void |
writeMultiset(Multiset<E> multiset,
java.io.ObjectOutputStream stream)
Stores the contents of a multiset in an output stream, as part of
serialization.
|
static int readCount(java.io.ObjectInputStream stream) throws java.io.IOException
writeMap(Map, ObjectOutputStream)
, the number of distinct elements in a
multiset serialized by writeMultiset(Multiset, ObjectOutputStream)
, or the number of distinct
keys in a multimap serialized by writeMultimap(Multimap, ObjectOutputStream)
.
The returned count may be used to construct an empty collection of the
appropriate capacity before calling any of the populate
methods.
java.io.IOException
static <K,V> void writeMap(java.util.Map<K,V> map, java.io.ObjectOutputStream stream) throws java.io.IOException
The serialized output consists of the number of entries, first key, first value, second key, second value, and so on.
java.io.IOException
static <K,V> void populateMap(java.util.Map<K,V> map, java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
writeMap(java.util.Map<K, V>, java.io.ObjectOutputStream)
for the data format.java.io.IOException
java.lang.ClassNotFoundException
static <K,V> void populateMap(java.util.Map<K,V> map, java.io.ObjectInputStream stream, int size) throws java.io.IOException, java.lang.ClassNotFoundException
writeMap(java.util.Map<K, V>, java.io.ObjectOutputStream)
for the data format. The size is determined by a
prior call to readCount(java.io.ObjectInputStream)
.java.io.IOException
java.lang.ClassNotFoundException
static <E> void writeMultiset(Multiset<E> multiset, java.io.ObjectOutputStream stream) throws java.io.IOException
The serialized output consists of the number of distinct elements, the first element, its count, the second element, its count, and so on.
java.io.IOException
static <E> void populateMultiset(Multiset<E> multiset, java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
writeMultiset(com.google.common.collect.Multiset<E>, java.io.ObjectOutputStream)
for the data format.java.io.IOException
java.lang.ClassNotFoundException
static <E> void populateMultiset(Multiset<E> multiset, java.io.ObjectInputStream stream, int distinctElements) throws java.io.IOException, java.lang.ClassNotFoundException
writeMultiset(com.google.common.collect.Multiset<E>, java.io.ObjectOutputStream)
for the data format. The number
of distinct elements is determined by a prior call to readCount(java.io.ObjectInputStream)
.java.io.IOException
java.lang.ClassNotFoundException
static <K,V> void writeMultimap(Multimap<K,V> multimap, java.io.ObjectOutputStream stream) throws java.io.IOException
Multimap.asMap()
view
determines the ordering in which data is written to the stream.
The serialized output consists of the number of distinct keys, and then for each distinct key: the key, the number of values for that key, and the key's values.
java.io.IOException
static <K,V> void populateMultimap(Multimap<K,V> multimap, java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
writeMultimap(com.google.common.collect.Multimap<K, V>, java.io.ObjectOutputStream)
for the data format.java.io.IOException
java.lang.ClassNotFoundException
static <K,V> void populateMultimap(Multimap<K,V> multimap, java.io.ObjectInputStream stream, int distinctKeys) throws java.io.IOException, java.lang.ClassNotFoundException
writeMultimap(com.google.common.collect.Multimap<K, V>, java.io.ObjectOutputStream)
for the data format. The number
of distinct keys is determined by a prior call to readCount(java.io.ObjectInputStream)
.java.io.IOException
java.lang.ClassNotFoundException
static <T> Serialization.FieldSetter<T> getFieldSetter(java.lang.Class<T> clazz, java.lang.String fieldName)