// (c) MIT 2003.  All rights reserved.

package rec.annotate.transcript;
import java.rmi.*;
import metaglue.*;
import metaglue.AgentPrimer.*;

public class TranscriberEHA implements ExceptionHandlerInterface,rec.annotate.transcript.Transcriber,speech.tools.Speech
{
	private AgentExceptionHandler aeh;
	private Transcriber agent;
	private AgentID agentID;
	private MetagluePrimitives mp;
	public TranscriberEHA(MetagluePrimitives ap,AgentID agentID,Catalog c) throws RemoteException
	{
		aeh=new AgentExceptionHandler(ap,agentID,c);
		mp=ap;
		this.agentID=agentID;
		instantiate(null);
	}
	public void instantiate(Agent a)
	{
		agent=(Transcriber)a;
	}
	public void replaceExceptionHandler(AgentExceptionHandler r)
	{
		aeh=r;
	}
	public void tell(agentland.util.Secret param0) throws java.rmi.RemoteException
	{
		boolean repeat;
		if(agent==null)
		{
			instantiate(mp.reliesOnSynch(agentID));
		}
		do
		{
			try
			{
				repeat=false;
				agent.tell(param0);
			}
			catch(RemoteException e) {repeat=aeh.handleRemoteException(e,this,"tell");}
		}
		while(repeat==true);
	}
	public boolean alive() throws java.rmi.RemoteException
	{
		boolean repeat;
		if(agent==null)
		{
			instantiate(mp.reliesOnSynch(agentID));
		}
		do
		{
			try
			{
				repeat=false;
				return(agent.alive());
			}
			catch(RemoteException e) {repeat=aeh.handleRemoteException(e,this,"alive");}
		}
		while(repeat==true);
		throw new RemoteException();
	}
	public metaglue.AgentID getAgentID() throws java.rmi.RemoteException
	{
		boolean repeat;
		if(agent==null)
		{
			instantiate(mp.reliesOnSynch(agentID));
		}
		do
		{
			try
			{
				repeat=false;
				return(agent.getAgentID());
			}
			catch(RemoteException e) {repeat=aeh.handleRemoteException(e,this,"getAgentID");}
		}
		while(repeat==true);
		throw new RemoteException();
	}
	public metaglue.AgentID getMetaglueAgentID() throws java.rmi.RemoteException
	{
		boolean repeat;
		if(agent==null)
		{
			instantiate(mp.reliesOnSynch(agentID));
		}
		do
		{
			try
			{
				repeat=false;
				return(agent.getMetaglueAgentID());
			}
			catch(RemoteException e) {repeat=aeh.handleRemoteException(e,this,"getMetaglueAgentID");}
		}
		while(repeat==true);
		throw new RemoteException();
	}
	public void shutdown() throws java.rmi.RemoteException
	{
		boolean repeat;
		if(agent==null)
		{
			instantiate(mp.reliesOnSynch(agentID));
		}
		do
		{
			try
			{
				repeat=false;
				agent.shutdown();
			}
			catch(RemoteException e) {repeat=aeh.handleRemoteException(e,this,"shutdown");}
		}
		while(repeat==true);
	}
	public java.util.Vector getHistory() throws java.rmi.RemoteException
	{
		boolean repeat;
		if(agent==null)
		{
			instantiate(mp.reliesOnSynch(agentID));
		}
		do
		{
			try
			{
				repeat=false;
				return(agent.getHistory());
			}
			catch(RemoteException e) {repeat=aeh.handleRemoteException(e,this,"getHistory");}
		}
		while(repeat==true);
		throw new RemoteException();
	}
	public java.lang.String getHistoryElement(int param0) throws java.rmi.RemoteException
	{
		boolean repeat;
		if(agent==null)
		{
			instantiate(mp.reliesOnSynch(agentID));
		}
		do
		{
			try
			{
				repeat=false;
				return(agent.getHistoryElement(param0));
			}
			catch(RemoteException e) {repeat=aeh.handleRemoteException(e,this,"getHistoryElement");}
		}
		while(repeat==true);
		throw new RemoteException();
	}
	public void resetHistory() throws java.rmi.RemoteException
	{
		boolean repeat;
		if(agent==null)
		{
			instantiate(mp.reliesOnSynch(agentID));
		}
		do
		{
			try
			{
				repeat=false;
				agent.resetHistory();
			}
			catch(RemoteException e) {repeat=aeh.handleRemoteException(e,this,"resetHistory");}
		}
		while(repeat==true);
	}
	public rec.annotate.transcript.Transcript getTranscript() throws java.rmi.RemoteException
	{
		boolean repeat;
		if(agent==null)
		{
			instantiate(mp.reliesOnSynch(agentID));
		}
		do
		{
			try
			{
				repeat=false;
				return(agent.getTranscript());
			}
			catch(RemoteException e) {repeat=aeh.handleRemoteException(e,this,"getTranscript");}
		}
		while(repeat==true);
		throw new RemoteException();
	}
}
