KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icesoft > faces > component > selectinputdate > SelectInputDate


1 /*
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * "The contents of this file are subject to the Mozilla Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
11  * License for the specific language governing rights and limitations under
12  * the License.
13  *
14  * The Original Code is ICEfaces 1.5 open source software code, released
15  * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
16  * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
17  * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
18  *
19  * Contributor(s): _____________________.
20  *
21  * Alternatively, the contents of this file may be used under the terms of
22  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
23  * License), in which case the provisions of the LGPL License are
24  * applicable instead of those above. If you wish to allow use of your
25  * version of this file only under the terms of the LGPL License and not to
26  * allow others to use your version of this file under the MPL, indicate
27  * your decision by deleting the provisions above and replace them with
28  * the notice and other provisions required by the LGPL License. If you do
29  * not delete the provisions above, a recipient may use your version of
30  * this file under either the MPL or the LGPL License."
31  *
32  */

33
34 package com.icesoft.faces.component.selectinputdate;
35
36 import com.icesoft.faces.component.CSS_DEFAULT;
37 import com.icesoft.faces.component.ext.HtmlInputText;
38 import com.icesoft.faces.component.ext.taglib.Util;
39 import com.icesoft.faces.context.DOMResponseWriter;
40 import com.icesoft.faces.util.CoreUtils;
41
42 import org.krysalis.jcharts.properties.LegendProperties;
43
44 import javax.faces.context.FacesContext;
45 import javax.faces.el.ValueBinding;
46 import java.io.IOException JavaDoc;
47 import java.text.DateFormat JavaDoc;
48 import java.text.SimpleDateFormat JavaDoc;
49 import java.util.ArrayList JavaDoc;
50 import java.util.Calendar JavaDoc;
51 import java.util.Date JavaDoc;
52 import java.util.HashMap JavaDoc;
53 import java.util.List JavaDoc;
54 import java.util.Map JavaDoc;
55
56 /**
57  * SelectInputDate is a JSF component class that represents an ICEfaces input
58  * date selector.
59  * <p/>
60  * The component extends the ICEfaces extended HTMLPanelGroup.
61  * <p/>
62  * By default the component is rendered by the "com.icesoft.faces.Calendar"
63  * renderer type.
64  *
65  * @author Greg McCleary
66  * @version 1.1
67  */

