KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > notes > Comment


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2003 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package org.lucane.applications.notes;
20
21 import java.io.Serializable JavaDoc;
22 import java.text.DateFormat JavaDoc;
23 import java.util.*;
24
25 import org.lucane.client.Client;
26
27 public class Comment implements Serializable JavaDoc
28 {
29   //-- attributes
30
private String JavaDoc id;
31   private String JavaDoc noteId;
32
33   private String JavaDoc author;
34   private String JavaDoc title;
35   private String JavaDoc content;
36
37   private Date creationDate;
38
39   /**
40    * Public constructor
41    * Used for new comments
42    */

43   public Comment(Note note, String JavaDoc author, String JavaDoc title, String JavaDoc content)
44   {
45     this.id = null;
46     this.noteId = note.getId();
47
48     this.author = author;
49     this.title = title;
50     this.content = content.replaceAll(" \\/\\>", ">");
51
52     this.creationDate = new Date();
53   }
54
55   /**
56    * Protected constructor
57    * Used when loading comments from the database
58    */

59   protected Comment(String JavaDoc id, String JavaDoc noteId, String JavaDoc author, String JavaDoc title, String JavaDoc content, String JavaDoc date)
60   {
61     this.id = id;
62     this.noteId = noteId;
63     
64     this.author = author;
65     this.title = title;
66     this.content = content.replaceAll(" \\/\\>", ">");
67
68     this.creationDate = new Date(Long.parseLong(date));
69   }
70
71   //-- getters
72
public void setId(String JavaDoc id)
73   {
74     this.id = id;
75   }
76   
77   public String JavaDoc getId()
78   {
79     return this.id;
80   }
81
82   public String JavaDoc getNoteId()
83   {
84     return this.noteId;
85   }
86
87   public String JavaDoc getAuthor()
88   {
89     return this.author;
90   }
91   
92   public String JavaDoc getTitle()
93   {
94     return this.title;
95   }
96
97   public String JavaDoc getContent()
98   {
99     return this.content;
100   }
101
102   public Date getCreationDate()
103   {
104     return this.creationDate;
105   }
106
107   public String JavaDoc toString()
108   {
109     Locale locale = new Locale(Client.getInstance().getConfig().getLanguage());
110     DateFormat JavaDoc df = DateFormat.getDateInstance(DateFormat.LONG, locale);
111     return this.author + " - " + this.title + " - " + df.format(this.creationDate);
112   }
113 }
114
Popular Tags