View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.custom.schedule.model;
21  
22  import java.util.Date;
23  import java.util.Iterator;
24  import java.util.TimeZone;
25  
26  
27  /**
28   * <p>
29   * The underlying model of the UISchedule component. You should implement this
30   * interface when creating real implementations, which would typically be backed
31   * by a database.
32   * </p>
33   *
34   * @author Jurgen Lust (latest modification by $Author: schof $)
35   * @version $Revision: 368941 $
36   */
37  public interface ScheduleModel
38  {
39      //~ Static fields/initializers ---------------------------------------------
40  
41      public static final int DAY = 0;
42      public static final int WORKWEEK = 1;
43      public static final int WEEK = 2;
44      public static final int MONTH = 3;
45  
46      //~ Methods ----------------------------------------------------------------
47  
48      /**
49       * @return true if there are no entries
50       */
51      public abstract boolean isEmpty();
52  
53      /**
54       * @param mode the mode: DAY, WORKWEEK, WEEK or MONTH
55       */
56      public abstract void setMode(int mode);
57  
58      /**
59       * @return the mode: DAY, WORKWEEK, WEEK or MONTH
60       */
61      public abstract int getMode();
62  
63      /**
64       * @param date the date to select
65       */
66      public abstract void setSelectedDate(Date date);
67  
68      /**
69       * @return the selected date
70       */
71      public abstract Date getSelectedDate();
72  
73      /**
74       * @param selectedEntry the entry to select
75       */
76      public abstract void setSelectedEntry(ScheduleEntry selectedEntry);
77  
78      /**
79       * @return the selected entry
80       */
81      public abstract ScheduleEntry getSelectedEntry();
82      
83      /**
84       * @return whether an entry is currently selected
85       */
86      public abstract boolean isEntrySelected();
87  
88      /**
89       * <p>
90       * Check if the schedule contains the specified date
91       * </p>
92       *
93       * @param date the date to check
94       *
95       * @return whether the schedule containts this date
96       */
97      public abstract boolean containsDate(Date date);
98  
99      /**
100      * <p>
101      * Get the day at position <i>index</i>.
102      * </p>
103      *
104      * @param index the index
105      *
106      * @return the day
107      */
108     public abstract Object get(int index);
109 
110     /**
111      * @return an iterator for the days
112      */
113     public abstract Iterator iterator();
114 
115     /**
116      * @return the number of days in this model
117      */
118     public abstract int size();
119     
120     /**
121      * Add an entry to the this model. 
122      *  
123      * @param entry the entry to be added
124      */
125     public abstract void addEntry(ScheduleEntry entry);
126     
127     /**
128      * Remove an entry from this model
129      * 
130      * @param entry the entry to be removed
131      */
132     public abstract void removeEntry(ScheduleEntry entry);
133     
134     /**
135      * Remove the currently selected entry from this model. If no entry
136      * is currently selected, nothing should happen.
137      */
138     public abstract void removeSelectedEntry();
139     
140     /**
141      * Reload the entries for the currently selected period
142      */
143     public abstract void refresh();
144     
145     /**
146      * @return The timezone for which the model should be built
147      */
148     public abstract TimeZone getTimeZone();
149     
150     /**
151      * @return true, if each day contains the same set of intervals
152      */
153     public abstract boolean containsRepeatedIntervals();
154 }
155 //The End