📄 crontabentrybean.java
字号:
/**
* This file is part of the jcrontab package
* Copyright (C) 2001-2002 Israel Olalla
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA
*
* For questions, suggestions:
*
* iolalla@yahoo.com
*
*/
package org.jcrontab.data;
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.Calendar;
import java.util.StringTokenizer;
import org.jcrontab.CrontabBean;
/** CrontabEntryBeans represents each entry into
* crontab "DataSource" usually a file.
* This Bean allows jcrontab to interact with
* the information from CrontabEntry
* @author $Author: iolalla $
* @version $Revision: 1.23 $
*/
public class CrontabEntryBean implements Serializable {
private int id;
private CrontabBean[] cb;
private String hours;
private String minutes;
private String months;
private String daysOfWeek;
private String daysOfMonth;
private String className;
private String methodName = "";
private String[] extraInfo;
private boolean bextraInfo = false;
private String description;
private boolean[] bHours;
private boolean[] bMinutes;
private boolean[] bMonths;
private boolean[] bDaysOfWeek;
private boolean[] bDaysOfMonth;
private String entry;
/** Default constructor
*/
public CrontabEntryBean(){
bHours = new boolean[24];
bMinutes = new boolean[60];
bMonths = new boolean[12];
bDaysOfWeek = new boolean[7];
bDaysOfMonth = new boolean[31];
// Initializes all arrays to false
for(int i=0; i<60; i++) {
if(i<24)
bHours[i] = false;
if(i<60)
bMinutes[i] = false;
if(i<12)
bMonths[i] = false;
if(i<7)
bDaysOfWeek[i] = false;
if(i<31)
bDaysOfMonth[i] = false;
}
}
/** This constructor builds a CrontabEntryBean from a
* CrontabBean
* @param cb bean to build a CrontabEntry from CrontabBean
*
*/
public CrontabEntryBean(CrontabBean cb){
bHours = new boolean[24];
bMinutes = new boolean[60];
bMonths = new boolean[12];
bDaysOfWeek = new boolean[7];
bDaysOfMonth = new boolean[31];
// Initializes all arrays to false
for(int i=0; i<60; i++) {
if(i<24)
bHours[i] = false;
if(i<60)
bMinutes[i] = false;
if(i<12)
bMonths[i] = false;
if(i<7)
bDaysOfWeek[i] = false;
if(i<31)
bDaysOfMonth[i] = false;
}
this.cb[0] = cb;
}
/** This constructor builds a CrontabEntryBean from a
* Crontab Line usually something similar to:
* * * * * * org.jcrontab.jcrontab
* @param entry this line is the Crontab Line
* @throws CrontabEntryException this excption is thrown if the format of the
* line is not valid with POSIX estandar
*/
public CrontabEntryBean(String entry)
throws CrontabEntryException {
bHours = new boolean[24];
bMinutes = new boolean[60];
bMonths = new boolean[12];
bDaysOfWeek = new boolean[7];
bDaysOfMonth = new boolean[31];
// Initializes all arrays to false
for(int i=0; i<60; i++) {
if(i<24)
bHours[i] = false;
if(i<60)
bMinutes[i] = false;
if(i<12)
bMonths[i] = false;
if(i<7)
bDaysOfWeek[i] = false;
if(i<31)
bDaysOfMonth[i] = false;
}
setLine(entry);
}
/** Id setter
* @param id this integer identifies the CrontabEntryBean
*/
public void setId(int id){
this.id = id;
}
/** ClassName Setter
* @param className This is the name of the class to execute
*/
public void setClassName(String className){
this.className = className;
}
/** MethodName setter
* @param methodName the name of the method to execute
*/
public void setMethodName(String methodName){
this.methodName = methodName;
}
/** Extra info setter
* @param extraInfo this array represents the parameters passed to the
* task
*/
public void setExtraInfo(String[] extraInfo){
this.extraInfo = extraInfo;
}
/** Hours setter
* @param hours The hours to execute the Class,
* the values can take are [ * , 2-4 , 2,3,4,5 , 3/5]
*/
public void setHours(String hours){
this.hours = hours;
}
/** Minutes setter
* @param minutes The minutes to execute the Class,
* the values can take are [ * , 2-4 , 2,3,4,5 , 3/5]
*/
public void setMinutes(String minutes){
this.minutes = minutes;
}
/** Months setter
* @param months The Monts to execute the Class,
* the values can take are [ * , 2-4 , 2,3,4,5 , 3/5]
*/
public void setMonths(String months){
this.months = months;
}
/** Days of Week
* @param daysOfWeek The days of the week
*/
public void setDaysOfWeek(String daysOfWeek){
this.daysOfWeek = daysOfWeek;
}
/** Days of Month setter
* @param daysOfMonth The days of the month
*/
public void setDaysOfMonth(String daysOfMonth){
this.daysOfMonth = daysOfMonth;
}
/**Description setter
* @param description The desciption
*/
public void setDescription(String description) {
this.description = description;
}
/** Id getter
* @return the Id of this CrontabBean
*/
public int getId(){
return id;
}
/** Class Name getter
* @return the Class's Name of this CrontabBean
*/
public String getClassName(){
return className;
}
/** Method Name getter
* @return the Method's Name of this CrontabBean
*/
public String getMethodName(){
return methodName;
}
/** Extra Info getter
* @return the extraInfo of this CrontabBean
*/
public String[] getExtraInfo(){
return extraInfo;
}
/** Hours getter
* @return the hours of this CrontabBean
*/
public String getHours(){
return hours;
}
/** Minutes getter
* @return the minutes of this CrontabBean
*/
public String getMinutes(){
return minutes;
}
/** Months getter
* @return the months of this CrontabBean
*/
public String getMonths(){
return months;
}
/** Days of week getter
* @return the Days of week of this CrontabBean
*/
public String getDaysOfWeek(){
return daysOfWeek;
}
/** Days of Month getter
* @return the Id of this CrontabBean
*/
public String getDaysOfMonth(){
return daysOfMonth;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -