//----------------------------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.WorkflowComponent;
import org.huihoo.workflow.WorkflowSerializable;

/**
 * <p>
 * The root class from which all event state objects shall be derived.
 * <p>
 * All Events are constructed with a reference to the object, the "source",
 * that is logically deemed to be the object upon which the Event in question
 * initially occurred upon.
 */

public class EventObject implements WorkflowSerializable
{
	/**
	 * The object on which the Event initially occurred.
	 */
	protected transient WorkflowComponent source;

	/**
	 * Constructs a prototypical Event.
	 *
	 * @param    source    The object on which the Event initially occurred.
	 */
	public EventObject(WorkflowComponent source)
	{
		if (source == null)
		{
			throw new IllegalArgumentException("null source");
		}

		this.source = source;
	}

	/**
	 * The object on which the Event initially occurred.
	 *
	 * @return   The object on which the Event initially occurred.
	 */
	public WorkflowComponent getSource()
	{
		return source;
	}

	/**
	 * Returns a String representation of this EventObject.
	 *
	 * @return  A a String representation of this EventObject.
	 */
	public String toString()
	{
		return getClass().getName() + "[source=" + source + "]";
	}
}
