KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > beans > SearchResult


1 /*
2  * SearchResult.java
3  *
4  * Created on August 21, 2002, 5:30 PM
5  */

6
7 package com.dotmarketing.beans;
8
9
10
11 /**
12  *
13  * @author rocco
14  */

15 public class SearchResult extends Object JavaDoc implements java.io.Serializable JavaDoc {
16     
17     
18     private static final long serialVersionUID = 1L;
19
20     /** Holds value of property title. */
21     private String JavaDoc title;
22     
23     /** Holds value of property url. */
24     private String JavaDoc url;
25     
26     /** Holds value of property desc. */
27     private String JavaDoc desc;
28     
29     /** Holds value of property score. */
30     private String JavaDoc score;
31     
32     /** Creates new Page */
33     public SearchResult() {
34     }
35     
36
37     
38     /** Getter for property title.
39      * @return Value of property title.
40      *
41      */

42     public String JavaDoc getTitle() {
43         return this.title;
44     }
45     
46     /** Setter for property title.
47      * @param title New value of property title.
48      *
49      */

50     public void setTitle(String JavaDoc title) {
51         this.title = title;
52     }
53     
54     /** Getter for property url.
55      * @return Value of property url.
56      *
57      */

58     public String JavaDoc getUrl() {
59         return this.url;
60     }
61     
62     /** Setter for property url.
63      * @param url New value of property url.
64      *
65      */

66     public void setUrl(String JavaDoc url) {
67         this.url = url;
68     }
69
70     /** Getter for property desc.
71      * @return Value of property desc.
72      *
73      */

74     public String JavaDoc getDesc() {
75         return this.desc;
76     }
77     
78     /** Getter for property desc.
79      * @return Value of property desc.
80      *
81      */

82     public String JavaDoc getPrettyDesc() {
83     if(this.desc.length() > 3){
84         String JavaDoc prettyDesc = this.desc;
85         prettyDesc = prettyDesc.replaceAll(" "," ");
86         prettyDesc = prettyDesc.replaceAll(" "," ");
87         return prettyDesc;
88     }
89     return this.desc;
90     }
91     
92     /** Setter for property desc.
93      * @param desc New value of property desc.
94      *
95      */

96     public void setDesc(String JavaDoc desc) {
97         desc = desc.replaceAll("@import.*;", "");
98         this.desc = desc;
99     }
100     
101     /** Getter for property score.
102      * @return Value of property score.
103      *
104      */

105     public String JavaDoc getScore() {
106         return this.score;
107     }
108     
109     /** Getter for property score.
110      * @return Value of property score.
111      *
112      */

113     public int getPercentScore(){
114         int percentScore = 0;
115         double fScore = 0;
116         try{
117             fScore = Float.parseFloat(this.score);
118         }catch(Exception JavaDoc e){
119             
120         }
121         percentScore = (int) (fScore * 100.0f);
122         
123         return percentScore;
124     }
125     
126     /** Setter for property score.
127      * @param score New value of property score.
128      *
129      */

130     public void setScore(String JavaDoc score) {
131         this.score = score;
132     }
133
134
135     /* (non-Javadoc)
136      * @see java.lang.Object#equals(java.lang.Object)
137      */

138     public boolean equals(Object JavaDoc arg0) {
139
140         String JavaDoc url1 = ((SearchResult)arg0).getUrl();
141         String JavaDoc url2 = this.getUrl();
142
143         if (url1 !=null) url1 = url1.replaceAll("index.dot","");
144         if (url2 !=null) url2 = url2.replaceAll("index.dot","");
145         
146         boolean ret = false;
147         if (url1!=null) {
148             ret = url1.equals(url2);
149         }
150         
151         return ret;
152     }
153
154
155     /* (non-Javadoc)
156      * @see java.lang.Object#hashCode()
157      */

158     public int hashCode() {
159         try {
160             return Integer.parseInt(score);
161         }
162         catch (Exception JavaDoc e) {
163             
164         }
165         return 0;
166     }
167 }
168
Popular Tags