jadex.bdi.tutorial.EnglishFrenchTranslationPlanE1 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-bdi Show documentation
Show all versions of jadex-applications-bdi Show documentation
The Jadex BDI applications package contain
several example applications, benchmarks and
testcases using BDI agents.
package jadex.bdi.tutorial;
import jadex.bdi.runtime.IExpression;
import jadex.bdi.runtime.Plan;
/**
* An english french translation plan can translate
* english words to french and is instantiated on demand.
*/
public class EnglishFrenchTranslationPlanE1 extends Plan
{
//-------- attributes --------
/** Query the tuples for a word. */
protected IExpression query_word;
//-------- constructors --------
/**
* Create a new plan.
*/
public EnglishFrenchTranslationPlanE1()
{
getLogger().info("Created: "+this);
this.query_word = getExpression("query_efword");
}
//-------- methods --------
/**
* The plan body.
*/
public void body()
{
String eword = (String)getParameter("word").getValue();
String fword = (String)query_word.execute("$eword", eword);
if(fword!=null)
{
getParameter("result").setValue(fword);
getLogger().info("Translating from english to german: "+eword+" - "+fword);
}
else
{
getLogger().info("Sorry word is not in database: "+eword);
fail();
}
}
}