001/**
002 * RetrievalResult.java
003 * jCOLIBRI2 framework. 
004 * @author Juan A. Recio-Garc�a.
005 * GAIA - Group for Artificial Intelligence Applications
006 * http://gaia.fdi.ucm.es
007 * 03/01/2007
008 */
009package es.ucm.fdi.gaia.jcolibri.method.retrieve;
010
011import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase;
012
013/**
014 * Stores the retrieval information. It contais a <case, evaluation> pair.
015 * @author Juan A. Recio-Garcia
016 * @version 2.0
017 */
018public class RetrievalResult implements Comparable<RetrievalResult> {
019        
020        /** Constant used to retrieve all the cases in the retrieval methods. */
021        public static final int RETRIEVE_ALL = Integer.MAX_VALUE;
022        
023        private CBRCase _case;
024        private double  eval;
025        
026        /**
027         * Constructor
028         * @param _case retrieved
029         * @param eval is the similiarty with the query
030         */
031        public RetrievalResult(CBRCase _case, Double eval)
032        {
033                this._case = _case;
034                this.eval = eval;
035        }
036
037        /**
038         * @return Returns the _case.
039         */
040        public CBRCase get_case() {
041                return _case;
042        }
043
044        /**
045         * @param _case The _case to set.
046         */
047        public void set_case(CBRCase _case) {
048                this._case = _case;
049        }
050
051        /**
052         * @return Returns the eval.
053         */
054        public double getEval() {
055                return eval;
056        }
057
058        /**
059         * @param eval The eval to set.
060         */
061        public void setEval(double eval) {
062                this.eval = eval;
063        }
064        
065        public String toString()
066        {
067                return _case + " -> "+ eval;
068        }
069
070        public int compareTo(RetrievalResult o) {
071
072                if(!(o instanceof RetrievalResult))
073                        return 0;
074
075                RetrievalResult other = (RetrievalResult) o;
076
077                if(other.getEval()< eval)
078                        return -1;
079                else if(other.getEval() > eval)
080                        return 1;
081                else
082                        return 0;
083        }
084}