001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.search;
020
021
022
023/**
024 * A Single Record of a Search Result
025 */
026public class SearchResulItemImpl implements SearchResulItem {
027    
028        private String title;
029    private float score;
030    private int recordsSearched;
031    private String id;
032    private String key;
033    private String url;
034    private String summary;
035    private String custom1;
036    private String custom2;
037    private String custom3;
038    private String custom4;
039        private String categoryTree;
040        private String category;
041        private String mimeType;
042        private String author;
043        private String size;
044        private String contextSummary;
045    
046    /**
047     * @param id
048     * @param title
049     * @param score
050     * @param key 
051     * @param url 
052     * @param summary
053     * @param custom1 
054     * @param custom2 
055     * @param custom3 
056     * @param custom4 
057     * @param mimeType 
058     * @param author 
059     * @param size 
060     */
061    public SearchResulItemImpl(String id,String title, float score, String key, String url,String summary,String contextSummary,
062                String categoryTree,String category,
063            String custom1,String custom2,String custom3,String custom4, String mimeType, String author, String size) {
064        this.id = id;
065        this.title = title;
066        this.score = score;
067        //this.recordsSearched = recordsSearched;
068        this.key = key;
069        this.url = url;
070        this.summary = summary;
071        this.contextSummary = contextSummary;
072
073        this.categoryTree = categoryTree;
074        this.category = category;
075        this.custom1 = custom1;
076        this.custom2 = custom2;
077        this.custom3 = custom3;
078        this.custom4 = custom4;
079        this.mimeType = mimeType;
080        this.author = author;
081        this.size = size;
082    }
083    @Override
084    public int getRecordsSearched() {
085        return recordsSearched;
086    }
087    @Override
088    public float getScore() {
089        return score;
090    }
091    @Override
092    public String getSummary() {
093        return summary;
094    }
095    @Override
096    public String getTitle() {
097        return title;
098    }
099    @Override
100    public String getId() {
101        return id;
102    }
103    
104    
105    @Override
106    public String getKey() {
107        return key;
108    }
109    
110    @Override
111    public String getUrl() {
112        return url;
113    }
114    @Override
115    public String getCustom1() {
116        return custom1;
117    }
118    @Override
119    public String getCustom2() {
120        return custom2;
121    }
122    @Override
123    public String getCustom3() {
124        return custom3;
125    }
126    @Override
127    public String getCustom4() {
128        return custom4;
129    }
130    
131    public String getCustom(int index) throws SearchException {
132        if(index==1) return custom1;
133        if(index==2) return custom2;
134        if(index==3) return custom3;
135        if(index==4) return custom4;
136        
137        throw new SearchException("invalid index ["+index+"], valid index is [1,2,3,4]");
138    }
139    
140        /**
141         * @return the category
142         */
143        public String getCategory() {
144                return category;
145        }
146        /**
147         * @return the categoryTree
148         */
149        public String getCategoryTree() {
150                return categoryTree;
151        }
152        /**
153         * @return the mimeType
154         */
155        public String getMimeType() {
156                return mimeType;
157        }
158        /**
159         * @return the author
160         */
161        public String getAuthor() {
162                return author;
163        }
164        /**
165         * @return the size
166         */
167        public String getSize() {
168                return size;
169        }
170        
171
172    /**
173         * @return the contextSummary
174         */
175        public String getContextSummary() {
176                return contextSummary;
177        }
178}