Package org.aoju.bus.cron
Class Expression
java.lang.Object
org.aoju.bus.cron.Expression
- All Implemented Interfaces:
Serializable,Cloneable
类似unix cron表达式提供解析器和执行器
Crontab表达式提供了指定复杂时间组合的能力
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Integerprotected static final intprotected static final intprotected static final intprotected booleanprotected static final intprotected intprotected booleanprotected booleanstatic final intprotected static final intprotected static final intprotected booleanprotected static final Integerprotected static final intprotected intprotected static final intprotected static final int -
Constructor Summary
ConstructorsConstructorDescriptionExpression(String cronExpression) 根据指定的参数构造一个新的CronExpressionExpression(Expression expression) 构造一个新的CronExpression作为现有*实例的副本 -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddToSet(int val, int end, int incr, int type) protected voidbuildExpression(String expression) protected intprotected intfindNextWhiteSpace(int i, String s) protected intprotected Stringprotected StringNOT YET IMPLEMENTED: Returns the final time that theCronExpressionwill match.protected intgetLastDayOfMonth(int monthNum, int year) protected intgetNextInvalidTimeAfter(Date date) getNextValidTimeAfter(Date date) protected intgetNumericValue(String s, int i) getTimeAfter(Date afterTime) getTimeBefore(Date endTime) NOT YET IMPLEMENTED: Returns the time before the given time that theCronExpressionmatches.protected org.aoju.bus.cron.Expression.ValueSetbooleanisSatisfiedBy(Date date) 指示给定的日期是否满足cron表达式 请注意,毫秒将被忽略,因此两个日期在同一秒的不同毫秒 处始终具有相同的结果static booleanisValidExpression(String cronExpression) 指示是否可以将指定的cron表达式解析为有效的cron表达式protected voidsetCalendarHour(Calendar cal, int hour) Advance the calendar to the particular hour paying particular attention to daylight saving problems.voidsetTimeZone(TimeZone timeZone) protected intskipWhiteSpace(int i, String s) protected intstoreExpressionVals(int pos, String s, int type) toString()static voidvalidateExpression(String cronExpression)
-
Field Details
-
MAX_YEAR
public static final int MAX_YEAR -
SECOND
protected static final int SECOND- See Also:
-
MINUTE
protected static final int MINUTE- See Also:
-
HOUR
protected static final int HOUR- See Also:
-
DAY_OF_MONTH
protected static final int DAY_OF_MONTH- See Also:
-
MONTH
protected static final int MONTH- See Also:
-
DAY_OF_WEEK
protected static final int DAY_OF_WEEK- See Also:
-
YEAR
protected static final int YEAR- See Also:
-
ALL_SPEC_INT
protected static final int ALL_SPEC_INT- See Also:
-
NO_SPEC_INT
protected static final int NO_SPEC_INT- See Also:
-
ALL_SPEC
-
NO_SPEC
-
monthMap
-
dayMap
-
seconds
-
minutes
-
hours
-
daysOfMonth
-
months
-
daysOfWeek
-
years
-
lastdayOfWeek
protected transient boolean lastdayOfWeek -
nthdayOfWeek
protected transient int nthdayOfWeek -
lastdayOfMonth
protected transient boolean lastdayOfMonth -
nearestWeekday
protected transient boolean nearestWeekday -
lastdayOffset
protected transient int lastdayOffset -
expressionParsed
protected transient boolean expressionParsed
-
-
Constructor Details
-
Expression
根据指定的参数构造一个新的CronExpression- Parameters:
cronExpression- 新对象应表示的cron表达式的字符串表示形式- Throws:
ParseException- 如果字符串表达式不能解析为有效的CronExpression
-
Expression
构造一个新的CronExpression作为现有*实例的副本- Parameters:
expression- 要复制的现有cron表达式
-
-
Method Details
-
isValidExpression
指示是否可以将指定的cron表达式解析为有效的cron表达式- Parameters:
cronExpression- 要评估的表达式- Returns:
- 指示给定表达式是否为有效cron表达式的布尔值
-
validateExpression
- Throws:
ParseException
-
isSatisfiedBy
指示给定的日期是否满足cron表达式 请注意,毫秒将被忽略,因此两个日期在同一秒的不同毫秒 处始终具有相同的结果- Parameters:
date- 评估日期- Returns:
- 指示给定日期是否满足cron 表达式的布尔值
-
getNextValidTimeAfter
-
getNextInvalidTimeAfter
-
getTimeZone
-
setTimeZone
-
toString
-
buildExpression
- Throws:
ParseException
-
storeExpressionVals
- Throws:
ParseException
-
checkNext
- Throws:
ParseException
-
getCronExpression
-
getExpressionSummary
-
getExpressionSetSummary
-
getExpressionSetSummary
-
skipWhiteSpace
-
findNextWhiteSpace
-
addToSet
- Throws:
ParseException
-
getValue
-
getNumericValue
-
getMonthNumber
-
getDayOfWeekNumber
-
getTimeAfter
-
setCalendarHour
Advance the calendar to the particular hour paying particular attention to daylight saving problems.- Parameters:
cal- the calendar to operate onhour- the hour to set
-
getTimeBefore
NOT YET IMPLEMENTED: Returns the time before the given time that theCronExpressionmatches.- Parameters:
endTime- end time- Returns:
- date
-
getFinalFireTime
NOT YET IMPLEMENTED: Returns the final time that theCronExpressionwill match.- Returns:
- time
-
getLastDayOfMonth
protected int getLastDayOfMonth(int monthNum, int year)
-