68 public class SelectInputDate
69         extends HtmlInputText {
70     /**
71      * The component type.
72      */

73     public static final String JavaDoc COMPONENT_TYPE =
74             "com.icesoft.faces.SelectInputDate";
75     /**
76      * The component family.
77      */

78     public static final String JavaDoc COMPONENT_FAMILY = "javax.faces.Input";
79     /**
80      * The default renderer type.
81      */

82     private static final String JavaDoc DEFAULT_RENDERER_TYPE =
83             "com.icesoft.faces.Calendar";
84     /**
85      * The default date format for the popup input text child component.
86      */

87     public static final String JavaDoc DEFAULT_POPUP_DATE_FORMAT = "MM/dd/yyyy";
88
89     // style
90
private String JavaDoc style = null;
91
92     private String JavaDoc styleClass = null;
93
94     /**
95      * The current renderAsPopup state.
96      */

97     private Boolean JavaDoc _renderAsPopup = null;
98     /**
99      * The current directory path of the images used by the component.
100      */

101     private String JavaDoc _imageDir = null;
102     /**
103      * The current name of the move next image
104      */

105     private String JavaDoc _moveNextImage = null;
106     /**
107      * The current name of the move previous image.
108      */

109     private String JavaDoc _movePreviousImage = null;
110     /**
111      * The current name of the open popup image.
112      */

113     private String JavaDoc _openPopupImage = null;
114     /**
115      * The current name of the close popup image.
116      */

117     private String JavaDoc _closePopupImage = null;
118
119     /**
120      * The current date format used for the input text child of the component.
121      * <p>Only applies when component is used in popup mode.
122      */

123     private String JavaDoc _popupDateFormat = null;
124
125     /**
126      * The current popup state.
127      */

128     private List JavaDoc showPopup = new ArrayList JavaDoc();
129     /**
130      * The current navigation event state.
131      */

132     private boolean navEvent = false;
133     /**
134      * The current navigation date of the component.
135      */

136     private Date JavaDoc navDate = null;
137
138     // declare default style classes
139
/**
140      * The default directory where the images used by this component can be
141      * found. This directory and its contents are included in the icefaces.jar
142      * file.
143      */

144     private final String JavaDoc DEFAULT_IMAGEDIR = "/xmlhttp/css/xp/css-images/";
145     /**
146      * The default move next image name.
147      */

148     private final String JavaDoc DEFAULT_MOVENEXT = "cal_arrow_right.gif";
149     /**
150      * The default move previous image name.
151      */

152     private final String JavaDoc DEFAULT_MOVEPREV = "cal_arrow_left.gif";
153     /**
154      * The default open popup image name.
155      */

156     private final String JavaDoc DEFAULT_OPENPOPUP = "cal_button.gif";
157     /**
158      * The default close popup image name.
159      */

160     private final String JavaDoc DEFAULT_CLOSEPOPUP = "cal_off.gif";
161     /**
162      * The default date format used by this component.
163      */

164     private DateFormat JavaDoc myDateFormat =
165             new SimpleDateFormat JavaDoc(DEFAULT_POPUP_DATE_FORMAT);
166
167     /**
168      * Creates an instance and sets renderer type to "com.icesoft.faces.Calendar".
169      */

170     public SelectInputDate() {
171         setRendererType(DEFAULT_RENDERER_TYPE);
172     }
173
174     public void encodeBegin(FacesContext context) throws IOException JavaDoc {
175         super.encodeBegin(context);
176         buildHeighLightMap();
177     }
178
179     /**
180      * <p/>
181      * CSS style attribute. </p>
182      *
183      * @return style
184      */

185
186     public String JavaDoc getStyle() {
187         if (this.style != null) {
188             return this.style;
189         }
190         ValueBinding _vb = getValueBinding("style");
191
192
193         if (_vb != null) {
194             return (String JavaDoc) _vb.getValue(getFacesContext());
195         }
196         return null;
197     }
198
199     /**
200      * <p/>
201      * CSS style attribute. </p>
202      *
203      * @param style
204      * @see #getStyle()
205      */

206     public void setStyle(String JavaDoc style) {
207         this.style = style;
208     }
209
210
211     /**
212      * Formats the given date using the default date format MM/dd/yyyy.
213      *
214      * @param date
215      * @return the formatted date as a String.
216      */

217     public String JavaDoc formatDate(Date JavaDoc date) {
218         if (date != null) {
219             return myDateFormat.format(date);
220         } else {
221             return "";
222         }
223     }
224
225     /**
226      * Sets the boolean navEvent attribute.
227      *
228      * @param navEvent a value of true indicates that a navigation event has
229      * occured.
230      */

231     public void setNavEvent(boolean navEvent) {
232         this.navEvent = navEvent;
233     }
234
235     /**
236      * A navEvent value of true indicates that a navEvent has occured.
237      *
238      * @return a value of true if a navigation event caused that render.
239      */

240     public boolean isNavEvent() {
241         return this.navEvent;
242     }
243
244     /**
245      * Set the date value of the navDate. The navDate is used to render a
246      * calendar when the user is navigating from month to month or year to
247      * year.
248      *
249      * @param navDate a Date assigned to the navDate.
250      */

251     public void setNavDate(Date JavaDoc navDate) {
252         this.navDate = navDate;
253     }
254
255     /**
256      * Get the navDate to render a calendar on a navigation event.
257      *
258      * @return the navDate as a Date
259      */

260     public Date JavaDoc getNavDate() {
261         return this.navDate;
262     }
263
264     /**
265      * Setting the showPopup attribute to true will render the SelectInputDate
266      * popup calendar.
267      *
268      * @param showPopup a value of true will cause the popup calendar to be
269      * rendered
270      */

271     public void setShowPopup(boolean showPopup) {
272         if (showPopup) {
273             this.showPopup.add(getClientId(FacesContext.getCurrentInstance()));
274         } else {
275             this.showPopup
276                     .remove(getClientId(FacesContext.getCurrentInstance()));
277         }
278     }
279
280     /**
281      * A showPopup value of true indicates the SelectInputText popup be
282      * rendered.
283      *
284      * @return the current value showPopup
285      */

286     public boolean isShowPopup() {
287         if (showPopup
288                 .contains(getClientId(FacesContext.getCurrentInstance()))) {
289             return true;
290         } else {
291             return false;
292         }
293     }
294
295     /* (non-Javadoc)
296     * @see javax.faces.component.UIComponent#getFamily()
297     */

298     public String JavaDoc getFamily() {
299         return COMPONENT_FAMILY;
300     }
301
302
303     /**
304      * Returns the style class name used for the row containing the month and
305      * Year. The style class is defined in an external style sheet.
306      *
307      * @return the style class name applied to the monthYearRow. If a
308      * monthYearRowClass attribute has not been set the default will be
309      * used.
310      */

311     public String JavaDoc getMonthYearRowClass() {
312         return Util.getQualifiedStyleClass(this,
313                 CSS_DEFAULT.DEFAULT_YEARMONTHHEADER_CLASS,
314                 isDisabled());
315     }
316
317
318     /**
319      * Returns the style class name of the weekRowClass The style class is
320      * defined in an external style sheet.
321      *
322      * @return the style class name applied to the weekRow. If a weekRowClass
323      * attribute has not been set the default will be used.
324      */

325     public String JavaDoc getWeekRowClass() {
326         return Util.getQualifiedStyleClass(this,
327                         CSS_DEFAULT.DEFAULT_WEEKHEADER_CLASS,
328                         isDisabled());
329     }
330
331     /**
332      * @return the style class name used for the input text of the calendar.
333      */

334     public String JavaDoc getCalendarInputClass() {
335         return Util.getQualifiedStyleClass(this,
336                                 CSS_DEFAULT.DEFAULT_CALENDARINPUT_CLASS,
337                                 isDisabled());
338     }
339
340     /**
341      * Returns the style class name applied to the day cells in the
342      * SelectInputDate calendar.
343      *
344      * @return the style class name that is applied to the SelectInputDate day
345      * cells
346      */

347     public String JavaDoc getDayCellClass() {
348         return Util.getQualifiedStyleClass(this,
349                                 CSS_DEFAULT.DEFAULT_DAYCELL_CLASS,
350                                 isDisabled());
351     }
352
353     /* (non-Javadoc)
354      * @see com.icesoft.faces.component.ext.HtmlInputText#setStyleClass(java.lang.String)
355      */

356     public void setStyleClass(String JavaDoc styleClass) {
357         this.styleClass = styleClass;
358     }
359
360     /**
361      * <p>Return the value of the <code>styleClass</code> property.</p>
362      *
363      * @return styleClass
364      */

365     public String JavaDoc getStyleClass() {
366         return Util.getQualifiedStyleClass(this,
367                                     styleClass,
368                                     CSS_DEFAULT.DEFAULT_CALENDAR,
369                                     "styleClass", isDisabled());
370     }
371
372     /**
373      * Returns the currentDayCell style class name.
374      *
375      * @return style class name used for the current day cell
376      */

377     public String JavaDoc getCurrentDayCellClass() {
378         return Util.getQualifiedStyleClass(this,
379                                 CSS_DEFAULT.DEFAULT_CURRENTDAYCELL_CLASS,
380                                 isDisabled());
381     }
382
383
384     /**
385      * @return the value of the renderAsPopup indicator.
386      */

387     public boolean isRenderAsPopup() {
388         if (_renderAsPopup != null) {
389             return _renderAsPopup.booleanValue();
390         }
391         ValueBinding vb = getValueBinding("renderAsPopup");
392         Boolean JavaDoc v =
393                 vb != null ? (Boolean JavaDoc) vb.getValue(getFacesContext()) : null;
394         return v != null ? v.booleanValue() : false;
395     }
396
397     /**
398      * @param b
399      */

400     public void setRenderAsPopup(boolean b) {
401         _renderAsPopup = new Boolean JavaDoc(b);
402     }
403
404     /**
405      * Sets the directory where the images used by this component are located.
406      *
407      * @param imageDir the directory where the images used by this component are
408      * located
409      */

410     public void setImageDir(String JavaDoc imageDir) {
411         _imageDir = imageDir;
412     }
413
414     /**
415      * @return the directory name where the images used by this component are
416      * located.
417      */

418     public String JavaDoc getImageDir() {
419         if (_imageDir != null) {
420             return _imageDir;
421         }
422
423         ValueBinding vb = getValueBinding("imageDir");
424         if (vb != null) {
425             return (String JavaDoc) vb.getValue(getFacesContext());
426         } else {
427             return DEFAULT_IMAGEDIR;
428         }
429     }
430
431     /**
432      * @return the name of the move next image.
433      */

434     public String JavaDoc getMoveNextImage() {
435         return this.DEFAULT_MOVENEXT;
436     }
437
438     /**
439      * Returns the name of the move previous image.
440      *
441      * @return DEFAULT_MOVEPREV
442      */

443     public String JavaDoc getMovePreviousImage() {
444         return this.DEFAULT_MOVEPREV;
445     }
446
447     /**
448      * returns the name of the open popup image.
449      *
450      * @return DEFAULT_OPENPOPUP
451      */

452     public String JavaDoc getOpenPopupImage() {
453         return this.DEFAULT_OPENPOPUP;
454     }
455
456     /**
457      * Returns the name of the close popup image.
458      *
459      * @return DEFAULT_CLOSEPOPUP
460      */

461     public String JavaDoc getClosePopupImage() {
462         return this.DEFAULT_CLOSEPOPUP;
463     }
464
465     /**
466      * Sets the date format of the input text child component when the component
467      * is in popup mode.
468      *
469      * @param popupDateFormat
470      */

471     public void setPopupDateFormat(String JavaDoc popupDateFormat) {
472         _popupDateFormat = popupDateFormat;
473     }
474
475     /**
476      * Returns the date format string of the input text child componenet.
477      *
478      * @return _popupDateFormat
479      */

480     public String JavaDoc getPopupDateFormat() {
481         if (_popupDateFormat != null) {
482             myDateFormat = new SimpleDateFormat JavaDoc(_popupDateFormat);
483             return _popupDateFormat;
484         }
485         ValueBinding vb = getValueBinding("popupDateFormat");
486         if (vb != null ) {
487             myDateFormat = new SimpleDateFormat JavaDoc((String JavaDoc) vb.getValue(getFacesContext()));
488             return (String JavaDoc) vb.getValue(getFacesContext());
489         } else {
490             return DEFAULT_POPUP_DATE_FORMAT;
491         }
492     }
493
494     /* (non-Javadoc)
495      * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
496      */

497     public Object JavaDoc saveState(FacesContext context) {
498         Object JavaDoc values[] = new Object JavaDoc[10];
499         values[0] = super.saveState(context);
500         values[1] = _renderAsPopup;
501         values[2] = _popupDateFormat;
502         values[3] = _imageDir;
503         values[4] = _moveNextImage;
504         values[5] = _movePreviousImage;
505         values[6] = _openPopupImage;
506         values[7] = _closePopupImage;
507         values[8] = new Boolean JavaDoc(navEvent);
508         values[9] = navDate;
509         return ((Object JavaDoc) (values));
510     }
511
512     /* (non-Javadoc)
513      * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object)
514      */

515     public void restoreState(FacesContext context, Object JavaDoc state) {
516         Object JavaDoc values[] = (Object JavaDoc[]) state;
517         super.restoreState(context, values[0]);
518         _renderAsPopup = (Boolean JavaDoc) values[1];
519         _popupDateFormat = (String JavaDoc) values[2];
520         _imageDir = (String JavaDoc) values[3];
521         _moveNextImage = (String JavaDoc) values[4];
522         _movePreviousImage = (String JavaDoc) values[5];
523         _openPopupImage = (String JavaDoc) values[6];
524         _closePopupImage = (String JavaDoc) values[7];
525         navEvent = ((Boolean JavaDoc) values[8]).booleanValue();
526         navDate = (Date JavaDoc) values[9];
527     }
528
529     private Map JavaDoc linkMap = new HashMap JavaDoc();
530
531     /**
532      * @return linkMap
533      */

534     public Map JavaDoc getLinkMap() {
535         return linkMap;
536     }
537
538     /**
539      * @param linkMap
540      */

541     public void setLinkMap(Map JavaDoc linkMap) {
542         this.linkMap = linkMap;
543     }
544
545     private String JavaDoc selectedDayLink;
546
547     /**
548      * @return selectedDayLink
549      */

550     public String JavaDoc getSelectedDayLink() {
551         return selectedDayLink;
552     }
553
554     /**
555      * @param selectedDayLink
556      */

557     public void setSelectedDayLink(String JavaDoc selectedDayLink) {
558         this.selectedDayLink = selectedDayLink;
559     }
560
561     //this component was throwing an exception in popup mode, if the component has no binding for value attribute
562
//so here we returning current date in this case.
563
/* (non-Javadoc)
564      * @see javax.faces.component.ValueHolder#getValue()
565      */

566     public Object JavaDoc getValue() {
567         if (super.getValue() == null) {
568             if (DOMResponseWriter.isStreamWriting()) {
569                 return new Date JavaDoc();
570             }
571             return null;
572         } else {
573             return super.getValue();
574         }
575     }
576
577     private String JavaDoc highlightClass;
578     /**
579      * <p>Set the value of the <code>highlightClass</code> property.</p>
580      *
581      * @param highlightClass
582      */

583     public void setHighlightClass(String JavaDoc highlightClass) {
584         this.highlightClass = highlightClass;
585     }
586
587     /**
588      * <p>Return the value of the <code>highlightClass</code> property.</p>
589      *
590      * @return String highlightClass, if never set returns a blank string not
591      * null
592      */

593     public String JavaDoc getHighlightClass() {
594         if (highlightClass != null) {
595             return highlightClass;
596         }
597         ValueBinding vb = getValueBinding("highlightClass");
598         return vb != null ? (String JavaDoc) vb.getValue(getFacesContext()) : "";
599     }
600     
601     private String JavaDoc highlightUnit;
602     /**
603      * <p>Set the value of the <code>highlightUnit</code> property.</p>
604      *
605      * @param highlightClass
606      */

607     public void setHighlightUnit(String JavaDoc highlightUnit) {
608         this.highlightUnit = highlightUnit;
609     }
610
611     /**
612      * <p>Return the value of the <code>highlightUnit</code> property.</p>
613      *
614      * @return String highlightUnit, if never set returns a blank string not
615      * null
616      */

617     public String JavaDoc getHighlightUnit() {
618         if (highlightUnit != null) {
619             return highlightUnit;
620         }
621         ValueBinding vb = getValueBinding("highlightUnit");
622         return vb != null ? (String JavaDoc) vb.getValue(getFacesContext()) : "";
623     }
624     
625     private String JavaDoc highlightValue;
626     /**
627      * <p>Set the value of the <code>highlightValue</code> property.</p>
628      *
629      * @param highlightValue
630      */

631     public void setHighlightValue(String JavaDoc highlightValue) {
632         this.highlightValue = highlightValue;
633     }
634
635     /**
636      * <p>Return the value of the <code>highlightValue</code> property.</p>
637      *
638      * @return String highlightValue. if never set returns blank a string not
639      * null
640      */

641     public String JavaDoc getHighlightValue() {
642         if (highlightValue != null) {
643             return highlightValue;
644         }
645         ValueBinding vb = getValueBinding("highlightValue");
646         return vb != null ? (String JavaDoc) vb.getValue(getFacesContext()) : "";
647     }
648     
649     private Map JavaDoc hightlightRules = new HashMap JavaDoc();
650     private Map JavaDoc unitMap = new UnitMap();
651     private void buildHeighLightMap() {
652         validateHighlight();
653         resetHighlightClasses(Calendar.YEAR);
654     }
655
656     private boolean validateHighlight() {
657         hightlightRules.clear();
658         String JavaDoc highlightClassArray[] = getHighlightClass().split(":");
659         String JavaDoc highlightUnitArray[] = getHighlightUnit().split(":");
660         String JavaDoc highlightValueArray[] = getHighlightValue().split(":");
661         if ((highlightClassArray.length < 1 ) ||
662                 highlightClassArray[0].equals("") ||
663                 highlightUnitArray[0].equals("") ||
664                 highlightValueArray[0].equals("")) {
665             return false;
666         }
667         if (!(highlightClassArray.length == highlightUnitArray.length) ||
668                 !(highlightUnitArray.length == highlightValueArray.length)) {
669             System.out.println("\n[SelectInputDate] The following attributes does not have corresponding values:" +
670                     "\n-highlightClass \n-highlightUnit \n-highlightValue \n" +
671                     "Note: When highlighting required, all above attributes " +
672                     "need to be used together and should have corresponding values.\n" +
673                     "Each entity can be separated using the : colon, e.g. \n" +
674                     "highlightClass=\"weekend: newyear\" \n" +
675                     "highlightUnit=\"DAY_OF_WEEK: DAY_OF_YEAR\" \n"+
676                     "highlightValue=\"1, 7: 1\" "
677                     );
678             return false;
679         }
680         
681         for(int i = 0; i < highlightUnitArray.length; i++) {
682             try {
683                 int option = Integer.parseInt(highlightUnitArray[i].trim());
684                 if (option <1 || option > 8) {
685                     System.out.println("[SelectInputDate:highlightUnit] \""+ highlightUnitArray[i].trim() +"\" " +
686                         "s not a valid unit value. Valid values are between 1 to 8");
687                     return false;
688                 }
689             } catch (NumberFormatException JavaDoc exception) {
690                 if (unitMap.containsKey(highlightUnitArray[i].trim())) {
691                     highlightUnitArray[i] = String.valueOf(unitMap.get(
692                             highlightUnitArray[i].trim()));
693                 } else {
694                     System.out.println("[SelectInputDate:highlightUnit] \""+ highlightUnitArray[i] +"\" is " +
695                             "not a valid unit value, String representation " +
696                             "of unit must match with java.util.Calendar contants (e.g.)" +
697                             "\nYEAR, MONTH, WEEK_OF_YEAR, WEEK_OF_MONTH, DATE, DAY_OF_YEAR, " +
698                             "DAY_OF_WEEK and DAY_OF_WEEK_IN_MONTH");
699                     return false;
700                 }
701             }
702             String JavaDoc[] value = highlightValueArray[i].replaceAll(" ", "").trim().split(",");
703             for (int j=0; j <value.length; j++ ) {
704                 hightlightRules.put(highlightUnitArray[i].trim() + "$"+ value[j] , highlightClassArray[i]);
705             }
706         }
707
708         
709         return true;
710     }
711
712     Map JavaDoc getHightlightRules() {
713         return hightlightRules;
714     }
715
716     void setHightlightRules(Map JavaDoc hightlightRules) {
717         this.hightlightRules = hightlightRules;
718     }
719     
720     private String JavaDoc highlightYearClass = "";
721     private String JavaDoc highlightMonthClass ="";
722     private String JavaDoc highlightWeekClass ="";
723     private String JavaDoc highlightDayClass ="";
724     
725     String JavaDoc getHighlightDayCellClass() {
726         return highlightYearClass +
727         highlightMonthClass +
728         highlightWeekClass +
729         highlightDayClass;
730     }
731
732     String JavaDoc getHighlightMonthClass() {
733         return highlightMonthClass;
734     }
735
736     void setHighlightMonthClass(String JavaDoc highlightMonthClass) {
737         this.highlightMonthClass = highlightMonthClass;
738     }
739
740     String JavaDoc getHighlightYearClass() {
741         return highlightYearClass;
742     }
743
744     void setHighlightYearClass(String JavaDoc highlightYearClass) {
745         this.highlightYearClass = highlightYearClass;
746     }
747
748     String JavaDoc getHighlightWeekClass() {
749         return highlightWeekClass;
750     }
751
752     void addHighlightWeekClass(String JavaDoc highlightWeekClass) {
753         if (this.highlightWeekClass.indexOf(highlightWeekClass) == -1) {
754             this.highlightWeekClass += (highlightWeekClass + " ");
755         }
756     }
757
758     void addHighlightDayClass(String JavaDoc highlightDayClass) {
759         if (this.highlightDayClass.indexOf(highlightDayClass) == -1) {
760             this.highlightDayClass += (highlightDayClass + " ");
761         }
762     }
763
764     void resetHighlightClasses(int level) {
765         if (level <= Calendar.MONTH) {
766             this.highlightMonthClass = "";
767             this.highlightYearClass = "";
768             this.highlightDayClass = "";
769         }
770         this.highlightDayClass = "";
771         this.highlightWeekClass = "";
772     }
773 }
774
775 class UnitMap extends HashMap JavaDoc {
776     public UnitMap() {
777         this.put("YEAR", new Integer JavaDoc(Calendar.YEAR));
778         this.put("MONTH", new Integer JavaDoc(Calendar.MONTH));
779         this.put("WEEK_OF_YEAR", new Integer JavaDoc(Calendar.WEEK_OF_YEAR));
780         this.put("WEEK_OF_MONTH", new Integer JavaDoc(Calendar.WEEK_OF_MONTH));
781         this.put("DATE", new Integer JavaDoc(Calendar.DATE));
782         this.put("DAY_OF_YEAR", new Integer JavaDoc(Calendar.DAY_OF_YEAR));
783         this.put("DAY_OF_WEEK", new Integer JavaDoc(Calendar.DAY_OF_WEEK));
784         this.put("DAY_OF_WEEK_IN_MONTH", new Integer JavaDoc(Calendar.DAY_OF_WEEK_IN_MONTH));
785     }
786     
787     public int getConstant(String JavaDoc key) {
788         if (!super.containsKey(key)) {
789             return 0;
790         }
791         return Integer.parseInt(super.get(key).toString());
792     }
793 }
794
795
Popular Tags