ca.odell.glazedlists.impl.io.SerializableByteCoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of glazedlists_java15 Show documentation
Show all versions of glazedlists_java15 Show documentation
Event-driven lists for dynamically filtered and sorted tables
The newest version!
/* Glazed Lists (c) 2003-2006 */
/* http://publicobject.com/glazedlists/ publicobject.com,*/
/* O'Dell Engineering Ltd.*/
package ca.odell.glazedlists.impl.io;
import ca.odell.glazedlists.io.ByteCoder;
import java.io.*;
/**
* A {@link ByteCoder} that uses {@link Serializable}.
*
* @author Jesse Wilson
*/
public class SerializableByteCoder implements ByteCoder {
/** {@inheritDoc} */
public void encode(Object source, OutputStream target) throws IOException {
ObjectOutputStream objectOut = new ObjectOutputStream(target);
objectOut.writeObject(source);
objectOut.close();
}
/** {@inheritDoc} */
public Object decode(InputStream source) throws IOException {
try {
ObjectInputStream objectIn = new ObjectInputStream(source);
return objectIn.readObject();
} catch(ClassNotFoundException e) {
throw new IllegalStateException(e.getMessage());
}
}
}