001package org.apache.turbine.services.schedule;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.turbine.util.TurbineException;
023
024/**
025 * This is an implementation of a JobEntry with no persistence. It is used by the
026 * {@link TurbineNonPersistentSchedulerService}
027 *
028 */
029public class JobEntryNonPersistent extends AbstractJobEntry
030{
031    private int jobId;
032    private int sec;
033    private int min;
034    private int hour;
035    private int wd;
036    private int day_mo;
037    private String task;
038    private boolean isnew = true;
039
040    /**
041     * Default constructor
042     */
043    public JobEntryNonPersistent()
044    {
045        super();
046    }
047
048    /**
049     * Constructor.
050     *
051     * Schedule a job to run on a certain point of time.<br>
052     *
053     * Example 1: Run the DefaultScheduledJob at 8:00am every 15th of
054     * the month - <br>
055     *
056     * JobEntry je = new JobEntry(0,0,8,15,"DefaultScheduledJob");<br>
057     *
058     * Example 2: Run the DefaultScheduledJob at 8:00am every day -
059     * <br>
060     *
061     * JobEntry je = new JobEntry(0,0,8,-1,"DefaultScheduledJob");<br>
062     *
063     * Example 3: Run the DefaultScheduledJob every 2 hours. - <br>
064     *
065     * JobEntry je = new JobEntry(0,120,-1,-1,"DefaultScheduledJob");<br>
066     *
067     * Example 4: Run the DefaultScheduledJob every 30 seconds. - <br>
068     *
069     * JobEntry je = new JobEntry(30,-1,-1,-1,"DefaultScheduledJob");<br>
070     *
071     * @param sec Value for entry "seconds".
072     * @param min Value for entry "minutes".
073     * @param hour Value for entry "hours".
074     * @param wd Value for entry "week days".
075     * @param day_mo Value for entry "month days".
076     * @param task Task to execute.
077     * @throws TurbineException a generic exception.
078     */
079    public JobEntryNonPersistent(int sec,
080                    int min,
081                    int hour,
082                    int wd,
083                    int day_mo,
084                    String task)
085            throws TurbineException
086    {
087        super(sec, min, hour, wd, day_mo, task);
088    }
089
090    /**
091     * @see java.lang.Object#hashCode()
092     */
093    @Override
094    public int hashCode()
095    {
096        return Integer.valueOf(jobId).hashCode();
097    }
098
099    /**
100     * @see java.lang.Object#equals(java.lang.Object)
101     */
102    @Override
103    public boolean equals(Object obj)
104    {
105        if (obj instanceof JobEntry)
106        {
107            return compareTo((JobEntry)obj) == 0;
108        }
109
110        return false;
111    }
112
113    /**
114     * Return true, if the entry is not yet persisted
115     */
116    @Override
117    public boolean isNew()
118    {
119        boolean _isnew = isnew;
120        isnew = false;
121        return _isnew;
122    }
123
124    /**
125     * Get the value of jobId.
126     *
127     * @return int
128     */
129    @Override
130    public int getJobId()
131    {
132        return jobId;
133    }
134
135    /**
136     * Set the value of jobId.
137     *
138     * @param v new value
139     */
140    @Override
141    public void setJobId(int v)
142    {
143        this.jobId = v;
144    }
145
146    /**
147     * Get the value of second.
148     *
149     * @return int
150     */
151    @Override
152    public int getSecond()
153    {
154        return sec;
155    }
156
157    /**
158     * Set the value of second.
159     *
160     * @param v new value
161     */
162    @Override
163    public void setSecond(int v)
164    {
165        this.sec = v;
166    }
167
168    /**
169     * Get the value of minute.
170     *
171     * @return int
172     */
173    @Override
174    public int getMinute()
175    {
176        return min;
177    }
178
179    /**
180     * Set the value of minute.
181     *
182     * @param v new value
183     */
184    @Override
185    public void setMinute(int v)
186    {
187        this.min = v;
188    }
189
190    /**
191     * Get the value of hour.
192     *
193     * @return int
194     */
195    @Override
196    public int getHour()
197    {
198        return hour;
199    }
200
201    /**
202     * Set the value of hour.
203     *
204     * @param v new value
205     */
206    @Override
207    public void setHour(int v)
208    {
209        this.hour = v;
210    }
211
212    /**
213     * Get the value of weekDay.
214     *
215     * @return int
216     */
217    @Override
218    public int getWeekDay()
219    {
220        return wd;
221    }
222
223    /**
224     * Set the value of weekDay.
225     *
226     * @param v new value
227     */
228    @Override
229    public void setWeekDay(int v)
230    {
231        this.wd = v;
232    }
233
234    /**
235     * Get the value of dayOfMonth.
236     *
237     * @return int
238     */
239    @Override
240    public int getDayOfMonth()
241    {
242        return day_mo;
243    }
244
245    /**
246     * Set the value of dayOfMonth.
247     *
248     * @param v new value
249     */
250    @Override
251    public void setDayOfMonth(int v)
252    {
253        this.day_mo = v;
254    }
255
256    /**
257     * Get the value of task.
258     *
259     * @return String
260     */
261    @Override
262    public String getTask()
263    {
264        return task;
265    }
266
267    /**
268     * Set the value of task.
269     *
270     * @param v new value
271     */
272    @Override
273    public void setTask(String v)
274    {
275        this.task = v;
276    }
277}