com.google.sitebricks.client.transport.XStreamXmlTransport Maven / Gradle / Ivy
package com.google.sitebricks.client.transport;
import com.google.inject.Inject;
import com.thoughtworks.xstream.XStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* @author Dhanji R. Prasanna ([email protected])
*/
class XStreamXmlTransport extends Xml {
private final XStream xStream;
@Inject
public XStreamXmlTransport(XStream xStream) {
this.xStream = xStream;
}
public T in(InputStream in, Class type) throws IOException {
return type.cast(xStream.fromXML(in));
}
public void out(OutputStream out, Class type, T data) {
xStream.toXML(data, out);
}
}