1 package org.roller.pojos; 2 3 import org.roller.RollerException; 4 import org.roller.model.BookmarkManager; 5 import org.roller.model.Roller; 6 import org.roller.model.RollerFactory; 7 8 import java.io.Serializable ; 9 10 23 public class BookmarkData extends org.roller.pojos.PersistentObject 24 implements Serializable , Comparable 25 { 26 static final long serialVersionUID = 2315131256728236003L; 27 28 protected FolderData folder; 29 30 protected String id = null; 31 protected String name; 32 protected String description; 33 protected String url; 34 protected Integer weight; 35 protected Integer priority; 36 protected String image; 37 protected String feedUrl; 38 39 protected BookmarkManager bookmarkManager = null; 40 41 43 44 public BookmarkData() 45 { 46 } 47 48 public BookmarkData( 49 FolderData parent, 50 String name, 51 String desc, 52 String url, 53 String feedUrl, 54 Integer weight, 55 Integer priority, 56 String image) 57 { 58 this.folder = parent; 59 this.name = name; 60 this.description = desc; 61 this.url = url; 62 this.feedUrl = feedUrl; 63 this.weight = weight; 64 this.priority = priority; 65 this.image = image; 66 } 67 68 69 public BookmarkData(BookmarkManager bmgr) 70 { 71 bookmarkManager = bmgr; 72 } 73 74 76 82 public String getId() 83 { 84 return this.id; 85 } 86 87 88 public void setId(String id) 89 { 90 this.id = id; 91 } 92 93 103 public String getName() 104 { 105 return this.name; 106 } 107 108 109 public void setName(String name) 110 { 111 this.name = name; 112 } 113 114 121 public String getDescription() 122 { 123 return this.description; 124 } 125 126 127 public void setDescription(String description) 128 { 129 this.description = description; 130 } 131 132 139 public String getUrl() 140 { 141 return this.url; 142 } 143 144 145 public void setUrl(String url) 146 { 147 this.url = url; 148 } 149 150 161 public java.lang.Integer getWeight() 162 { 163 return this.weight; 164 } 165 166 167 public void setWeight(java.lang.Integer weight) 168 { 169 this.weight = weight; 170 } 171 172 183 public java.lang.Integer getPriority() 184 { 185 return this.priority; 186 } 187 188 189 public void setPriority(java.lang.Integer priority) 190 { 191 this.priority = priority; 192 } 193 194 199 public String getImage() 200 { 201 return this.image; 202 } 203 204 205 public void setImage(String image) 206 { 207 this.image = image; 208 } 209 210 215 public String getFeedUrl() 216 { 217 return this.feedUrl; 218 } 219 220 221 public void setFeedUrl(String feedUrl) 222 { 223 this.feedUrl = feedUrl; 224 } 225 226 228 232 public org.roller.pojos.FolderData getFolder() 233 { 234 return this.folder; 235 } 236 237 238 public void setFolder(org.roller.pojos.FolderData folder) 239 { 240 this.folder = folder; 241 } 242 243 245 public String toString() 246 { 247 StringBuffer str = new StringBuffer ("{"); 248 249 str.append("id=" + id + " " + "name=" + name + " " + "description=" + 250 description + " " + "url=" + url + " " + "weight=" + 251 weight + " " + "priority=" + priority + " " + "folderId=" + 252 "image=" + image + " " + "feedUrl=" + 253 feedUrl); 254 str.append('}'); 255 256 return (str.toString()); 257 } 258 259 public boolean equals(Object pOther) 260 { 261 if (pOther instanceof BookmarkData) 262 { 263 BookmarkData lTest = (BookmarkData) pOther; 264 boolean lEquals = true; 265 266 if (this.id == null) 267 { 268 lEquals = lEquals && (lTest.id == null); 269 } 270 else 271 { 272 lEquals = lEquals && this.id.equals(lTest.id); 273 } 274 275 if (this.name == null) 276 { 277 lEquals = lEquals && (lTest.name == null); 278 } 279 else 280 { 281 lEquals = lEquals && this.name.equals(lTest.name); 282 } 283 284 if (this.description == null) 285 { 286 lEquals = lEquals && (lTest.description == null); 287 } 288 else 289 { 290 lEquals = lEquals && 291 this.description.equals(lTest.description); 292 } 293 294 if (this.url == null) 295 { 296 lEquals = lEquals && (lTest.url == null); 297 } 298 else 299 { 300 lEquals = lEquals && this.url.equals(lTest.url); 301 } 302 303 if (this.weight == null) 304 { 305 lEquals = lEquals && (lTest.weight == null); 306 } 307 else 308 { 309 lEquals = lEquals && this.weight.equals(lTest.weight); 310 } 311 312 if (this.priority == null) 313 { 314 lEquals = lEquals && (lTest.priority == null); 315 } 316 else 317 { 318 lEquals = lEquals && this.priority.equals(lTest.priority); 319 } 320 321 if (this.image == null) 331 { 332 lEquals = lEquals && (lTest.image == null); 333 } 334 else 335 { 336 lEquals = lEquals && this.image.equals(lTest.image); 337 } 338 339 if (this.feedUrl == null) 340 { 341 lEquals = lEquals && (lTest.feedUrl == null); 342 } 343 else 344 { 345 lEquals = lEquals && this.feedUrl.equals(lTest.feedUrl); 346 } 347 348 return lEquals; 349 } 350 else 351 { 352 return false; 353 } 354 } 355 356 public int hashCode() 357 { 358 int result = 17; 359 result = (37 * result) + 360 ((this.id != null) ? this.id.hashCode() : 0); 361 result = (37 * result) + 362 ((this.name != null) ? this.name.hashCode() : 0); 363 result = (37 * result) + 364 ((this.description != null) ? this.description.hashCode() : 0); 365 result = (37 * result) + 366 ((this.url != null) ? this.url.hashCode() : 0); 367 result = (37 * result) + 368 ((this.weight != null) ? this.weight.hashCode() : 0); 369 result = (37 * result) + 370 ((this.priority != null) ? this.priority.hashCode() : 0); 371 result = (37 * result) + 372 ((this.folder != null) ? this.folder.hashCode() : 0); 373 result = (37 * result) + 374 ((this.image != null) ? this.image.hashCode() : 0); 375 result = (37 * result) + 376 ((this.feedUrl != null) ? this.feedUrl.hashCode() : 0); 377 378 return result; 379 } 380 381 384 public void setData(org.roller.pojos.PersistentObject otherData) 385 { 386 this.id = ((BookmarkData) otherData).id; 387 this.name = ((BookmarkData) otherData).name; 388 this.description = ((BookmarkData) otherData).description; 389 this.url = ((BookmarkData) otherData).url; 390 this.weight = ((BookmarkData) otherData).weight; 391 this.priority = ((BookmarkData) otherData).priority; 392 this.folder = ((BookmarkData) otherData).folder; 393 this.image = ((BookmarkData) otherData).image; 394 this.feedUrl = ((BookmarkData) otherData).feedUrl; 395 } 396 397 400 public int compareTo(Object o) 401 { 402 return bookmarkComparator.compare(this, o); 403 } 404 405 private BookmarkComparator bookmarkComparator = new BookmarkComparator(); 406 407 410 public void setBookmarkManager(BookmarkManager bmgr) 411 { 412 bookmarkManager = bmgr; 413 } 414 415 public boolean canSave() throws RollerException 416 { 417 Roller roller = RollerFactory.getRoller(); 418 if (roller.getUser().equals(UserData.SYSTEM_USER)) 419 { 420 return true; 421 } 422 if (roller.getUser().equals(getFolder().getWebsite().getUser())) 423 { 424 return true; 425 } 426 return false; 427 } 428 } | Popular Tags |