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

net.razorvine.pickle.objects.ClassDictConstructor Maven / Gradle / Ivy

Go to download

A feature complete pickle protocol implementation (Python's builtin serialization mechanism)

The newest version!
package net.razorvine.pickle.objects;

import net.razorvine.pickle.IObjectConstructor;
import net.razorvine.pickle.PickleException;

/**
 * This object constructor creates ClassDicts (for unsupported classes).
 *
 * @author Irmen de Jong ([email protected])
 */
public class ClassDictConstructor implements IObjectConstructor {

	final String module;
	final String name;

	public ClassDictConstructor(String module, String name) {
		this.module = module;
		this.name = name;
	}

	public Object construct(Object[] args) {
		if (args.length > 0)
			throw new PickleException("expected zero arguments for construction of ClassDict (for "+module+"."+name+"). This happens when an unsupported/unregistered class is being unpickled that requires construction arguments. Fix it by registering a custom IObjectConstructor for this class.");
		return new ClassDict(module, name);
	}
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy