Develop and Download Open Source Software

Browse CVS Repository

Diff of /pal/blog/src/java/jp/sf/pal/blog/model/BlogComment.java

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.10 by shinsuke, Fri Jun 30 12:29:21 2006 UTC revision 1.11 by tigercat, Wed Feb 6 05:40:49 2008 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright 2005-2006 The Portal Application Laboratory Team.   * Copyright 2005-2008 The Portal Application Laboratory Team.
3   *   *
4   * Licensed under the Apache License, Version 2.0 (the "License");   * Licensed under the Apache License, Version 2.0 (the "License");
5   * you may not use this file except in compliance with the License.   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at   * You may obtain a copy of the License at
7   *   *
8   *      http://www.apache.org/licenses/LICENSE-2.0   *      http://www.apache.org/licenses/LICENSE-2.0
9   *   *
10   * Unless required by applicable law or agreed to in writing, software   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and   * See the License for the specific language governing permissions and
14   * limitations under the License.   * limitations under the License.
15   */   */
16  package jp.sf.pal.blog.model;  package jp.sf.pal.blog.model;
17    
18  import java.util.Date;  import java.util.Date;
19    
20  import javax.faces.context.FacesContext;  import javax.faces.context.FacesContext;
21    
22  import jp.sf.pal.blog.BlogConstants;  import jp.sf.pal.blog.BlogConstants;
23    import jp.sf.pal.blog.converter.Converter;
24  import org.apache.commons.lang.StringUtils;  
25    import org.apache.commons.lang.StringUtils;
26  import com.marevol.utils.faces.util.DateFormatUtil;  import org.seasar.framework.container.S2Container;
27    import org.seasar.framework.container.factory.SingletonS2ContainerFactory;
28  /**  
29   * BlogComment generated by hbm2java  import com.marevol.utils.faces.util.DateFormatUtil;
30   */  
31  public class BlogComment implements java.io.Serializable  /**
32  {   * BlogComment generated by hbm2java
33     */
34      // Fields      public class BlogComment implements java.io.Serializable
35    {
36      /**  
37       *      // Fields    
38       */  
39      private static final long serialVersionUID = 562524292609035239L;      /**
40         *
41      public static final String ID = "id";       */
42        private static final long serialVersionUID = 562524292609035239L;
43      public static final String NAME = "name";  
44        public static final String ID = "id";
45      public static final String EMAIL = "email";  
46        public static final String NAME = "name";
47      public static final String URL = "url";  
48        public static final String EMAIL = "email";
49      public static final String MESSAGE = "message";  
50        public static final String URL = "url";
51      public static final String CREATEDTIME = "createdtime";  
52        public static final String MESSAGE = "message";
53      private Long id;  
54        public static final String CREATEDTIME = "createdtime";
55      private BlogMessage blogMessage;  
56        public static final String DEFAULT_FORMAT_CONVERTER = "TextConverter";
57      private String name;  
58        private Long id;
59      private String email;  
60        private BlogMessage blogMessage;
61      private String url;  
62        private String name;
63      private String message;  
64        private String email;
65      private Date createdtime;  
66        private String url;
67      // Constructors  
68        private String message;
69      /** default constructor */  
70      public BlogComment()      private Date createdtime;
71      {  
72      }      // Constructors
73    
74      /** constructor with id */      /** default constructor */
75      public BlogComment(Long id)      public BlogComment()
76      {      {
77          this.id = id;      }
78      }  
79        /** constructor with id */
80      // Property accessors      public BlogComment(Long id)
81        {
82      /**          this.id = id;
83       *      }
84       */  
85      public Long getId()      // Property accessors
86      {  
87          return this.id;      /**
88      }       *
89         */
90      public void setId(Long id)      public Long getId()
91      {      {
92          this.id = id;          return this.id;
93      }      }
94    
95      /**      public void setId(Long id)
96       *      {
97       */          this.id = id;
98      public BlogMessage getBlogMessage()      }
99      {  
100          return this.blogMessage;      /**
101      }       *
102         */
103      public void setBlogMessage(BlogMessage blogMessage)      public BlogMessage getBlogMessage()
104      {      {
105          this.blogMessage = blogMessage;          return this.blogMessage;
106      }      }
107    
108      /**      public void setBlogMessage(BlogMessage blogMessage)
109       *      {
110       */          this.blogMessage = blogMessage;
111      public String getName()      }
112      {  
113          return this.name;      /**
114      }       *
115         */
116      public void setName(String name)      public String getName()
117      {      {
118          this.name = name;          return this.name;
119      }      }
120    
121      /**      public void setName(String name)
122       *      {
123       */          this.name = name;
124      public String getEmail()      }
125      {  
126          return this.email;      /**
127      }       *
128         */
129      public void setEmail(String email)      public String getEmail()
130      {      {
131          this.email = email;          return this.email;
132      }      }
133    
134      /**      public void setEmail(String email)
135       *      {
136       */          this.email = email;
137      public String getUrl()      }
138      {  
139          if (url != null      /**
140                  && (url.startsWith("http://") || url.startsWith("https://")))       *
141          {       */
142              return this.url;      public String getUrl()
143          }      {
144          return "";          if (url != null
145      }                  && (url.startsWith("http://") || url.startsWith("https://")))
146            {
147      public void setUrl(String url)              return this.url;
148      {          }
149          this.url = url;          return "";
150      }      }
151    
152      /**      public void setUrl(String url)
153       *      {
154       */          this.url = url;
155      public String getMessage()      }
156      {  
157          return this.message;      /**
158      }       *
159         */
160      public void setMessage(String message)      public String getMessage()
161      {      {
162          this.message = message;          return this.message;
163      }      }
164    
165      /**      public void setMessage(String message)
166       *      {
167       */          this.message = message;
168      public Date getCreatedtime()      }
169      {  
170          return this.createdtime;      /**
171      }       *
172         */
173      public void setCreatedtime(Date createdtime)      public Date getCreatedtime()
174      {      {
175          this.createdtime = createdtime;          return this.createdtime;
176      }      }
177    
178      public Boolean getDeleteEnabled()      public void setCreatedtime(Date createdtime)
179      {      {
180          String user = FacesContext.getCurrentInstance().getExternalContext()          this.createdtime = createdtime;
181                  .getRemoteUser();      }
182          if (user == null)  
183          {      public Boolean getDeleteEnabled()
184              return Boolean.FALSE;      {
185          }          String user = FacesContext.getCurrentInstance().getExternalContext()
186                    .getRemoteUser();
187          if (user.equals(getBlogMessage().getOwner()))          if (user == null)
188          {          {
189              return Boolean.TRUE;              return Boolean.FALSE;
190          }          }
191          return Boolean.FALSE;  
192            if (user.equals(getBlogMessage().getOwner()))
193      }          {
194                return Boolean.TRUE;
195      public String getFormattedCreatedtime()          }
196      {          return Boolean.FALSE;
197          return DateFormatUtil.getMediumFormattedDateTime(getCreatedtime());  
198      }      }
199    
200      public String getAbbreviatedMessage()      public String getFormattedMessage()
201      {      {
202          return getAbbreviatedMessage(BlogConstants.DEFAULT_TITLE_MAX_LENGTH);          S2Container container = SingletonS2ContainerFactory.getContainer();
203      }          Converter converter = (Converter)container
204                    .getComponent(DEFAULT_FORMAT_CONVERTER);
205      public String getAbbreviatedMessage(int maxLength)          String formattedMessage = converter.convert(getMessage());
206      {          if (formattedMessage == null)
207          return StringUtils.abbreviate(getMessage(), maxLength);          {
208      }              return getMessage();
209            }
210      public void setAbbreviatedMessage(String msg)          return formattedMessage;
211      {      }
212          setMessage(msg);  
213      }      public String getFormattedCreatedtime()
214        {
215      /**          return DateFormatUtil.getMediumFormattedDateTime(getCreatedtime());
216       * @return Returns the emptyComment.      }
217       */  
218      public boolean isEmptyMessage()      public String getAbbreviatedMessage()
219      {      {
220          return StringUtils.isEmpty(getMessage());          return getAbbreviatedMessage(BlogConstants.DEFAULT_TITLE_MAX_LENGTH);
221      }      }
222    
223      /**      public String getAbbreviatedMessage(int maxLength)
224       * @param emptyComment The emptyComment to set.      {
225       */          return StringUtils.abbreviate(getMessage(), maxLength);
226      public void setEmptyMessage(boolean emptyMessage)      }
227      {  
228      }      public void setAbbreviatedMessage(String msg)
229        {
230      /**          setMessage(msg);
231       * @return Returns the emptyEmail.      }
232       */  
233      public boolean isEmptyEmail()      /**
234      {       * @return Returns the emptyComment.
235          return StringUtils.isEmpty(getEmail());       */
236      }      public boolean isEmptyMessage()
237        {
238      /**          return StringUtils.isEmpty(getMessage());
239       * @param emptyEmail The emptyEmail to set.      }
240       */  
241      public void setEmptyEmail(boolean emptyEmail)      /**
242      {       * @param emptyComment The emptyComment to set.
243      }       */
244        public void setEmptyMessage(boolean emptyMessage)
245      /**      {
246       * @return Returns the emptyUrl.      }
247       */  
248      public boolean isEmptyUrl()      /**
249      {       * @return Returns the emptyEmail.
250          return StringUtils.isEmpty(getUrl());       */
251      }      public boolean isEmptyEmail()
252        {
253      /**          return StringUtils.isEmpty(getEmail());
254       * @param emptyUrl The emptyUrl to set.      }
255       */  
256      public void setEmptyUrl(boolean emptyUrl)      /**
257      {       * @param emptyEmail The emptyEmail to set.
258      }       */
259  }      public void setEmptyEmail(boolean emptyEmail)
260        {
261        }
262    
263        /**
264         * @return Returns the emptyUrl.
265         */
266        public boolean isEmptyUrl()
267        {
268            return StringUtils.isEmpty(getUrl());
269        }
270    
271        /**
272         * @param emptyUrl The emptyUrl to set.
273         */
274        public void setEmptyUrl(boolean emptyUrl)
275        {
276        }
277    }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26