From f49c912acd0b844a10af4dd1c3694d958899d21b Mon Sep 17 00:00:00 2001 From: OHTAKE Tomohiro Date: Tue, 10 Jan 2012 12:07:18 +0900 Subject: [PATCH] Eliminate duplication of crontab lower/upper bounds They look different, but had been same. See 921359c1257a3e30aa46e491c2c00817b838e52c --- core/src/main/java/hudson/scheduler/BaseParser.java | 5 +++-- core/src/main/java/hudson/scheduler/CronTab.java | 6 +----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/scheduler/BaseParser.java b/core/src/main/java/hudson/scheduler/BaseParser.java index 13361d3e01..b54b97eaa4 100644 --- a/core/src/main/java/hudson/scheduler/BaseParser.java +++ b/core/src/main/java/hudson/scheduler/BaseParser.java @@ -36,8 +36,9 @@ import antlr.TokenStreamException; * @author Kohsuke Kawaguchi */ abstract class BaseParser extends LLkParser { - private static final int[] LOWER_BOUNDS = new int[] {0,0,1,1,0}; - private static final int[] UPPER_BOUNDS = new int[] {59,23,31,12,7}; + // lower/uppser bounds of fields (inclusive) + static final int[] LOWER_BOUNDS = new int[] {0,0,1,1,0}; + static final int[] UPPER_BOUNDS = new int[] {59,23,31,12,7}; /** * Used to pick a value from within the range diff --git a/core/src/main/java/hudson/scheduler/CronTab.java b/core/src/main/java/hudson/scheduler/CronTab.java index a892f542fb..9da5ae4f98 100644 --- a/core/src/main/java/hudson/scheduler/CronTab.java +++ b/core/src/main/java/hudson/scheduler/CronTab.java @@ -413,7 +413,7 @@ public final class CronTab { public String checkSanity() { for( int i=0; i<5; i++ ) { long bitMask = (i<4)?bits[i]:(long)dayOfWeek; - for( int j=LOWER_BOUNDS[i]; j<=UPPER_BOUNDS[i]; j++ ) { + for( int j=BaseParser.LOWER_BOUNDS[i]; j<=BaseParser.UPPER_BOUNDS[i]; j++ ) { if(!checkBits(bitMask,j)) { // this rank has a sparse entry. // if we have a sparse rank, one of them better be the left-most. @@ -428,8 +428,4 @@ public final class CronTab { return null; } - - // lower/uppser bounds of fields - private static final int[] LOWER_BOUNDS = new int[] {0,0,1,0,0}; - private static final int[] UPPER_BOUNDS = new int[] {59,23,31,12,7}; } -- GitLab