es.ucm.fdi.gaia.jcolibri.casebase.LinealCaseBase Maven / Gradle / Ivy
Show all versions of jCOLIBRI Show documentation
package es.ucm.fdi.gaia.jcolibri.casebase;
import java.util.Collection;
import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase;
import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCaseBase;
import es.ucm.fdi.gaia.jcolibri.cbrcore.CaseBaseFilter;
import es.ucm.fdi.gaia.jcolibri.cbrcore.Connector;
/**
* Basic Lineal Case Base that stores cases into a Collection.
* This class does not includes any kind of caching mechanism.
* That way, if you call to learn() or forget() cases are automatically stored/removed to/from the persistence media.
* This will be a performance problem if you plan to learn/forget in multiple steps. This case base is unrecommended for evaluation.
*
* Depending on your requirements the CachedLinealCaseBase could be more suitable.
*
* @author Juan A. Recio-García
* @see CachedLinealCaseBase
*
*/
public class LinealCaseBase implements CBRCaseBase {
private Connector connector;
private Collection cases;
public void init(Connector connector) {
this.connector = connector;
cases = this.connector.retrieveAllCases();
}
/* (non-Javadoc)
* @see jcolibri.cbrcore.CBRCaseBase#deInit()
*/
public void close() {
this.connector.close();
}
/* (non-Javadoc)
* @see jcolibri.cbrcore.CBRCaseBase#forgetCases(java.util.Collection)
*/
public void forgetCases(Collection cases) {}
/* (non-Javadoc)
* @see jcolibri.cbrcore.CBRCaseBase#getCases()
*/
public Collection getCases() {
return cases;
}
/* (non-Javadoc)
* @see jcolibri.cbrcore.CBRCaseBase#getCases(jcolibri.cbrcore.CaseBaseFilter)
*/
public Collection getCases(CaseBaseFilter filter) {return null;}
/* (non-Javadoc)
* @see jcolibri.cbrcore.CBRCaseBase#learnCases(java.util.Collection)
*/
public void learnCases(Collection cases) {
connector.storeCases(cases);
this.cases.addAll(cases);
}
}