KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > workflowtool > util > ContentValues


1 /* ===============================================================================
2 *
3 * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4 *
5 * ===============================================================================
6 *
7 * Copyright (C)
8 *
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License version 2, as published by the
11 * Free Software Foundation. See the file LICENSE.html for more information.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19 * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20 *
21 * ===============================================================================
22 */

23 package org.infoglue.cms.applications.workflowtool.util;
24
25 import java.text.SimpleDateFormat JavaDoc;
26 import java.util.Date JavaDoc;
27
28 /**
29  * Bean class used for populating content attributes from the request and/or the property set.
30  */

31 public class ContentValues
32 {
33     /**
34      * The key used when populating the publish date attribute.
35      */

36     public static final String JavaDoc PUBLISH_DATE_TIME = "PublishDateTime";
37
38     /**
39      * The key used when populating the expire date attribute.
40      */

41     public static final String JavaDoc EXPIRE_DATE_TIME = "ExpireDateTime";
42
43     /**
44      * The key used when populating the name attribute.
45      */

46     public static final String JavaDoc NAME = "Name";
47     
48     /**
49      * The publish date of the content.
50      */

51     private Date JavaDoc publishDateTime;
52
53     /**
54      * The expire date of the content.
55      */

56     private Date JavaDoc expireDateTime;
57
58     /**
59      * The name of the content.
60      */

61     private String JavaDoc name;
62     
63     /**
64      * Default constructor.
65      */

66     public ContentValues()
67     {
68         super();
69     }
70
71     /**
72      * Returns the name of the content.
73      *
74      * @return the name of the content.
75      */

76     public String JavaDoc getName()
77     {
78         return name;
79     }
80     
81     /**
82      * Returns the publish date of the content.
83      *
84      * @return the publish date of the content.
85      */

86     public Date JavaDoc getPublishDateTime()
87     {
88         return publishDateTime;
89     }
90
91     /**
92      * Returns the expire date of the content.
93      *
94      * @return the expire date of the content.
95      */

96     public Date JavaDoc getExpireDateTime()
97     {
98         return expireDateTime;
99     }
100
101     /**
102      * Sets the name of the content to the specified value.
103      *
104      * @param name the new name.
105      */

106     public void setName(final String JavaDoc name)
107     {
108         this.name = name;
109     }
110     
111     /**
112      * Sets the publish date of the content to the specified value.
113      *
114      * @param name the new name.
115      */

116     public void setPublishDateTime(final String JavaDoc publishDateTime)
117     {
118         this.publishDateTime = getDate(publishDateTime);
119     }
120     
121     /**
122      * Sets the expire date of the content to the specified value.
123      *
124      * @param name the new name.
125      */

126     public void setExpireDateTime(final String JavaDoc expireDateTime)
127     {
128         this.expireDateTime = getDate(expireDateTime);
129     }
130
131     /**
132      * Converts the specified string to a date or null if the string is unparsable.
133      *
134      * @param dateString the string to parse.
135      * @return the date.
136      */

137     private static Date JavaDoc getDate(final String JavaDoc dateString)
138     {
139         try
140         {
141             return (dateString == null) ? null : new SimpleDateFormat JavaDoc("yyyy-MM-dd HH:mm").parse(dateString);
142         }
143         catch(Exception JavaDoc e)
144         {
145             return null;
146         }
147     }
148 }
Popular Tags