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