亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? fastcronparser.java

?? oscache-2.4.1-full
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package com.opensymphony.oscache.util;

import java.text.ParseException;

import java.util.*;
import java.util.Calendar;

/**
 * Parses cron expressions and determines at what time in the past is the
 * most recent match for the supplied expression.
 *
 * @author <a href="&#109;a&#105;&#108;&#116;&#111;:chris&#64;swebtec.&#99;&#111;&#109;">Chris Miller</a>
 * @author $Author: ltorunski $
 * @version $Revision: 340 $
 */
public class FastCronParser {
    private static final int NUMBER_OF_CRON_FIELDS = 5;
    private static final int MINUTE = 0;
    private static final int HOUR = 1;
    private static final int DAY_OF_MONTH = 2;
    private static final int MONTH = 3;
    private static final int DAY_OF_WEEK = 4;

    // Lookup tables that hold the min/max/size of each of the above field types.
    // These tables are precalculated for performance.
    private static final int[] MIN_VALUE = {0, 0, 1, 1, 0};
    private static final int[] MAX_VALUE = {59, 23, 31, 12, 6};

    /**
     * A lookup table holding the number of days in each month (with the obvious exception
     * that February requires special handling).
     */
    private static final int[] DAYS_IN_MONTH = {
        31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
    };

    /**
     * Holds the raw cron expression that this parser is handling.
     */
    private String cronExpression = null;

    /**
    * This is the main lookup table that holds a parsed cron expression. each long
    * represents one of the above field types. Bits in each long value correspond
    * to one of the possbile field values - eg, for the minute field, bits 0 -> 59 in
    * <code>lookup[MINUTE]</code> map to minutes 0 -> 59 respectively. Bits are set if
    * the corresponding value is enabled. So if the minute field in the cron expression
    * was <code>"0,2-8,50"</code>, bits 0, 2, 3, 4, 5, 6, 7, 8 and 50 will be set.
    * If the cron expression is <code>"*"</code>, the long value is set to
    * <code>Long.MAX_VALUE</code>.
    */
    private long[] lookup = {
        Long.MAX_VALUE, Long.MAX_VALUE, Long.MAX_VALUE, Long.MAX_VALUE,
        Long.MAX_VALUE
    };

    /**
    * This is based on the contents of the <code>lookup</code> table. It holds the
    * <em>highest</em> valid field value for each field type.
    */
    private int[] lookupMax = {-1, -1, -1, -1, -1};

    /**
    * This is based on the contents of the <code>lookup</code> table. It holds the
    * <em>lowest</em> valid field value for each field type.
    */
    private int[] lookupMin = {
        Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE,
        Integer.MAX_VALUE, Integer.MAX_VALUE
    };

    /**
    * Creates a FastCronParser that uses a default cron expression of <code>"* * * * *"</cron>.
    * This will match any time that is supplied.
    */
    public FastCronParser() {
    }

    /**
    * Constructs a new FastCronParser based on the supplied expression.
    *
    * @throws ParseException if the supplied expression is not a valid cron expression.
    */
    public FastCronParser(String cronExpression) throws ParseException {
        setCronExpression(cronExpression);
    }

    /**
    * Resets the cron expression to the value supplied.
    *
    * @param cronExpression the new cron expression.
    *
    * @throws ParseException if the supplied expression is not a valid cron expression.
    */
    public void setCronExpression(String cronExpression) throws ParseException {
        if (cronExpression == null) {
            throw new IllegalArgumentException("Cron time expression cannot be null");
        }

        this.cronExpression = cronExpression;
        parseExpression(cronExpression);
    }

    /**
    * Retrieves the current cron expression.
    *
    * @return the current cron expression.
    */
    public String getCronExpression() {
        return this.cronExpression;
    }

    /**
    * Determines whether this cron expression matches a date/time that is more recent
    * than the one supplied.
    *
    * @param time The time to compare the cron expression against.
    *
    * @return <code>true</code> if the cron expression matches a time that is closer
    * to the current time than the supplied time is, <code>false</code> otherwise.
    */
    public boolean hasMoreRecentMatch(long time) {
        return time < getTimeBefore(System.currentTimeMillis());
    }

