All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ssf4j.xstream.XStreamDeserializer Maven / Gradle / Ivy

The newest version!
package org.ssf4j.xstream;

import java.io.IOException;
import java.io.InputStream;

import org.ssf4j.Deserializer;

import com.thoughtworks.xstream.XStream;

public class XStreamDeserializer implements Deserializer {

	protected XStreamSerialization serde;
	protected XStream xstream;
	protected Class type;
	protected InputStream in;
	
	public XStreamDeserializer(XStreamSerialization serde, XStream xstream, InputStream in, Class type) {
		this.serde = serde;
		this.xstream = xstream;
		this.in = in;
		this.type = type;
	}
	
	@Override
	public T read() throws IOException {
		serde.getLock().lock();
		try {
			return type.cast(xstream.fromXML(in));
		} finally {
			serde.getLock().unlock();
		}
	}

	@Override
	public void close() throws IOException {
		in.close();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy