/**
 * WPCLCommand.java
 * Created Mar 12, 2007
 * Copyright (C) Tandberg Television 2007
 */
package com.tandbergtv.workflow.message;

import java.util.HashMap;
import java.util.Map;

/**
 * Represents a command and its associated parameters. A command is usually attached to an async
 * message received by the workflow system, but can also be attached to sync messages as well.
 * 
 * @author Sahil Verma
 */
public class WPCLCommand {
	
	private String name;
	
	private Map<String, String> parameters;
	
	/**
	 * A simple do-nothing command 
	 */
	public static final WPCLCommand NULL = new WPCLCommand("null");

	/**
	 * Creates a WPCLCommand
	 * @param name The name of the command
	 */
	public WPCLCommand(String name) {
		this.name = name;
		this.parameters = new HashMap<String, String>();
	}
	
	/**
	 * Creates a WPCLCommand
	 * @param name
	 * @param parameters
	 */
	public WPCLCommand(String name, Map<String, String> parameters) {
		this(name);
		this.parameters = parameters;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return this.name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the parameters
	 */
	public Map<String, String> getParameters() {
		return this.parameters;
	}

	/**
	 * @param parameters the parameters to set
	 */
	public void setParameters(Map<String, String> parameters) {
		this.parameters = parameters;
	}
	
	/**
	 * Adds a key-value pair to the parameters
	 * 
	 * @param name
	 * @param value
	 */
	public void addParameter(String name, String value) {
		this.parameters.put(name, value);
	}
	
	/**
	 * Returns the value of the specified parameter
	 * @param name
	 * @return The parameter value
	 */
	public String getParameterValue(String name) {
		return this.parameters.get(name);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return this.name;
	}
}
