//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/willow
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : willow@lists.sourceforge.net 
 */
//----------------------------END  LICENSE----------------------------

package org.huihoo.workflow.store;

import java.util.Hashtable;
import java.util.Map;

public class Constants
{
	/** Represents a SUBMIT  dispatch style */
	public static final int SUBMIT = 0x01;

	/** Represents a RESUBMIT dispatch style */
	public static final int RESUBMIT = 0x02;

	/** Represents a BACKTRACK dispatch style */
	public static final int BACKTRACK = 0x11;
		
	/** Represents a REVERSE dispatch style */
	public static final int REVERSE = 0x12;
	
	/**
	 * Key for the <code>participants</code> attribute. Use instances of List as
	 * values for this key. The list should contain java.lang.String instances.
	 */
	public static final String PARTICIPANTS = "participants";

	/**	
	 * Key for the <code>dispatchStyle</code> attribute. Use instances of Integer
	 * as values for this key. Constants defined in this class.
	 */
	public final static String DISPATCH_STYLE = "dispatchStyle";


	public static Map createMap()
	{
		return new Hashtable();
	}
	
	/**
	 * Sets the participants attribute in the specified map to the specified value.
	 */
	public static final void setParticipants(Map map, java.util.List list)
	{
		if(map == null)
		{
			return;
		}
		map.put(PARTICIPANTS, list);
	}

	/**
	 * Returns the participants attribute from the specified map.
	 */
	public static final java.util.List getParticipants(Map map)
	{
		if(map == null)
		{
			return null;
		}
		
		return (java.util.List) map.get(PARTICIPANTS);
	}

	/**
	 * Sets the opaque attribute in the specified map to the specified value.
	 */
	public static final void setDispatchStyle(Map map, int style)
	{
		if(map == null)
		{
			return;
		}
		
		map.put(DISPATCH_STYLE, new Integer(style));
	}

	/**
	 * Returns the opaque attribute from the specified map.
	 */
	public static final int getDispatchStyle(Map map)
	{
		if(map == null)
		{
			return SUBMIT;
		}
		
		Integer intObj = (Integer) map.get(DISPATCH_STYLE);
		if (intObj != null)
		{
			return intObj.intValue();
		}
		return SUBMIT;
	}
	
}
