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

net.razorvine.pyro.serializer.PyroUriPickler Maven / Gradle / Ivy

package net.razorvine.pyro.serializer;

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

import net.razorvine.pickle.IObjectPickler;
import net.razorvine.pickle.Opcodes;
import net.razorvine.pickle.PickleException;
import net.razorvine.pickle.Pickler;
import net.razorvine.pyro.PyroURI;

/**
 * Pickler extension to be able to pickle Pyro URI objects.
 *  
 * @author Irmen de Jong ([email protected])
 */
public class PyroUriPickler implements IObjectPickler {

	public void pickle(Object o, OutputStream out, Pickler currentPickler) throws PickleException, IOException {
		PyroURI uri = (PyroURI) o;
		out.write(Opcodes.GLOBAL);
		out.write("Pyro4.core\nURI\n".getBytes());
		out.write(Opcodes.EMPTY_TUPLE);
		out.write(Opcodes.NEWOBJ);
		out.write(Opcodes.MARK);
		currentPickler.save(uri.protocol);
		currentPickler.save(uri.objectid);
		currentPickler.save(null);
		currentPickler.save(uri.host);
		currentPickler.save(uri.port);
		out.write(Opcodes.TUPLE);
		out.write(Opcodes.BUILD);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy