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     */
009    package jcolibri.method.retrieve;
010    
011    import 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     */
018    public class RetrievalResult implements Comparable{
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(Object o) {
071                    if(!(o instanceof RetrievalResult))
072                            return 0;
073                    RetrievalResult other = (RetrievalResult)o;
074                    if(other.getEval()< eval)
075                            return -1;
076                    else if(other.getEval() > eval)
077                            return 1;
078                    else
079                            return 0;
080            }
081    }