Package org.zkoss.io
Class Serializables
- java.lang.Object
-
- org.zkoss.io.Serializables
-
public class Serializables extends java.lang.Object
Utilities to handle java.io.Serializable.- Author:
- tomyeh
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Logger
logio
The logger called org.zkoss.io.serializable used to log serialization information.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.util.Collection<T>
smartRead(java.io.ObjectInputStream s, java.util.Collection<T> col)
Reads serializable elements back (serialized bysmartWrite(ObjectOutputStream,Collection)
)static <T> java.util.List<T>
smartRead(java.io.ObjectInputStream s, java.util.List<T> col)
Reads serializable elements back (serialized bysmartWrite(ObjectOutputStream,Collection)
)static <K,V>
java.util.Map<K,V>smartRead(java.io.ObjectInputStream s, java.util.Map<K,V> map)
Reads serializable entries back (serialized bysmartWrite(ObjectOutputStream,Map)
).static void
smartWrite(java.io.ObjectOutputStream s, java.lang.Object val)
Writes the given value only if it is serializable.static <T> void
smartWrite(java.io.ObjectOutputStream s, java.util.Collection<T> col)
Writes only serializable elements of the specified collection.static <K,V>
voidsmartWrite(java.io.ObjectOutputStream s, java.util.Map<K,V> map)
Writes only serializable entries of the specified map.static <T> void
smartWrite(java.io.ObjectOutputStream s, T[] ary)
Writes only serializable elements of the specified array.
-
-
-
Method Detail
-
smartWrite
public static <K,V> void smartWrite(java.io.ObjectOutputStream s, java.util.Map<K,V> map) throws java.io.IOException
Writes only serializable entries of the specified map. Non-serializable attributes are ignored.- Throws:
java.io.IOException
-
smartRead
public static <K,V> java.util.Map<K,V> smartRead(java.io.ObjectInputStream s, java.util.Map<K,V> map) throws java.io.IOException, java.lang.ClassNotFoundException
Reads serializable entries back (serialized bysmartWrite(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:
java.io.IOException
java.lang.ClassNotFoundException
-
smartWrite
public static <T> void smartWrite(java.io.ObjectOutputStream s, java.util.Collection<T> col) throws java.io.IOException
Writes only serializable elements of the specified collection.- Throws:
java.io.IOException
-
smartRead
public static <T> java.util.Collection<T> smartRead(java.io.ObjectInputStream s, java.util.Collection<T> col) throws java.io.IOException, java.lang.ClassNotFoundException
Reads serializable elements back (serialized bysmartWrite(ObjectOutputStream,Collection)
)- Parameters:
col
- the collection to hold the data being read. If null and and data is read, a new collection (LinkedList) is created and returned.- Returns:
- the collection being read
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
smartRead
public static <T> java.util.List<T> smartRead(java.io.ObjectInputStream s, java.util.List<T> col) throws java.io.IOException, java.lang.ClassNotFoundException
Reads serializable elements back (serialized bysmartWrite(ObjectOutputStream,Collection)
)- Parameters:
col
- the collection to hold the data being read. If null and and data is read, a new collection (LinkedList) is created and returned.- Returns:
- the collection being read
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
- Since:
- 6.0.0
-
smartWrite
public static <T> void smartWrite(java.io.ObjectOutputStream s, T[] ary) throws java.io.IOException
Writes only serializable elements of the specified array.To read back, use
smartRead(ObjectInputStream, Collection)
.- Throws:
java.io.IOException
- Since:
- 3.0.0
-
smartWrite
public static void smartWrite(java.io.ObjectOutputStream s, java.lang.Object val) throws java.io.IOException
Writes the given value only if it is serializable. If not, null is written.- Throws:
java.io.IOException
- Since:
- 5.0.7
-
-