| 1 6 7 package com.dotmarketing.beans; 8 9 10 11 15 public class SearchResult extends Object implements java.io.Serializable { 16 17 18 private static final long serialVersionUID = 1L; 19 20 21 private String title; 22 23 24 private String url; 25 26 27 private String desc; 28 29 30 private String score; 31 32 33 public SearchResult() { 34 } 35 36 37 38 42 public String getTitle() { 43 return this.title; 44 } 45 46 50 public void setTitle(String title) { 51 this.title = title; 52 } 53 54 58 public String getUrl() { 59 return this.url; 60 } 61 62 66 public void setUrl(String url) { 67 this.url = url; 68 } 69 70 74 public String getDesc() { 75 return this.desc; 76 } 77 78 82 public String getPrettyDesc() { 83 if(this.desc.length() > 3){ 84 String prettyDesc = this.desc; 85 prettyDesc = prettyDesc.replaceAll(" "," "); 86 prettyDesc = prettyDesc.replaceAll(" "," "); 87 return prettyDesc; 88 } 89 return this.desc; 90 } 91 92 96 public void setDesc(String desc) { 97 desc = desc.replaceAll("@import.*;", ""); 98 this.desc = desc; 99 } 100 101 105 public String getScore() { 106 return this.score; 107 } 108 109 113 public int getPercentScore(){ 114 int percentScore = 0; 115 double fScore = 0; 116 try{ 117 fScore = Float.parseFloat(this.score); 118 }catch(Exception e){ 119 120 } 121 percentScore = (int) (fScore * 100.0f); 122 123 return percentScore; 124 } 125 126 130 public void setScore(String score) { 131 this.score = score; 132 } 133 134 135 138 public boolean equals(Object arg0) { 139 140 String url1 = ((SearchResult)arg0).getUrl(); 141 String 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 158 public int hashCode() { 159 try { 160 return Integer.parseInt(score); 161 } 162 catch (Exception e) { 163 164 } 165 return 0; 166 } 167 } 168 | Popular Tags |