Coverage Report - org.apache.turbine.services.schedule.JobEntryNonPersistent
 
Classes in this File Line Coverage Branch Coverage Complexity
JobEntryNonPersistent
84%
28/33
75%
3/4
1,105
 
 1  
 package org.apache.turbine.services.schedule;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.turbine.util.TurbineException;
 23  
 
 24  
 /**
 25  
  * This is an implementation of a JobEntry with no persistence. It is used by the
 26  
  * {@link TurbineNonPersistentSchedulerService}
 27  
  *
 28  
  */
 29  
 public class JobEntryNonPersistent extends AbstractJobEntry
 30  
 {
 31  
     private int jobId;
 32  
     private int sec;
 33  
     private int min;
 34  
     private int hour;
 35  
     private int wd;
 36  
     private int day_mo;
 37  
     private String task;
 38  24
     private boolean isnew = true;
 39  
 
 40  
     /**
 41  
      * Default constructor
 42  
      */
 43  
     public JobEntryNonPersistent()
 44  
     {
 45  9
         super();
 46  9
     }
 47  
 
 48  
     /**
 49  
      * Constructor.
 50  
      *
 51  
      * Schedule a job to run on a certain point of time.<br>
 52  
      *
 53  
      * Example 1: Run the DefaultScheduledJob at 8:00am every 15th of
 54  
      * the month - <br>
 55  
      *
 56  
      * JobEntry je = new JobEntry(0,0,8,15,"DefaultScheduledJob");<br>
 57  
      *
 58  
      * Example 2: Run the DefaultScheduledJob at 8:00am every day -
 59  
      * <br>
 60  
      *
 61  
      * JobEntry je = new JobEntry(0,0,8,-1,"DefaultScheduledJob");<br>
 62  
      *
 63  
      * Example 3: Run the DefaultScheduledJob every 2 hours. - <br>
 64  
      *
 65  
      * JobEntry je = new JobEntry(0,120,-1,-1,"DefaultScheduledJob");<br>
 66  
      *
 67  
      * Example 4: Run the DefaultScheduledJob every 30 seconds. - <br>
 68  
      *
 69  
      * JobEntry je = new JobEntry(30,-1,-1,-1,"DefaultScheduledJob");<br>
 70  
      *
 71  
      * @param sec Value for entry "seconds".
 72  
      * @param min Value for entry "minutes".
 73  
      * @param hour Value for entry "hours".
 74  
      * @param wd Value for entry "week days".
 75  
      * @param day_mo Value for entry "month days".
 76  
      * @param task Task to execute.
 77  
      * @throws TurbineException a generic exception.
 78  
      */
 79  
     public JobEntryNonPersistent(int sec,
 80  
                     int min,
 81  
                     int hour,
 82  
                     int wd,
 83  
                     int day_mo,
 84  
                     String task)
 85  
             throws TurbineException
 86  
     {
 87  15
         super(sec, min, hour, wd, day_mo, task);
 88  15
     }
 89  
 
 90  
     /**
 91  
      * @see java.lang.Object#hashCode()
 92  
      */
 93  
     @Override
 94  
     public int hashCode()
 95  
     {
 96  0
         return Integer.valueOf(jobId).hashCode();
 97  
     }
 98  
 
 99  
     /**
 100  
      * @see java.lang.Object#equals(java.lang.Object)
 101  
      */
 102  
     @Override
 103  
     public boolean equals(Object obj)
 104  
     {
 105  21
         if (obj instanceof JobEntry)
 106  
         {
 107  21
             return compareTo((JobEntry)obj) == 0;
 108  
         }
 109  
 
 110  0
         return false;
 111  
     }
 112  
 
 113  
     /**
 114  
      * Return true, if the entry is not yet persisted
 115  
      */
 116  
     @Override
 117  
     public boolean isNew()
 118  
     {
 119  0
         boolean _isnew = isnew;
 120  0
         isnew = false;
 121  0
         return _isnew;
 122  
     }
 123  
 
 124  
     /**
 125  
      * Get the value of jobId.
 126  
      *
 127  
      * @return int
 128  
      */
 129  
     @Override
 130  
     public int getJobId()
 131  
     {
 132  66
         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  24
         this.jobId = v;
 144  24
     }
 145  
 
 146  
     /**
 147  
      * Get the value of second.
 148  
      *
 149  
      * @return int
 150  
      */
 151  
     @Override
 152  
     public int getSecond()
 153  
     {
 154  51
         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  15
         this.sec = v;
 166  15
     }
 167  
 
 168  
     /**
 169  
      * Get the value of minute.
 170  
      *
 171  
      * @return int
 172  
      */
 173  
     @Override
 174  
     public int getMinute()
 175  
     {
 176  45
         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  15
         this.min = v;
 188  15
     }
 189  
 
 190  
     /**
 191  
      * Get the value of hour.
 192  
      *
 193  
      * @return int
 194  
      */
 195  
     @Override
 196  
     public int getHour()
 197  
     {
 198  27
         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  15
         this.hour = v;
 210  15
     }
 211  
 
 212  
     /**
 213  
      * Get the value of weekDay.
 214  
      *
 215  
      * @return int
 216  
      */
 217  
     @Override
 218  
     public int getWeekDay()
 219  
     {
 220  27
         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  15
         this.wd = v;
 232  15
     }
 233  
 
 234  
     /**
 235  
      * Get the value of dayOfMonth.
 236  
      *
 237  
      * @return int
 238  
      */
 239  
     @Override
 240  
     public int getDayOfMonth()
 241  
     {
 242  27
         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  15
         this.day_mo = v;
 254  15
     }
 255  
 
 256  
     /**
 257  
      * Get the value of task.
 258  
      *
 259  
      * @return String
 260  
      */
 261  
     @Override
 262  
     public String getTask()
 263  
     {
 264  15
         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  15
         this.task = v;
 276  15
     }
 277  
 }