use of org.batfish.common.util.BatfishObjectInputStream in project batfish by batfish.
the class PluginConsumer method deserializeObject.
private <S extends Serializable> S deserializeObject(InputStream stream, Class<S> outputClass, Format format) throws IOException {
try {
ObjectInputStream ois;
if (format != Format.JAVA_SERIALIZED) {
XStream xstream = new XStream(new DomDriver("UTF-8"));
xstream.setClassLoader(_currentClassLoader);
ois = xstream.createObjectInputStream(stream);
} else {
ois = new BatfishObjectInputStream(stream, _currentClassLoader);
}
Object o = ois.readObject();
return outputClass.cast(o);
} catch (ClassNotFoundException | ClassCastException e) {
throw new BatfishException("Failed to deserialize object of type '" + outputClass.getCanonicalName() + "' from data", e);
}
}
Aggregations