亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
成人综合在线观看| 中文字幕在线观看一区| 99久久综合精品| 日韩av一区二区三区四区| 色老头久久综合| 国产成人免费视频网站| 激情伊人五月天久久综合| 欧美激情一区二区在线| 国产一区二区成人久久免费影院| 亚洲国产成人av网| 精品无人码麻豆乱码1区2区| 丁香五精品蜜臀久久久久99网站| av在线播放一区二区三区| 亚洲免费资源在线播放| 99精品视频在线观看| 天天色天天爱天天射综合| 国产日本亚洲高清| 69久久99精品久久久久婷婷| 972aa.com艺术欧美| 免费在线观看成人| 欧美性色黄大片| 国产精品欧美一区二区三区| 视频一区二区欧美| 91久久免费观看| 国产精品妹子av| 色视频一区二区| 亚洲国产精品一区二区久久恐怖片| 中文字幕一区二区三区av| 亚洲三级小视频| 欧美一区二区在线播放| 国产精品理论片| 日韩视频一区在线观看| 亚洲综合男人的天堂| 丝袜美腿亚洲色图| 激情另类小说区图片区视频区| 91精品国产色综合久久不卡电影| 国产精品麻豆久久久| 国产成人夜色高潮福利影视| 欧美精品一区在线观看| 99精品视频在线免费观看| 欧美国产综合色视频| 欧美国产精品久久| 美女网站色91| 日韩午夜小视频| 成人一区二区三区视频在线观看| 亚洲蜜臀av乱码久久精品蜜桃| 欧美视频一区二区三区在线观看| 91麻豆.com| 欧美一区二区啪啪| 久久综合久久久久88| 亚洲日本一区二区三区| 另类综合日韩欧美亚洲| 国产另类ts人妖一区二区| 五月婷婷久久丁香| 久久这里只有精品视频网| 国产精品一区二区你懂的| 亚洲欧洲无码一区二区三区| 国产亚洲综合色| 欧美不卡一区二区三区四区| 欧美三级日韩三级国产三级| 成人免费视频网站在线观看| 韩国成人福利片在线播放| eeuss鲁片一区二区三区| 欧美日韩精品一区二区天天拍小说 | 一区二区三区欧美在线观看| 国内国产精品久久| 日韩欧美中文字幕一区| 成人欧美一区二区三区1314| 黄页视频在线91| 日韩欧美在线1卡| 色综合一区二区| 欧美日韩一区二区三区高清| 国产精品1024| 一个色妞综合视频在线观看| 久久久精品欧美丰满| 成人免费看视频| 麻豆91小视频| 久久久久久久综合狠狠综合| 欧美高清激情brazzers| 在线成人免费观看| 国产精品久久久久影视| 极品少妇xxxx偷拍精品少妇| 国产黄色91视频| 久久网站热最新地址| 国产91富婆露脸刺激对白| 国产亚洲短视频| 91香蕉视频污在线| 水蜜桃久久夜色精品一区的特点| 欧美色倩网站大全免费| 热久久一区二区| 欧美三级电影在线看| 国产婷婷色一区二区三区在线| 国产精品毛片久久久久久| 精品写真视频在线观看| hitomi一区二区三区精品| 精品福利二区三区| 香蕉乱码成人久久天堂爱免费| 懂色av一区二区三区免费观看| 69av一区二区三区| 精品久久久久一区二区国产| 亚洲成年人网站在线观看| 成人av动漫网站| 久久久精品黄色| 91丨九色丨蝌蚪富婆spa| 大美女一区二区三区| 91麻豆精品国产91久久久 | 欧美在线综合视频| 亚洲色图第一区| 99re视频精品| 免费欧美日韩国产三级电影| 91免费小视频| 国产精品一区二区在线观看网站| 亚洲日本免费电影| 国产精品成人在线观看| 26uuu另类欧美亚洲曰本| 久久嫩草精品久久久精品| 欧美日韩一区高清| 久草这里只有精品视频| 欧美不卡一二三| 国产成人综合在线观看| 久久中文字幕电影| 91在线观看高清| 亚洲精品成人在线| 精品国产自在久精品国产| 国产毛片精品国产一区二区三区| 久久久精品中文字幕麻豆发布| 国产精品女主播av| 亚洲精品亚洲人成人网| 717成人午夜免费福利电影| 成人99免费视频| 国产美女精品一区二区三区| 亚洲国产欧美在线| 国产精品国产馆在线真实露脸| 日韩精品在线一区| 欧美性xxxxxxxx| 91免费小视频| 99久久免费精品高清特色大片| 另类小说综合欧美亚洲| 亚洲午夜日本在线观看| 国产精品麻豆99久久久久久| 精品国产欧美一区二区| 欧美高清视频不卡网| 欧美色手机在线观看| 一本大道av一区二区在线播放| 国产成人免费在线视频| 欧美成人三级在线| 精品国产伦一区二区三区观看体验| 2021国产精品久久精品| 欧美一区日本一区韩国一区| 亚洲一区二区三区在线| 久久亚洲私人国产精品va媚药| 欧美在线观看一区| 欧美日韩成人一区二区| 欧美大肚乱孕交hd孕妇| 5858s免费视频成人| 色素色在线综合| 亚洲日本在线视频观看| 成人黄动漫网站免费app| 日韩精品专区在线影院重磅| 亚洲v日本v欧美v久久精品| 国产精品欧美极品| 国产精品热久久久久夜色精品三区 | 亚洲欧洲日韩女同| 久久精品亚洲麻豆av一区二区| 日韩免费观看高清完整版| 国产精品网站导航| 国产精品视频一二三| 夜夜操天天操亚洲| 奇米色一区二区三区四区| 另类成人小视频在线| 日本福利一区二区| 一本一道久久a久久精品| 亚洲成av人片一区二区三区| 中文字幕在线不卡视频| 91在线视频18| 在线观看亚洲专区| 欧美一卡二卡三卡| www国产精品av| 自拍偷自拍亚洲精品播放| 一区二区久久久久久| 欧美a级一区二区| 国产一区啦啦啦在线观看| 国产精品一区二区久激情瑜伽| 国产999精品久久| 色94色欧美sute亚洲线路一ni | 日韩美女啊v在线免费观看| 亚洲一区av在线| 国产一区二区美女诱惑| 色一区在线观看| 91精品国产手机| 国产精品久久久久久户外露出| 亚洲午夜激情av| 韩国成人福利片在线播放| 一本大道久久a久久综合| 日韩欧美一区二区不卡| 国产一区二区免费在线| 欧美日韩在线精品一区二区三区激情| 国产精品美女久久久久av爽李琼 | 国产亚洲精久久久久久| 日本不卡不码高清免费观看|