/* * OAASolver.java * * * Copyright (c) 2004 David Hjelm . * * * Project homepage: . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ package se.gu.ling.trindikit.oaa.common; import com.sri.oaa2.icl.*; import java.util.*; /** Abstract base class which can be extended to create solvers, classes that encapsulate the functionality to solve a OAA query and can be added to an OAAAgent with the addSolver method. Each instance o an OAASolver has a corresponding solvable. @author David Hjelm @version February 2003 */ public abstract class OAASolver{ private IclTerm solvable; /** Called from the constructor of the implementing class. @param solvable the solvable for this solver. Internally represented as an IclTerm. */ public OAASolver(String solvable){ this.solvable=IclUtils.fromString(false,solvable); } /** Called from the constructor of the implementing class. @param solvable the solvable for this solver. */ public OAASolver(IclTerm solvable){ this.solvable = solvable; } /** Abstract method for solving OAA queries. This method is called from the OAAAgent when it receives an incoming OAA query. Implement this for every solver. @param goal The OAA query. @param params List of additional parameters passed with the query @param answers Answers to query. If solve does not have any answers to goal, i.e. goal is false according to this solver, return false. Otherwise, add the answer(s), which should be IclTerms unifiable with goal, to answers and return true. If exceptions occur, they can be encapsulated using SolveException and propagated to the caller of the method. */ public abstract boolean solve(IclTerm goal,IclList params,IclList answers) throws SolveException; /** returns the solvable associated with this solver */ public IclTerm getSolvable(){ return (IclTerm)solvable.clone(); } /** returns the solvable associated with this solver represented as a String */ public String getSolvableString(){ return solvable.toIdentifyingString(); } }