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

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

There is a newer version: 0.4
Show newest version
package org.ssf4j.xstream;

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

import org.ssf4j.Serialization;
import com.thoughtworks.xstream.XStream;

/**
 * Serialization facade that uses XStream
 * @author robin
 *
 */
public class XStreamSerialization implements Serialization {

	/**
	 * The {@link XStream} instance to use for serialization/deserialization.
	 * If {@code null} then a new {@link XStream} is created for each
	 * serializer/deserializer
	 */
	protected XStream xstream;
	
	/**
	 * Create a new {@link XStreamSerialization} that uses a new default {@link XStream}
	 * for each serializer/deserializer
	 */
	public XStreamSerialization() {}
	
	/**
	 * Create a new {@link XStreamSerialization} that uses the supplied {@link XStream} for
	 * each serializer/deserializer
	 * @param xstream
	 */
	public XStreamSerialization(XStream xstream) {
		this.xstream = xstream;
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public  XStreamSerializer newSerializer(OutputStream out, Class type) throws IOException {
		return new XStreamSerializer(xstream, out);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public  XStreamDeserializer newDeserializer(InputStream in, Class type) throws IOException {
		return new XStreamDeserializer(xstream, in, type);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy