org.zkoss.io
Class Serializables

java.lang.Object
  extended by org.zkoss.io.Serializables

public class Serializables
extends Object

Utilities to handle java.io.Serializable.

Author:
tomyeh

Field Summary
static Log logio
          The logger called org.zkoss.io.serializable used to log serialization information.
 
Method Summary
static Collection smartRead(ObjectInputStream s, Collection col)
          Reads serializable elements back (serialized by smartWrite(ObjectOutputStream,Collection))
static Map smartRead(ObjectInputStream s, Map map)
          Reads serializable entries back (serialized by smartWrite(ObjectOutputStream,Map)).
static void smartWrite(ObjectOutputStream s, Collection col)
          Writes only serializable elements of the specified collection.
static void smartWrite(ObjectOutputStream s, Map map)
          Writes only serializable entries of the specified map.
static void smartWrite(ObjectOutputStream s, Object val)
          Writes the given value only if it is serializable.
static void smartWrite(ObjectOutputStream s, Object[] ary)
          Writes only serializable elements of the specified array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logio

public static final Log logio
The logger called org.zkoss.io.serializable used to log serialization information. You could set it to DEBUG, such that the not-serializable and ignored values will be logged.

Since:
5.0.7
Method Detail

smartWrite

public static void smartWrite(ObjectOutputStream s,
                              Map map)
                       throws IOException
Writes only serializable entries of the specified map. Non-serializable attributes are ignored.

Throws:
IOException

smartRead

public static Map smartRead(ObjectInputStream s,
                            Map map)
                     throws IOException,
                            ClassNotFoundException
Reads serializable entries back (serialized by smartWrite(ObjectOutputStream,Map)).

Parameters:
map - the map to hold the data being read. If null and any data is read, a new map (HashMap) is created and returned.
Returns:
the map being read
Throws:
IOException
ClassNotFoundException

smartWrite

public static void smartWrite(ObjectOutputStream s,
                              Collection col)
                       throws IOException
Writes only serializable elements of the specified collection.

Throws:
IOException

smartRead

public static Collection smartRead(ObjectInputStream s,
                                   Collection col)
                            throws IOException,
                                   ClassNotFoundException
Reads serializable elements back (serialized by smartWrite(ObjectOutputStream,Collection))

Parameters:
col - the collection to hold the data beinig read. If null and and data is read, a new collection (LinkedList) is created and returned.
Returns:
the collection being read
Throws:
IOException
ClassNotFoundException

smartWrite

public static void smartWrite(ObjectOutputStream s,
                              Object[] ary)
                       throws IOException
Writes only serializable elements of the specified array.

To read back, use smartRead(ObjectInputStream, Collection).

Throws:
IOException
Since:
3.0.0

smartWrite

public static void smartWrite(ObjectOutputStream s,
                              Object val)
                       throws IOException
Writes the given value only if it is serializable. If not, null is written.

Throws:
IOException
Since:
5.0.7


Copyright © 2012. All Rights Reserved.