org.jboss.seam.solder.util.collections
Class Serialization

java.lang.Object
  extended by org.jboss.seam.solder.util.collections.Serialization

public class Serialization
extends Object


Method Summary
static
<K,V> void
populateMultimap(Multimap<K,V> multimap, ObjectInputStream stream, int distinctKeys)
          Populates a multimap by reading an input stream, as part of deserialization.
static int readCount(ObjectInputStream stream)
          Reads a count corresponding to a serialized map, multiset, or multimap.
static
<K,V> void
writeMultimap(Multimap<K,V> multimap, ObjectOutputStream stream)
          Stores the contents of a multimap in an output stream, as part of serialization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readCount

public static int readCount(ObjectInputStream stream)
                     throws IOException
Reads a count corresponding to a serialized map, multiset, or multimap. It returns the size of a map serialized by #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.

Throws:
IOException

writeMultimap

public static <K,V> void writeMultimap(Multimap<K,V> multimap,
                                       ObjectOutputStream stream)
                          throws IOException
Stores the contents of a multimap in an output stream, as part of serialization. It does not support concurrent multimaps whose content may change while the method is running. The 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.

Throws:
IOException

populateMultimap

public static <K,V> void populateMultimap(Multimap<K,V> multimap,
                                          ObjectInputStream stream,
                                          int distinctKeys)
                             throws IOException,
                                    ClassNotFoundException
Populates a multimap by reading an input stream, as part of deserialization. See writeMultimap(org.jboss.seam.solder.util.collections.Multimap, java.io.ObjectOutputStream) for the data format. The number of distinct keys is determined by a prior call to readCount(java.io.ObjectInputStream).

Throws:
IOException
ClassNotFoundException


Copyright © 2008-2011 Seam Framework. All Rights Reserved.