KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > data > search > JahiaSearchHit


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12

13 // DJ 03.01.2001
14

15 package org.jahia.data.search;
16
17 import java.util.ArrayList JavaDoc;
18
19 import org.jahia.services.pages.JahiaPage;
20 import org.jahia.services.search.ParsedObject;
21
22 /**
23  * This class defines what does a search "hit" looks like.
24  * One hit is one page found by jahia containing at least one time the searchstring
25  * in one of its fields.
26  *
27  * @see org.jahia.data.search.JahiaSearchResult
28  * @see org.jahia.engines.search.Search_Engine
29  * @author DJ
30  */

31 public class JahiaSearchHit implements JahiaSearchHitInterface
32 {
33
34     public int id;
35     public int type; // field type
36
public Object JavaDoc obj;
37
38     public int wordcount;
39
40     public String JavaDoc fileDownloadUrl = "#";
41     public String JavaDoc pageUrl = "#";
42     public ArrayList JavaDoc languageCodes = new ArrayList JavaDoc();
43
44     /**
45      * A small string coming from this page, usually containing one of the searched words.
46      * Currently: one of the fields containing this word.
47      */

48     public String JavaDoc teaser;
49
50     public int pageID;
51
52     /** Deprecated , use obj instead */
53     public JahiaPage page;
54
55     private ParsedObject parsedObject;
56
57     /**
58      *
59      * @param parsedObject ParsedObject
60      */

61     public JahiaSearchHit(ParsedObject aParsedObject){
62         this.parsedObject = aParsedObject;
63     }
64
65     /**
66      * Returns the list of locales available for this hit.
67      * @return ArrayList
68      */

69     public ArrayList JavaDoc getLanguageCodes(){
70         return this.languageCodes;
71     }
72
73     /**
74      * Returns the list of locales available for this hit.
75      * @return ArrayList
76      */

77     public void setLanguageCodes(ArrayList JavaDoc languagesCode){
78         this.languageCodes = languagesCode;
79     }
80
81     /**
82      * Returns the hit score
83      */

84     public int getScore(){
85         return this.wordcount;
86     }
87
88     /**
89      *
90      * @param score int
91      */

92     public void setScore(int score){
93         this.wordcount = score;
94     }
95
96     /**
97      * Returns a small teaser about this hit
98      */

99     public String JavaDoc getTeaser(){
100         return this.teaser;
101     }
102
103     /**
104      * Returns a small teaser about this hit
105      */

106     public void setTeaser(String JavaDoc aTeaser){
107         this.teaser = aTeaser;
108     }
109
110     /**
111      * Returns a ParsedObject instance of this hit
112      * @return ParsedObject
113      */

114     public ParsedObject getParsedObject(){
115         return this.parsedObject;
116     }
117
118     /**
119      * Sets a ParsedObject
120      */

121     public void setParsedObject(ParsedObject aParsedObject){
122         this.parsedObject = aParsedObject;
123     }
124
125     //-------------------------------------------------------------------------
126
/**
127      * Compare between two objects, sort by their wordcount.
128      *
129      * @param Object
130      */

131     public int compareTo(Object JavaDoc anObj) throws ClassCastException JavaDoc {
132
133         JahiaSearchHitInterface hit = (JahiaSearchHitInterface)anObj;
134         if ( hit.getScore() > this.wordcount ){
135             return 1;
136         } else if ( hit.getScore() == this.wordcount ){
137             return 0;
138         }
139         return -1;
140     }
141
142 }
143
Popular Tags