001    /**
002     * CBRQuery.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     * 05/01/2007
008     */
009    package jcolibri.cbrcore;
010    
011    import jcolibri.exception.AttributeAccessException;
012    
013    
014    /**
015     * Represents a CBR query defining it as a description of the problem/case. 
016     * Cases are composed by description, solution, justification of solution and result, so a query is only the description part of a case.
017     * This is: a case without solution or result.
018     * 
019     * @see jcolibri.cbrcore.CBRCase
020     */
021    public class CBRQuery{
022            
023            CaseComponent description;
024    
025            /**
026             * Returns the description component.
027             */
028            public CaseComponent getDescription() {
029                    return description;
030            }
031    
032            /**
033             * Sets the description component.
034             */
035            public void setDescription(CaseComponent description) {
036                    this.description = description;
037            }
038            
039            /**
040             * Returns the ID value of the Query/Case that is the ID attribute of its description component.
041             */
042            public Object getID()
043            {
044                    if(this.description==null)
045                            return null;
046                    else
047                            try {
048                                    return description.getIdAttribute().getValue(description);
049                            } catch (AttributeAccessException e) {
050                                    return null;
051                            }
052            }
053            
054        public String toString()
055        {
056            return "[Description: "+description+"]";
057        }
058    }