1 31 package org.blojsom.blog.database; 32 33 import org.blojsom.blog.Comment; 34 import org.blojsom.blog.Entry; 35 import org.blojsom.util.BlojsomUtils; 36 37 import java.io.Serializable ; 38 import java.util.Date ; 39 import java.util.Map ; 40 import java.util.HashMap ; 41 import java.util.Locale ; 42 import java.text.SimpleDateFormat ; 43 44 51 public class DatabaseComment implements Comment, Serializable { 52 53 protected Integer _id; 54 protected Integer _blogId; 55 protected Integer _blogEntryId; 56 protected Entry _entry; 57 58 protected String _author; 59 protected String _authorEmail; 60 protected String _authorURL; 61 protected String _comment; 62 protected Date _commentDate; 63 protected Map _metaData; 64 protected Integer _parentId; 65 protected String _status; 66 protected String _ip; 67 68 71 public DatabaseComment() { 72 } 73 74 79 public Integer getId() { 80 return _id; 81 } 82 83 88 public void setId(Integer id) { 89 if (_id == null) { 90 _id = id; 91 } 92 } 93 94 99 public void setBlogId(Integer blogId) { 100 _blogId = blogId; 101 } 102 103 108 public Integer getBlogId() { 109 return _blogId; 110 } 111 112 117 public Integer getBlogEntryId() { 118 return _blogEntryId; 119 } 120 121 126 public void setBlogEntryId(Integer blogEntryId) { 127 _blogEntryId = blogEntryId; 128 } 129 130 135 public Entry getEntry() { 136 return _entry; 137 } 138 139 144 public void setEntry(Entry entry) { 145 _entry = entry; 146 _blogEntryId = _entry.getId(); 147 } 148 149 154 public String getAuthor() { 155 return _author; 156 } 157 158 163 public String getEscapedAuthor() { 164 return BlojsomUtils.escapeString(_author); 165 } 166 167 172 public void setAuthor(String author) { 173 _author = author; 174 } 175 176 181 public String getAuthorEmail() { 182 return _authorEmail; 183 } 184 185 190 public String getEscapedAuthorEmail() { 191 return BlojsomUtils.escapeString(_authorEmail); 192 } 193 194 199 public void setAuthorEmail(String authorEmail) { 200 _authorEmail = authorEmail; 201 } 202 203 208 public String getAuthorURL() { 209 return _authorURL; 210 } 211 212 217 public String getEscapedAuthorURL() { 218 return BlojsomUtils.escapeString(_authorURL); 219 } 220 221 226 public void setAuthorURL(String authorURL) { 227 _authorURL = authorURL; 228 } 229 230 234 public String getEscapedComment() { 235 return BlojsomUtils.escapeString(_comment); 236 } 237 238 243 public String getComment() { 244 return _comment; 245 } 246 247 252 public void setComment(String comment) { 253 _comment = comment; 254 } 255 256 261 public Date getCommentDate() { 262 return _commentDate; 263 } 264 265 271 public String getISO8601Date() { 272 return BlojsomUtils.getISO8601Date(_commentDate); 273 } 274 275 280 public String getRFC822Date() { 281 return BlojsomUtils.getRFC822Date(_commentDate); 282 } 283 284 289 public Map getMetaData() { 290 if (_metaData == null) { 291 return new HashMap (); 292 } 293 294 return _metaData; 295 } 296 297 302 public void setCommentDate(Date commentDate) { 303 _commentDate = commentDate; 304 } 305 306 311 public void setMetaData(Map metaData) { 312 _metaData = metaData; 313 } 314 315 322 public String getDateAsFormat(String format) { 323 return getDateAsFormat(format, null); 324 } 325 326 333 public String getDateAsFormat(String format, Locale locale) { 334 if (_commentDate == null || format == null) { 335 return null; 336 } 337 338 SimpleDateFormat sdf; 339 try { 340 if (locale == null) { 341 sdf = new SimpleDateFormat (format); 342 } else { 343 sdf = new SimpleDateFormat (format, locale); 344 } 345 346 return sdf.format(_commentDate); 347 } catch (IllegalArgumentException e) { 348 return _commentDate.toString(); 349 } 350 } 351 352 357 public Integer getParentId() { 358 return _parentId; 359 } 360 361 366 public void setParentId(Integer parentId) { 367 _parentId = parentId; 368 } 369 370 375 public String getIp() { 376 return _ip; 377 } 378 379 384 public void setIp(String ip) { 385 _ip = ip; 386 } 387 388 393 public String getStatus() { 394 return _status; 395 } 396 397 402 public void setStatus(String status) { 403 _status = status; 404 } 405 406 411 public Date getDate() { 412 return _commentDate; 413 } 414 415 420 public String getType() { 421 return COMMENT_TYPE; 422 } 423 } 424 | Popular Tags |