Bug 120523 [Commands] parameters: support serializing and deserializing of ParameterizedCommands
UA wants to be able to store a ParameterizedCommand as a String in documents like Help, Cheatsheets and Intro parts. The stored commands will be shown as links and when the user clicks the link we will deserialize from String back to ParameterizedCommand and execute it. The informational content of a ParameterizedCommand amounts to the command id and the ids and values of each of the parameters. We'd like to propose a standard serialization format and offer API for (de)serializing so that others can use it as well as us. The serialization format we have looks like this: commandId?param1Id=value1&param2Id=value2 Breaking it up, looks like this: commandId '?' param1Id '=' value1 '&' param2Id '=' value2 ... The commandId, paramIds and values are UTF-8 encoded to allow arbitrary characters to appear in them. I'm going to attach 2 patches for this. The first patch implements this functionality. It has changes to org.eclipse.core.commands and org.eclipse.ui.workbench The second patch is some JUnit tests to add to org.eclipse.ui.tests.
bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/ParameterizedCommand.java
import java.util.List;
import java.util.Map;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.internal.commands.util.Util;
/**
 * <p>
 * A command that has had one or more of its parameters specified. This class
 * serves as a utility class for developers that need to manipulate commands
 * with parameters. It handles the behaviour of generating a parameter map and a
 * human-readable name.
 * </p>
 * 
 * @since 3.1
 */
public final class ParameterizedCommand implements Comparable {
	/**
	 * The constant integer hash code value meaning the hash code has not yet
	 * been computed.
	 */
	private static final int HASH_CODE_NOT_COMPUTED = -1;
	/**
	 * A factor for computing the hash code for all parameterized commands.
	 */
	private static final int HASH_FACTOR = 89;
	/**
	 * The seed for the hash code for all parameterized commands.
	 */
	private static final int HASH_INITIAL = ParameterizedCommand.class
			.getName().hashCode();
	/**