1 /***
2 Copyright (C) 2005 The Java Community
3
4 This program is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free Software
6 Foundation; either version 2 of the License, or (at your option) any later
7 version.
8
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 Place, Suite 330, Boston, MA 02111-1307 USA.
16 */
17 package org.bejug.javacareers.jobs.search.lucene;
18
19 import java.io.File;
20 import java.util.ArrayList;
21 import java.util.List;
22
23 /***
24 * @author Bavo Bruylandt (Last modified by $Author: ge0ffrey $)
25 * @version $Revision: 1.1 $ - $Date: 2005/08/26 07:58:30 $
26 */
27 class SearchResultImpl implements SearchResult {
28
29 /***
30 * a string containing the filename.
31 */
32 private String file;
33
34 /***
35 * the context.
36 */
37 private List context = new ArrayList();
38
39 /***
40 * a string containing the query.
41 */
42 private String query;
43
44 /***
45 * string containing the user.
46 */
47 private String user;
48
49 /***
50 * the weight.
51 */
52 private double weight;
53
54
55 /***
56 * constructor.
57 */
58 public SearchResultImpl() {
59 super();
60 }
61
62 /***
63 * @param file String
64 * @param context String
65 * @param query String
66 */
67 public SearchResultImpl(String file, List context, String query) {
68 this.file = file;
69 this.context = context;
70 this.query = query;
71 }
72
73 /***
74 * @param file String
75 * @param context String
76 * @param query String
77 */
78 public SearchResultImpl(File file, List context, String query) {
79 this.file = file.getAbsolutePath();
80 this.context = context;
81 this.query = query;
82 }
83
84 /***
85 * @return the wanted query.
86 */
87 public String getQuery() {
88 return query;
89 }
90
91 /***
92 * @param query String containing the query.
93 */
94 public void setQuery(String query) {
95 this.query = query;
96 }
97
98 /***
99 * @return file
100 */
101 public String getFile() {
102 return file;
103 }
104
105 /***
106 * @param file String
107 */
108 public void setFile(String file) {
109 this.file = file;
110 }
111
112 /***
113 * @return context
114 */
115 public List getContext() {
116 return context;
117 }
118
119 /***
120 * @param context a List containing the context.
121 */
122 public void setContext(List context) {
123 this.context = context;
124 }
125
126 /***
127 * adds a context to the list.
128 * @param contextString a String to add to the context-list.
129 */
130 public void addContext(String contextString) {
131 context.add(contextString);
132 }
133
134 /***
135 * Gets the weight of this hit.
136 * @return weight for this hit.
137 */
138 public double getWeight() {
139 return weight;
140 }
141
142 /***
143 * Sets the weight for this hit.
144 * @param weight The weight for this hit.
145 */
146 public void setWeight(double weight) {
147 this.weight = weight;
148 }
149
150
151 /***
152 * a string representation of the object.
153 *
154 * @return a string representation of the object.
155 */
156 public String toString() {
157 final StringBuffer buf = new StringBuffer();
158 buf.append("SearchResultImpl");
159 buf.append("{file=").append(file);
160 buf.append(",context=").append(context);
161 buf.append(",query=").append(query);
162 buf.append(",weight=").append(weight);
163 buf.append('}');
164 return buf.toString();
165 }
166
167 /***
168 * @return a String indicating the user.
169 */
170 public String getUser() {
171 return user;
172 }
173
174 /***
175 * @param user a String containing the user.
176 */
177 public void setUser(String user) {
178 this.user = user;
179 }
180 }
181
182 /***
183 * $Log: SearchResultImpl.java,v $
184 * Revision 1.1 2005/08/26 07:58:30 ge0ffrey
185 * split up the sources in service, serviceimpl and webclient
186 *
187 * Revision 1.8 2005/08/09 12:59:56 bavo_jcs
188 * Optimized imports
189 *
190 * Revision 1.7 2005/08/08 12:08:02 bme_jcs
191 * resolved checkstyle errors
192 *
193 * Revision 1.6 2005/08/08 09:38:23 bme_jcs
194 * resolved checkstyle errors
195 *
196 * Revision 1.5 2005/07/12 10:42:39 bavo_jcs
197 * PDF Ajax integration, added user info
198 *
199 * Revision 1.4 2005/07/11 15:01:41 bavo_jcs
200 * PDF Ajax integration
201 *
202 * Revision 1.3 2005/06/14 12:05:53 schauwvliege
203 * CheckStyle and fixing tests
204 *
205 * Revision 1.2 2005/06/09 08:18:52 bejug_cc
206 * Fix initial import
207 *
208 * Revision 1.1 2005/05/23 17:09:48 sja
209 * Removed Lucene prefix.
210 *
211 * Revision 1.1 2005/05/23 15:42:00 bbr
212 * added weight to lucene
213 *
214 * Revision 1.1 2005/05/23 08:46:33 PSONG09
215 * added feeder source files to project
216 *
217 * Revision 1.3 2005/05/23 07:10:18 stephan_janssen
218 * Code cleanup.
219 *
220 * Revision 1.2 2005/05/20 07:45:38 bavo_jcs
221 * -lucene changes
222 *
223 * Revision 1.1 2005/05/18 15:46:39 bavo_jcs
224 * -adeed lucene service
225 *
226 */