    /**
    * Find the most recent time that matches this cron expression. This time will
    * always be in the past, ie a lower value than the supplied time.
    *
    * @param time The time (in milliseconds) that we're using as our upper bound.
    *
    * @return The time (in milliseconds) when this cron event last occurred.
    */
    public long getTimeBefore(long time) {
        // It would be nice to get rid of the Calendar class for speed, but it's a lot of work...
        // We create this
        Calendar cal = new GregorianCalendar();
        cal.setTimeInMillis(time);

        int minute = cal.get(Calendar.MINUTE);
        int hour = cal.get(Calendar.HOUR_OF_DAY);
        int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);
        int month = cal.get(Calendar.MONTH) + 1; // Calendar is 0-based for this field, and we are 1-based
        int year = cal.get(Calendar.YEAR);

        long validMinutes = lookup[MINUTE];
        long validHours = lookup[HOUR];
        long validDaysOfMonth = lookup[DAY_OF_MONTH];
        long validMonths = lookup[MONTH];
        long validDaysOfWeek = lookup[DAY_OF_WEEK];

        // Find out if we have a Day of Week or Day of Month field
        boolean haveDOM = validDaysOfMonth != Long.MAX_VALUE;
        boolean haveDOW = validDaysOfWeek != Long.MAX_VALUE;

        boolean skippedNonLeapYear = false;

