1 19 package org.lucane.applications.notes; 20 21 import java.io.Serializable ; 22 import java.text.DateFormat ; 23 import java.util.*; 24 25 import org.lucane.client.Client; 26 27 public class Note implements Serializable 28 { 29 private String id; 31 32 private String author; 33 private String title; 34 private String content; 35 36 private Date creationDate; 37 private Date editionDate; 38 39 private boolean published; 40 private boolean commentable; 41 42 46 public Note(String author, String title, String content, boolean published, boolean commentable) 47 { 48 this.id = null; 49 50 this.author = author; 51 this.title = title; 52 this.content = content.replaceAll(" \\/\\>", ">"); 53 54 55 this.creationDate = new Date(); 56 this.editionDate = null; 57 58 this.published = published; 59 this.commentable = commentable; 60 } 61 62 66 protected Note(String id, String author, String title, String content, String creationDate, String editionDate, String published, String commentable) 67 { 68 this.id = id; 69 70 this.author = author; 71 this.title = title; 72 this.content = content.replaceAll(" \\/\\>", ">"); 73 74 75 this.creationDate = new Date(Long.parseLong(creationDate)); 76 if(editionDate.length() > 0 && !editionDate.equals("0")) 77 this.editionDate = new Date(Long.parseLong(editionDate)); 78 else 79 this.editionDate = null; 80 81 this.published = Integer.parseInt(published) > 0; 82 this.commentable = Integer.parseInt(commentable) > 0; 83 } 84 85 86 89 public void editContent(String title, String content, boolean isPublic, boolean isCommentable) 90 { 91 this.title = title; 92 this.content = content; 93 this.editionDate = new Date(); 94 this.published = isPublic; 95 this.commentable = isCommentable; 96 } 97 98 100 public void setId(String id) 101 { 102 this.id = id; 103 } 104 105 public String getId() 106 { 107 return this.id; 108 } 109 110 public String getAuthor() 111 { 112 return this.author; 113 } 114 115 public String getTitle() 116 { 117 return this.title; 118 } 119 120 public String getContent() 121 { 122 return this.content; 123 } 124 125 public Date getCreationDate() 126 { 127 return this.creationDate; 128 } 129 130 public Date getEditionDate() 131 { 132 return this.editionDate; 133 } 134 135 public boolean isPublic() 136 { 137 return this.published; 138 } 139 140 public boolean isCommentable() 141 { 142 return this.commentable; 143 } 144 145 public String toString() 146 { 147 Locale locale = new Locale(Client.getInstance().getConfig().getLanguage()); 148 DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, locale); 149 return this.title + " - " + df.format(this.creationDate); 150 } 151 } 152 | Popular Tags |