//----------------------------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.script.compiler;
import java.util.Hashtable;

import org.huihoo.workflow.WorkflowException;

public class DelegatingListener implements ParseEventListener
{
	ParseEventListener delegate;
	Parser.Action action;
	Mark tmplStart, tmplStop;
	DelegatingListener(ParseEventListener delegate, Parser.Action action)
	{
		this.delegate = delegate;
		this.action = action;
	}
	void doAction(Mark start, Mark stop) throws WorkflowException
	{
		action.execute(start, stop);
	}

	public void beginScriptProcessing() throws WorkflowException
	{
		delegate.beginScriptProcessing();
	}
	public void endScriptProcessing() throws WorkflowException
	{
		delegate.endScriptProcessing();
	}
	public void handleDirective(String directive, Mark start, Mark stop, Hashtable attrs) throws WorkflowException
	{
		doAction(this.tmplStart, this.tmplStop);
		delegate.handleDirective(directive, start, stop, attrs);
	}
	public void handleScriptlet(Mark start, Mark stop, Hashtable attrs) throws WorkflowException
	{
		doAction(this.tmplStart, this.tmplStop);
		delegate.handleScriptlet(start, stop, attrs);
	}
	public void handleCharData(Mark start, Mark stop, char[] chars) throws WorkflowException
	{
		delegate.handleCharData(start, stop, chars);
	}
}
