//----------------------------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.event;

import org.huihoo.workflow.WorkflowException;

public final class WorkflowEventUtilities
{
	public static void enterEvent(WorkEventListener[] listeners, WorkEvent event)
	{
		if(listeners == null)
		{
			return;
		}
		
		for (int i = 0; i < listeners.length; ++i)
		{
			listeners[i].enter(event);
		}
	}
	public static void notifyEvent(WorkEventListener[] listeners, WorkEvent event, WorkflowException wcex)
	{
		if(listeners == null)
		{
			return;
		}
		for (int i = 0; i < listeners.length; ++i)
		{
			listeners[i].notify(event, wcex);
		}
	}

	public static void leaveEvent(WorkEventListener[] listeners, WorkEvent event)
	{
		if(listeners == null)
		{
			return;
		}
		
		for (int i = 0; i < listeners.length; ++i)
		{
			listeners[i].leave(event);
		}
	}

	public static void enterEvent(CaseEventListener[] listeners, CaseEvent event)
	{
		if(listeners == null)
		{
			return;
		}
		
		for (int i = 0; i < listeners.length; ++i)
		{
			listeners[i].enter(event);
		}
	}
	public static void notifyEvent(CaseEventListener[] listeners, CaseEvent event, WorkflowException wcex)
	{
		if(listeners == null)
		{
			return;
		}
		
		for (int i = 0; i < listeners.length; ++i)
		{
			listeners[i].notify(event, wcex);
		}
	}

	public static void leaveEvent(CaseEventListener[] listeners, CaseEvent event)
	{
		if(listeners == null)
		{
			return;
		}
		
		for (int i = 0; i < listeners.length; ++i)
		{
			listeners[i].leave(event);
		}
	}

}