        while (true) {
            boolean retry = false;

            // Clean up the month if it was wrapped in a previous iteration
            if (month < 1) {
                month += 12;
                year--;
            }

            // get month...................................................
            boolean found = false;

            if (validMonths != Long.MAX_VALUE) {
                for (int i = month + 11; i > (month - 1); i--) {
                    int testMonth = (i % 12) + 1;

                    // Check if the month is valid
                    if (((1L << (testMonth - 1)) & validMonths) != 0) {
                        if ((testMonth > month) || skippedNonLeapYear) {
                            year--;
                        }

                        // Check there are enough days in this month (catches non leap-years trying to match the 29th Feb)
                        int numDays = numberOfDaysInMonth(testMonth, year);

                        if (!haveDOM || (numDays >= lookupMin[DAY_OF_MONTH])) {
                            if ((month != testMonth) || skippedNonLeapYear) {
                                // New DOM = min(maxDOM, prevDays);  ie, the highest valid value
                                dayOfMonth = (numDays <= lookupMax[DAY_OF_MONTH]) ? numDays : lookupMax[DAY_OF_MONTH];
                                hour = lookupMax[HOUR];
                                minute = lookupMax[MINUTE];
                                month = testMonth;
                            }

                            found = true;
                            break;
                        }
                    }
                }

                skippedNonLeapYear = false;

                if (!found) {
                    // The only time we drop out here is when we're searching for the 29th of February and no other date!
                    skippedNonLeapYear = true;
                    continue;
                }
            }

            // Clean up if the dayOfMonth was wrapped. This takes leap years into account.
            if (dayOfMonth < 1) {
                month--;
                dayOfMonth += numberOfDaysInMonth(month, year);
                hour = lookupMax[HOUR];
                continue;
            }

            // get day...................................................
            if (haveDOM && !haveDOW) { // get day using just the DAY_OF_MONTH token

                int daysInThisMonth = numberOfDaysInMonth(month, year);
                int daysInPreviousMonth = numberOfDaysInMonth(month - 1, year);

                // Find the highest valid day that is below the current day
                for (int i = dayOfMonth + 30; i > (dayOfMonth - 1); i--) {
                    int testDayOfMonth = (i % 31) + 1;

                    // Skip over any days that don't actually exist (eg 31st April)
                    if ((testDayOfMonth <= dayOfMonth) && (testDayOfMonth > daysInThisMonth)) {
                        continue;
                    }

                    if ((testDayOfMonth > dayOfMonth) && (testDayOfMonth > daysInPreviousMonth)) {
                        continue;
                    }

                    if (((1L << (testDayOfMonth - 1)) & validDaysOfMonth) != 0) {
                        if (testDayOfMonth > dayOfMonth) {
                            // We've found a valid day, but we had to move back a month
                            month--;
                            retry = true;
                        }

                        if (dayOfMonth != testDayOfMonth) {
                            hour = lookupMax[HOUR];
                            minute = lookupMax[MINUTE];
                        }

                        dayOfMonth = testDayOfMonth;
                        break;
                    }
                }

                if (retry) {
                    continue;
                }
            } else if (haveDOW && !haveDOM) { // get day using just the DAY_OF_WEEK token

                int daysLost = 0;
                int currentDOW = dayOfWeek(dayOfMonth, month, year);

                for (int i = currentDOW + 7; i > currentDOW; i--) {
                    int testDOW = i % 7;

                    if (((1L << testDOW) & validDaysOfWeek) != 0) {
                        dayOfMonth -= daysLost;

                        if (dayOfMonth < 1) {
                            // We've wrapped back a month
                            month--;
                            dayOfMonth += numberOfDaysInMonth(month, year);
                            retry = true;
                        }

                        if (currentDOW != testDOW) {
                            hour = lookupMax[HOUR];
                            minute = lookupMax[MINUTE];
                        }

                        break;
                    }

                    daysLost++;
                }

                if (retry) {
                    continue;
                }
            }

            // Clean up if the hour has been wrapped
            if (hour < 0) {
                hour += 24;
                dayOfMonth--;
                continue;
            }

            // get hour...................................................
            if (validHours != Long.MAX_VALUE) {
                // Find the highest valid hour that is below the current hour
                for (int i = hour + 24; i > hour; i--) {
                    int testHour = i % 24;

                    if (((1L << testHour) & validHours) != 0) {
                        if (testHour > hour) {
                            // We've found an hour, but we had to move back a day
                            dayOfMonth--;
                            retry = true;
                        }

                        if (hour != testHour) {
                            minute = lookupMax[MINUTE];
                        }

                        hour = testHour;
                        break;
                    }
                }

                if (retry) {
                    continue;
                }
            }

            // get minute.................................................
            if (validMinutes != Long.MAX_VALUE) {
                // Find the highest valid minute that is below the current minute
                for (int i = minute + 60; i > minute; i--) {
                    int testMinute = i % 60;

                    if (((1L << testMinute) & validMinutes) != 0) {
                        if (testMinute > minute) {
                            // We've found a minute, but we had to move back an hour
                            hour--;
                            retry = true;
                        }

                        minute = testMinute;
                        break;
                    }
                }

                if (retry) {
                    continue;
                }
            }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品一线二线三线精华| 欧美性色黄大片手机版| 成人毛片老司机大片| 91精品国产综合久久久久久久| 国产精品不卡一区二区三区| 另类的小说在线视频另类成人小视频在线 | 欧美成人国产一区二区| 一卡二卡三卡日韩欧美| aaa国产一区| 亚洲国产精品99久久久久久久久| 麻豆国产精品视频| 欧美人动与zoxxxx乱| 日本一区二区三区电影| 久色婷婷小香蕉久久| 69堂亚洲精品首页| 亚洲午夜av在线| 在线看国产一区| 亚洲免费观看高清| www.色综合.com| 欧美激情资源网| 国产乱人伦精品一区二区在线观看 | 国产精品自产自拍| 精品福利一区二区三区 | 中文字幕日韩精品一区 | 亚洲黄网站在线观看| 不卡av在线网| 中文字幕巨乱亚洲| 成人激情综合网站| 国产精品免费视频一区| 成人免费高清在线观看| 日本一区二区三区dvd视频在线| 精品无人码麻豆乱码1区2区| 欧美一级艳片视频免费观看| 男男视频亚洲欧美| 欧美大片一区二区| 欧美在线你懂得| 亚洲情趣在线观看| 91在线精品一区二区| 中文字幕亚洲不卡| 国产成人精品免费| 国产亚洲欧洲997久久综合| 蜜臂av日日欢夜夜爽一区| 91精品国产全国免费观看| 天天综合天天综合色| 欧美一区二区在线不卡| 日本伊人色综合网| 精品国产免费久久 | 亚洲五码中文字幕| 欧美日本在线视频| 麻豆精品国产91久久久久久| 精品国产一二三区| 国产激情91久久精品导航| 国产精品妹子av| 97久久人人超碰| 亚洲成人中文在线| 日韩欧美www| 国产成人免费在线视频| 自拍偷拍亚洲欧美日韩| 在线亚洲一区观看| 日本午夜一区二区| 2023国产精品自拍| 成人av网址在线| 亚洲综合视频在线| 91麻豆精品国产91久久久更新时间 | 国产日产亚洲精品系列| 一区二区三区色| 欧洲中文字幕精品| 日韩精彩视频在线观看| 欧美videos中文字幕| 成人高清视频在线观看| 一区二区免费视频| 欧美成人乱码一区二区三区| 高清国产午夜精品久久久久久| 亚洲人精品午夜| 国产黄人亚洲片| 一区二区三区欧美日韩| 日韩午夜激情av| 波多野结衣视频一区| 亚洲成人动漫一区| ww亚洲ww在线观看国产| 91女厕偷拍女厕偷拍高清| 日韩av二区在线播放| 欧美国产精品一区二区| 欧美日韩综合一区| 国产一区久久久| 一区二区国产盗摄色噜噜| 精品国产凹凸成av人导航| 99久久国产综合精品麻豆| 日韩成人一区二区三区在线观看| 国产女主播在线一区二区| 欧美日韩在线播放| 日韩欧美一区中文| 91日韩在线专区| 久久国产精品99精品国产| 亚洲精品国产无天堂网2021| 精品av久久707| 色婷婷综合久久久久中文| 精品亚洲免费视频| 怡红院av一区二区三区| 欧美精品一区二区三区久久久| 91精彩视频在线| 国产成人在线视频网站| 天天操天天色综合| 最新日韩av在线| 日韩你懂的在线观看| 色妹子一区二区| 国产精品一二三在| 免费视频一区二区| 亚洲综合激情小说| 国产精品女主播av| 欧美精品一区视频| 欧美电影在哪看比较好| 91在线观看下载| 精品无码三级在线观看视频| 午夜久久久久久久久| 日韩美女视频19| 久久欧美中文字幕| 91精品国产色综合久久不卡蜜臀| 色噜噜夜夜夜综合网| 成人福利视频网站| 国产一区二区精品久久| 日本美女一区二区| 亚洲成国产人片在线观看| 亚洲欧洲综合另类| 国产精品三级视频| 久久久国产精华| 欧美成人bangbros| 7777女厕盗摄久久久| 欧美丝袜丝nylons| 色综合久久综合网97色综合| 成人一级黄色片| 国产精品资源在线| 黄色日韩三级电影| 秋霞午夜av一区二区三区| 亚洲在线视频免费观看| 亚洲女同女同女同女同女同69| 国产精品丝袜久久久久久app| 久久伊人蜜桃av一区二区| 精品国产伦一区二区三区观看方式| 欧美精品v日韩精品v韩国精品v| 欧美亚洲愉拍一区二区| 在线观看成人免费视频| 91免费看视频| 色噜噜久久综合| 日本高清免费不卡视频| 日本高清不卡视频| 在线免费观看视频一区| 91成人在线免费观看| 色婷婷激情综合| 欧美影院精品一区| 欧美日韩一区二区三区四区五区 | 99精品一区二区三区| 不卡一区二区三区四区| 成人h版在线观看| 成人午夜短视频| 99re热这里只有精品免费视频| av亚洲精华国产精华| 91亚洲资源网| 欧美色男人天堂| 亚洲午夜精品在线| 亚洲图片欧美综合| 午夜不卡av在线| 蜜桃一区二区三区四区| 看片网站欧美日韩| 国产美女主播视频一区| 成人丝袜高跟foot| 91免费看视频| 欧美日韩在线播放三区| 中文字幕在线不卡视频| 国产乱码一区二区三区| 国产精品69久久久久水密桃| 国产福利精品导航| hitomi一区二区三区精品| 91老司机福利 在线| 欧美色网一区二区| 欧美大黄免费观看| 久久精品夜夜夜夜久久| 亚洲欧洲韩国日本视频| 亚洲国产视频在线| 麻豆国产欧美日韩综合精品二区| 国产精品影视在线观看| 91蜜桃网址入口| 欧美精品1区2区3区| 欧美一级黄色片| 欧美国产国产综合| 一区二区免费在线播放| 麻豆精品久久精品色综合| 成人动漫中文字幕| 欧美日韩亚洲综合| 久久久久久久久久久久电影| 中文字幕亚洲视频| 午夜免费欧美电影| 国产盗摄一区二区三区| 91高清视频免费看| 欧美岛国在线观看| 亚洲视频 欧洲视频| 蜜臀精品久久久久久蜜臀| 成人综合在线观看| 欧美日韩视频专区在线播放| 久久亚洲一级片|