Package org.zkoss.io
Class Serializables
java.lang.Object
org.zkoss.io.Serializables
Utilities to handle java.io.Serializable.
- Author:
- tomyeh
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.slf4j.LoggerThe logger called org.zkoss.io.serializable used to log serialization information. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Collection<T>smartRead(ObjectInputStream s, Collection<T> col) Reads serializable elements back (serialized bysmartWrite(ObjectOutputStream,Collection))static <T> List<T>smartRead(ObjectInputStream s, List<T> col) Reads serializable elements back (serialized bysmartWrite(ObjectOutputStream,Collection))static <K,V> Map<K, V> smartRead(ObjectInputStream s, Map<K, V> map) Reads serializable entries back (serialized bysmartWrite(ObjectOutputStream,Map)).static voidsmartWrite(ObjectOutputStream s, Object val) Writes the given value only if it is serializable.static <T> voidsmartWrite(ObjectOutputStream s, Collection<T> col) Writes only serializable elements of the specified collection.static <K,V> void smartWrite(ObjectOutputStream s, Map<K, V> map) Writes only serializable entries of the specified map.static <T> voidsmartWrite(ObjectOutputStream s, T[] ary) Writes only serializable elements of the specified array.
-
Field Details
-
logio
public static final org.slf4j.Logger logioThe logger called org.zkoss.io.serializable used to log serialization information. You could set it to DEBUG, such that the non-serializable and ignored values will be logged.- Since:
- 5.0.7
-
-
Method Details
-
smartWrite
Writes only serializable entries of the specified map. Non-serializable attributes are ignored.- Throws:
IOException
-
smartRead
public static <K,V> Map<K,V> smartRead(ObjectInputStream s, Map<K, V> map) throws IOException, ClassNotFoundExceptionReads 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:
IOExceptionClassNotFoundException
-
smartWrite
Writes only serializable elements of the specified collection.- Throws:
IOException
-
smartRead
public static <T> Collection<T> smartRead(ObjectInputStream s, Collection<T> col) throws IOException, 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:
IOExceptionClassNotFoundException
-
smartRead
public static <T> List<T> smartRead(ObjectInputStream s, List<T> col) throws IOException, 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:
IOExceptionClassNotFoundException- Since:
- 6.0.0
-
smartWrite
Writes only serializable elements of the specified array.To read back, use
smartRead(ObjectInputStream, Collection).- Throws:
IOException- Since:
- 3.0.0
-
smartWrite
Writes the given value only if it is serializable. If not, null is written.- Throws:
IOException- Since:
- 5.0.7
-