KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > search > result > SearchResult


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: SearchResult.java,v $
31  * Revision 1.2 2005/04/09 17:19:56 colinmacleod
32  * Changed copyright text to GPL v2 explicitly.
33  *
34  * Revision 1.1.1.1 2005/03/10 17:52:38 colinmacleod
35  * Restructured ivata op around Hibernate/PicoContainer.
36  * Renamed ivata groupware.
37  *
38  * Revision 1.1 2004/08/01 11:40:29 colinmacleod
39  * Moved search classes to separate subproject.
40  *
41  * -----------------------------------------------------------------------------
42  */

43 package com.ivata.groupware.business.search.result;
44
45 import com.ivata.groupware.business.search.item.SearchItemDO;
46
47 /**
48  * <p>
49  * Represents a single result as returned by the search engine.
50  * </p>
51  *
52  * @since Jul 31, 2004
53  * @author Colin MacLeod
54  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
55  * @version $Revision: 1.2 $
56  */

57
58 public class SearchResult implements Comparable JavaDoc {
59     /**
60      * <p>
61      * The search item which matched a query.
62      * </p>
63      */

64     private SearchItemDO item;
65
66     /**
67      * <p>
68      * Indicates how well the item matched the query.
69      * </p>
70      */

71     private float weight;
72     /**
73      * <p>
74      * <code>Comparable</code> method used to sort items. This compares the
75      * weight of the two results.
76      * </p>
77      *
78      * @see Comparable#compareTo(Object)
79      */

80     public int compareTo(final Object JavaDoc compare) {
81         SearchResult otherResult = (SearchResult) compare;
82         if (otherResult.weight == weight) {
83             return 0;
84         }
85         if (otherResult.weight > weight) {
86             return 1;
87         }
88         return -1;
89     }
90
91     /**
92      * <p>
93      * The search item which matched a query.
94      * </p>
95      *
96      * @return Returns the item.
97      */

98     public final SearchItemDO getItem() {
99         return item;
100     }
101     /**
102      * <p>
103      * Indicates how well the item matched the query.
104      * </p>
105      *
106      * @return Returns the weight.
107      */

108     public final float getWeight() {
109         return weight;
110     }
111     /**
112      * <p>
113      * The search item which matched a query.
114      * </p>
115      *
116      * @param item The item to set.
117      */

118     public final void setItem(final SearchItemDO item) {
119         this.item = item;
120     }
121     /**
122      * <p>
123      * Indicates how well the item matched the query.
124      * </p>
125      *
126      * @param weight The weight to set.
127      */

128     public final void setWeight(final float weight) {
129         this.weight = weight;
130     }
131
132 }
133
Popular Tags