KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > api > components > CmpEntryBean


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3.api.components;
7
8 import java.text.*;
9 import java.util.*;
10
11 import javax.servlet.http.HttpServletRequest JavaDoc;
12
13 import org.apache.struts.action.ActionMapping;
14
15 import com.raptus.owxv3.LoggingManager;
16
17 /**
18  *
19  * <hr>
20  * <table width="100%" border="0">
21  * <tr>
22  * <td width="24%"><b>Filename</b></td><td width="76%">CmpEntryBean.java</td>
23  * </tr>
24  * <tr>
25  * <td width="24%"><b>Author</b></td><td width="76%">Guy Zürcher (gzuercher@raptus.com)</td>
26  * </tr>
27  * <tr>
28  * <td width="24%"><b>Date</b></td><td width="76%">28th of June 2001</td>
29  * </tr>
30  * </table>
31  * <hr>
32  * <table width="100%" border="0">
33  * <tr>
34  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
35  * </tr>
36  * </table>
37  * <hr>
38  */

39 public class CmpEntryBean extends ComponentBean
40 {
41
42     /**
43      *
44      */

45     protected boolean flagEntryDte = false;
46
47     /**
48      *
49      */

50     protected boolean flagTimedPub = false;
51
52     /**
53      *
54      */

55     protected String JavaDoc entryDte = null;
56
57     /**
58      *
59      */

60     protected String JavaDoc showFromDate = null;
61     protected String JavaDoc showFromTime = null;
62
63     /**
64      *
65      */

66     protected String JavaDoc showUntilDate = null;
67     protected String JavaDoc showUntilTime = null;
68
69
70     //protected boolean valuesChanged=false;
71

72     /**
73      *
74      */

75     public boolean getFlagEntryDte() { return flagEntryDte; }
76     public void setFlagEntryDte(boolean flag)
77     {
78         //if(flagEntryDte!=flag) valuesChanged=true;
79

80         this.flagEntryDte = flag;
81     }
82
83     /**
84      *
85      */

86     public boolean getFlagTimedPub() { return flagTimedPub; }
87     public void setFlagTimedPub(boolean tpub)
88     {
89         //if(flagTimedPub!=tpub) valuesChanged=true;
90

91         this.flagTimedPub = tpub;
92
93     }
94
95     /**
96      *
97      */

98     public String JavaDoc getEntryDte() { return entryDte; }
99     public void setEntryDte(String JavaDoc dte)
100     {
101         //if(entryDte!=null)
102
// if(!entryDte.equals(dte)) valuesChanged=true;
103
this.entryDte = dte;
104     }
105
106     /**
107      *
108      */

109     public String JavaDoc getShowFromDate() { return showFromDate; }
110     public void setShowFromDate(String JavaDoc dte)
111     {
112         //if(showFromDate!=null)
113
// if(!showFromDate.equals(dte)) valuesChanged=true;
114
this.showFromDate = dte;
115     }
116
117     /**
118      *
119      */

120     public String JavaDoc getShowFromTime() { return showFromTime; }
121     public void setShowFromTime(String JavaDoc tme)
122     {
123         //if(showFromTime!=null)
124
// if(!showFromTime.equals(tme)) valuesChanged=true;
125
this.showFromTime = tme;
126     }
127
128     /**
129      *
130      */

131     public String JavaDoc getShowUntilDate() { return showUntilDate; }
132     public void setShowUntilDate(String JavaDoc dte)
133     {
134         //if(showUntilDate!=null)
135
// if(!showUntilDate.equals(dte)) valuesChanged=true;
136
this.showUntilDate = dte;
137     }
138
139     /**
140      *
141      */

142     public String JavaDoc getShowUntilTime() { return showUntilTime; }
143     public void setShowUntilTime(String JavaDoc tme)
144     {
145         //if(showUntilTime!=null)
146
// if(!showUntilTime.equals(tme)) valuesChanged=true;
147

148         this.showUntilTime = tme;
149     }
150
151     /**
152      * Returns a value representing the starting date/time at which the
153      * data should be published. The following rules apply:
154      *
155      * If only <showFromDate> is ok, but not <showFromTime> a time
156      * of 0:00 is assumed. (start of day)
157      *
158      * @return a valid java.util.Date object (date AND time) or
159      * NULL if something went wrong
160      */

161     public java.util.Date JavaDoc getShowFrom()
162     {
163         if(showFromDate != null) showFromDate = showFromDate.trim();
164         if(showFromTime != null) showFromTime = showFromTime.trim();
165
166         if(showFromDate == null || showFromDate.length() == 0)
167         {
168             flagTimedPub = false;
169             return null;
170         }
171
172         if(showFromTime == null || showFromTime.length() == 0)
173             showFromTime = getLocalizedTime("00:00");
174
175         return getDateObj(showFromDate + " " + showFromTime);
176     }
177
178     /**
179      * Returns a value representing the stopping date/time at which the
180      * data should be no more published. The following rules apply:
181      *
182      * If only <showUntilDate> is ok, but not <showUntilTime> a time
183      * of 23:59 is assumed. (end of day)
184      *
185      * @return a valid java.util.Date object (date AND time) or
186      * NULL if something went wrong
187      */

188     public java.util.Date JavaDoc getShowUntil()
189     {
190         if(showUntilDate != null) showUntilDate = showUntilDate.trim();
191         if(showUntilTime != null) showUntilTime = showUntilTime.trim();
192
193         if(showUntilDate == null || showUntilDate.length() == 0)
194             return null;
195
196         if(showUntilTime == null || showUntilTime.length() == 0)
197             showUntilTime = getLocalizedTime("23:59");
198
199         return getDateObj(showUntilDate + " " + showUntilTime);
200     }
201
202     /**
203      * Accepts a string with swiss-german formatted time. The time is then
204      * converted into a java.util.Date object in order to get the current
205      * locale's format out of it.
206      *
207      * @param s Input time string formatted with de_CH
208      *
209      * @return a string that contains a formatted time for the locale
210      * <currLocale>. If something went wrong, the original
211      * <s> is returned.
212      */

213     protected String JavaDoc getLocalizedTime(String JavaDoc s)
214     {
215         DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, new Locale("de", "CH"));
216         Date c = null;
217         try
218         {
219             c = df.parse(s);
220         }
221         catch(ParseException e) {
222             return s;
223         }
224
225         df = DateFormat.getTimeInstance(DateFormat.SHORT, currLocale);
226         return df.format(c);
227     }
228
229     /**
230      * Returns a valid java.util.Date object, that contains the date AND
231      * the time values. As input parameter it accepts any date/time string
232      * that is formatted for the current locale.
233      *
234      * Examples: Locale: String:
235      *
236      * de_CH "01.01.1999 12:34"
237      * en_GB * "15/09/2000 16:23"
238      * en_US * "09/15/2000 4:23 pm"
239      *
240      * @param s a string that contains date AND time formatted
241      * for <currentLocale>
242      *
243      * @return a valid java.util.Date object if conversion was successful
244      * otherwise NULL
245      */

246     protected java.util.Date JavaDoc getDateObj(String JavaDoc s)
247     {
248         java.util.Date JavaDoc dval = null;
249         DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT,
250                                                        DateFormat.SHORT, currLocale);
251         try
252         {
253             dval = df.parse(s);
254         }
255         catch(ParseException e) {
256             LoggingManager.log("ParseException while trying to convert. " + e.getMessage(), this);
257             return dval;
258         }
259
260         return dval;
261     }
262
263     /**
264      *
265      */

266     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request)
267     {
268         super.reset(mapping, request);
269         flagEntryDte = false;
270         flagTimedPub = false;
271         //valuesChanged= false;
272
}
273
274     /*public void setValuesChanged(boolean b){
275         valuesChanged=b;
276     }
277
278     public void setComponentChanged()
279     {
280        if(valuesChanged) super.setComponentChanged(true);
281     }*/

282 }
283
284 // eof
285
Popular Tags