mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix doc
This commit is contained in:
parent
b1920b6fa2
commit
be72eab9a0
@ -152,7 +152,6 @@ public class CronPattern {
|
|||||||
* @return 如果匹配返回 {@code true}, 否则返回 {@code false}
|
* @return 如果匹配返回 {@code true}, 否则返回 {@code false}
|
||||||
*/
|
*/
|
||||||
public boolean match(GregorianCalendar calendar, boolean isMatchSecond) {
|
public boolean match(GregorianCalendar calendar, boolean isMatchSecond) {
|
||||||
final int second = calendar.get(Calendar.SECOND);
|
|
||||||
final int minute = calendar.get(Calendar.MINUTE);
|
final int minute = calendar.get(Calendar.MINUTE);
|
||||||
final int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
final int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||||
final int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
final int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
||||||
@ -162,7 +161,7 @@ public class CronPattern {
|
|||||||
|
|
||||||
boolean eval;
|
boolean eval;
|
||||||
for (int i = 0; i < matcherSize; i++) {
|
for (int i = 0; i < matcherSize; i++) {
|
||||||
eval = ((false == isMatchSecond) || secondMatchers.get(i).match(second)) // 匹配秒(非秒匹配模式下始终返回true)
|
eval = ((false == isMatchSecond) || secondMatchers.get(i).match(calendar.get(Calendar.SECOND))) // 匹配秒(非秒匹配模式下始终返回true)
|
||||||
&& minuteMatchers.get(i).match(minute)// 匹配分
|
&& minuteMatchers.get(i).match(minute)// 匹配分
|
||||||
&& hourMatchers.get(i).match(hour)// 匹配时
|
&& hourMatchers.get(i).match(hour)// 匹配时
|
||||||
&& isMatchDayOfMonth(dayOfMonthMatchers.get(i), dayOfMonth, month, calendar.isLeapYear(year))// 匹配日
|
&& isMatchDayOfMonth(dayOfMonthMatchers.get(i), dayOfMonth, month, calendar.isLeapYear(year))// 匹配日
|
||||||
|
@ -4,15 +4,17 @@ import cn.hutool.cron.CronException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 星期值处理<br>
|
* 星期值处理<br>
|
||||||
* 1表示星期一,2表示星期二,依次类推,0和7都可以表示星期日
|
* 1表示星期一,2表示星期二,依次类推,0和7都可以表示星期日<br>
|
||||||
|
* {@code L}表示周六
|
||||||
*
|
*
|
||||||
* @author Looly
|
* @author Looly
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class DayOfWeekValueParser extends SimpleValueParser {
|
public class DayOfWeekValueParser extends SimpleValueParser {
|
||||||
|
|
||||||
/** Weeks aliases. */
|
/**
|
||||||
private static final String[] ALIASES = { "sun", "mon", "tue", "wed", "thu", "fri", "sat" };
|
* Weeks aliases.
|
||||||
|
*/
|
||||||
|
private static final String[] ALIASES = {"sun", "mon", "tue", "wed", "thu", "fri", "sat"};
|
||||||
|
|
||||||
public DayOfWeekValueParser() {
|
public DayOfWeekValueParser() {
|
||||||
super(0, 7);
|
super(0, 7);
|
||||||
@ -33,12 +35,13 @@ public class DayOfWeekValueParser extends SimpleValueParser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析别名
|
* 解析别名
|
||||||
|
*
|
||||||
* @param value 别名值
|
* @param value 别名值
|
||||||
* @return 月份int值
|
* @return 月份int值
|
||||||
* @throws CronException 无效别名抛出此异常
|
* @throws CronException 无效别名抛出此异常
|
||||||
*/
|
*/
|
||||||
private int parseAlias(String value) throws CronException {
|
private int parseAlias(String value) throws CronException {
|
||||||
if("L".equalsIgnoreCase(value)){
|
if ("L".equalsIgnoreCase(value)) {
|
||||||
//最后一天为星期六
|
//最后一天为星期六
|
||||||
return ALIASES.length - 1;
|
return ALIASES.length - 1;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package cn.hutool.cron.pattern.parser;
|
package cn.hutool.cron.pattern.parser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小时值处理
|
* 小时值处理<br>
|
||||||
* @author Looly
|
* 小时被限定在0-23
|
||||||
*
|
*
|
||||||
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class HourValueParser extends SimpleValueParser{
|
public class HourValueParser extends SimpleValueParser {
|
||||||
|
|
||||||
public HourValueParser() {
|
public HourValueParser() {
|
||||||
super(0, 23);
|
super(0, 23);
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package cn.hutool.cron.pattern.parser;
|
package cn.hutool.cron.pattern.parser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分钟值处理
|
* 分钟值处理<br>
|
||||||
* @author Looly
|
* 限定于0-59
|
||||||
*
|
*
|
||||||
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class MinuteValueParser extends SimpleValueParser{
|
public class MinuteValueParser extends SimpleValueParser {
|
||||||
|
|
||||||
public MinuteValueParser() {
|
public MinuteValueParser() {
|
||||||
super(0, 59);
|
super(0, 59);
|
||||||
|
@ -3,15 +3,17 @@ package cn.hutool.cron.pattern.parser;
|
|||||||
import cn.hutool.cron.CronException;
|
import cn.hutool.cron.CronException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 月份值处理
|
* 月份值处理<br>
|
||||||
|
* 限定于1-12,1表示一月,支持别名,如一月是{@code jan}
|
||||||
*
|
*
|
||||||
* @author Looly
|
* @author Looly
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class MonthValueParser extends SimpleValueParser {
|
public class MonthValueParser extends SimpleValueParser {
|
||||||
|
|
||||||
/** Months aliases. */
|
/**
|
||||||
private static final String[] ALIASES = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" };
|
* Months aliases.
|
||||||
|
*/
|
||||||
|
private static final String[] ALIASES = {"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"};
|
||||||
|
|
||||||
public MonthValueParser() {
|
public MonthValueParser() {
|
||||||
super(1, 12);
|
super(1, 12);
|
||||||
@ -28,6 +30,7 @@ public class MonthValueParser extends SimpleValueParser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析别名
|
* 解析别名
|
||||||
|
*
|
||||||
* @param value 别名值
|
* @param value 别名值
|
||||||
* @return 月份int值
|
* @return 月份int值
|
||||||
* @throws CronException 无效月别名抛出此异常
|
* @throws CronException 无效月别名抛出此异常
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package cn.hutool.cron.pattern.parser;
|
package cn.hutool.cron.pattern.parser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 秒值处理
|
* 秒值处理<br>
|
||||||
* @author Looly
|
* 限定于0-59
|
||||||
*
|
*
|
||||||
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class SecondValueParser extends MinuteValueParser{
|
public class SecondValueParser extends MinuteValueParser {
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,20 @@ package cn.hutool.cron.pattern.parser;
|
|||||||
import cn.hutool.cron.CronException;
|
import cn.hutool.cron.CronException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 简易值转换器。将给定String值转为int
|
* 简易值转换器。将给定String值转为int,并限定最大值和最小值<br>
|
||||||
* @author Looly
|
* 此类同时识别{@code L} 为最大值。
|
||||||
*
|
*
|
||||||
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class SimpleValueParser implements ValueParser {
|
public class SimpleValueParser implements ValueParser {
|
||||||
|
|
||||||
/** 最小值(包括) */
|
/**
|
||||||
|
* 最小值(包括)
|
||||||
|
*/
|
||||||
protected int min;
|
protected int min;
|
||||||
/** 最大值(包括) */
|
/**
|
||||||
|
* 最大值(包括)
|
||||||
|
*/
|
||||||
protected int max;
|
protected int max;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,10 +26,10 @@ public class SimpleValueParser implements ValueParser {
|
|||||||
* @param max 最大值(包括)
|
* @param max 最大值(包括)
|
||||||
*/
|
*/
|
||||||
public SimpleValueParser(int min, int max) {
|
public SimpleValueParser(int min, int max) {
|
||||||
if(min > max){
|
if (min > max) {
|
||||||
this.min = max;
|
this.min = max;
|
||||||
this.max = min;
|
this.max = min;
|
||||||
}else{
|
} else {
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
}
|
}
|
||||||
@ -32,7 +37,7 @@ public class SimpleValueParser implements ValueParser {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int parse(String value) throws CronException {
|
public int parse(String value) throws CronException {
|
||||||
if("L".equalsIgnoreCase(value)){
|
if ("L".equalsIgnoreCase(value)) {
|
||||||
// L表示最大值
|
// L表示最大值
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package cn.hutool.cron.pattern.parser;
|
package cn.hutool.cron.pattern.parser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 年值处理
|
* 年值处理<br>
|
||||||
* @author Looly
|
* 年的限定在1970-2099年
|
||||||
*
|
*
|
||||||
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class YearValueParser extends SimpleValueParser{
|
public class YearValueParser extends SimpleValueParser {
|
||||||
|
|
||||||
public YearValueParser() {
|
public YearValueParser() {
|
||||||
super(1970, 2099);
|
super(1970, 2099);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user