KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > blog > Comment


1 /*
2  * Created on Feb 18, 2005
3  */

4 package com.openedit.blog;
5
6 import java.text.SimpleDateFormat JavaDoc;
7 import java.util.Date JavaDoc;
8
9 import com.openedit.OpenEditException;
10 import com.openedit.users.User;
11
12 /**
13  * A blog comment, attached to a blog entry.
14  *
15  * @author cburkey
16  */

17 public class Comment
18 {
19     protected String JavaDoc fieldAuthor; //friendly name
20
protected User fieldUser;
21     protected Date JavaDoc fieldDateTime;
22     protected String JavaDoc fieldContent;
23     protected String JavaDoc fieldId;
24     protected boolean fieldVisible;
25     
26     public String JavaDoc getAuthor()
27     {
28         return fieldAuthor;
29     }
30     public void setAuthor(String JavaDoc inAuthor)
31     {
32         fieldAuthor = inAuthor;
33     }
34     public String JavaDoc getContent()
35     {
36         return fieldContent;
37     }
38     public void setContent(String JavaDoc inContent)
39     {
40         fieldContent = inContent;
41     }
42     public Date JavaDoc getDateTime()
43     {
44         return fieldDateTime;
45     }
46     public void setDateTime(Date JavaDoc inDateTime)
47     {
48         fieldDateTime = inDateTime;
49     }
50     public String JavaDoc published(String JavaDoc inFormat)
51     {
52         SimpleDateFormat JavaDoc format = new SimpleDateFormat JavaDoc(inFormat);
53         return format.format(getDateTime());
54     }
55     public String JavaDoc getId()
56     {
57         return fieldId;
58     }
59     public void setId(String JavaDoc inId)
60     {
61         fieldId = inId;
62     }
63     public boolean isVisible()
64     {
65         return fieldVisible;
66     }
67     public void setVisible(boolean inVisible)
68     {
69         fieldVisible = inVisible;
70     }
71     
72     public boolean canEdit(User inUser) throws OpenEditException
73     {
74         if ( inUser != null )
75         {
76             if( inUser.getShortDescription().equals( getAuthor() ) )
77             {
78                 return true;
79             }
80             if( inUser.hasPermission("oe.administration"))
81             {
82                 return true;
83             }
84         }
85         return false;
86     }
87     public User getUser()
88     {
89         return fieldUser;
90     }
91     public void setUser(User inUser)
92     {
93         fieldUser = inUser;
94     }
95 }
96
Popular Tags