當前位置: 首頁>>代碼示例>>Java>>正文


Java ScheduleUnit類代碼示例

本文整理匯總了Java中com.espertech.esper.type.ScheduleUnit的典型用法代碼示例。如果您正苦於以下問題:Java ScheduleUnit類的具體用法?Java ScheduleUnit怎麽用?Java ScheduleUnit使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ScheduleUnit類屬於com.espertech.esper.type包,在下文中一共展示了ScheduleUnit類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: computeNextOccurance

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
/**
 * Computes the next lowest date in milliseconds based on a specification and the
 * from-time passed in.
 *
 * @param spec              defines the schedule
 * @param afterTimeInMillis defines the start time
 * @param timeZone          time zone
 * @param timeAbacus time abacus
 * @return a long date millisecond value for the next schedule occurance matching the spec
 */
public static long computeNextOccurance(ScheduleSpec spec, long afterTimeInMillis, TimeZone timeZone, TimeAbacus timeAbacus) {
    if ((ExecutionPathDebugLog.isDebugEnabled) && (log.isDebugEnabled())) {
        log.debug(".computeNextOccurance Computing next occurance, afterTimeInMillis=" + (new Date(afterTimeInMillis)) +
                "  as long=" + afterTimeInMillis +
                "  spec=" + spec);
    }


    // Add the minimum resolution to the start time to ensure we don't get the same exact time
    if (spec.getUnitValues().containsKey(ScheduleUnit.SECONDS)) {
        afterTimeInMillis += timeAbacus.getOneSecond();
    } else {
        afterTimeInMillis += 60 * timeAbacus.getOneSecond();
    }

    return compute(spec, afterTimeInMillis, timeZone, timeAbacus);
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:28,代碼來源:ScheduleComputeHelper.java

示例2: toString

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
@SuppressWarnings({"StringConcatenationInsideStringBufferAppend"})
public final String toString() {
    StringBuilder buffer = new StringBuilder();
    for (ScheduleUnit element : ScheduleUnit.values()) {
        if (!unitValues.containsKey(element)) {
            continue;
        }

        Set<Integer> valueSet = unitValues.get(element);
        buffer.append(element + "={");
        if (valueSet == null) {
            buffer.append("null");
        } else {
            String delimiter = "";
            for (int i : valueSet) {
                buffer.append(delimiter + i);
                delimiter = ",";
            }
        }
        buffer.append("} ");
    }
    return buffer.toString();
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:24,代碼來源:ScheduleSpec.java

示例3: computeNextOccurance

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
/**
 * Computes the next lowest date in milliseconds based on a specification and the
 * from-time passed in.
 * @param spec defines the schedule
 * @param afterTimeInMillis defines the start time
 * @return a long date millisecond value for the next schedule occurance matching the spec
 */
public static long computeNextOccurance(ScheduleSpec spec, long afterTimeInMillis)
{
    if ((ExecutionPathDebugLog.isDebugEnabled) && (log.isDebugEnabled()))
    {
        log.debug(".computeNextOccurance Computing next occurance, afterTimeInMillis=" + (new Date(afterTimeInMillis)) +
                  "  as long=" + afterTimeInMillis +
                  "  spec=" + spec);
    }


    // Add the minimum resolution to the start time to ensure we don't get the same exact time
    if (spec.getUnitValues().containsKey(ScheduleUnit.SECONDS))
    {
        afterTimeInMillis += MIN_OFFSET_MSEC;
    }
    else
    {
        afterTimeInMillis += 60 * MIN_OFFSET_MSEC;
    }

    return compute(spec, afterTimeInMillis);
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:30,代碼來源:ScheduleComputeHelper.java

示例4: testCompress

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
public void testCompress()
{
    EnumMap<ScheduleUnit, SortedSet<Integer>> unitValues = new EnumMap<ScheduleUnit, SortedSet<Integer>>(ScheduleUnit.class);
    unitValues = (new ScheduleSpec()).getUnitValues();

    // Populate Month with all valid values
    SortedSet<Integer> monthValues = new TreeSet<Integer>();
    for (int i = ScheduleUnit.MONTHS.min(); i <= ScheduleUnit.MONTHS.max(); i++)
    {
        monthValues.add(i);
    }
    unitValues.put(ScheduleUnit.MONTHS, monthValues);

    // Construct spec, test that month was replaced with wildcards
    ScheduleSpec spec = new ScheduleSpec(unitValues);
    assertTrue(spec.getUnitValues().get(ScheduleUnit.MONTHS) == null);
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:18,代碼來源:TestScheduleSpec.java

示例5: ScheduleSpec

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
public ScheduleSpec(EnumMap<ScheduleUnit, SortedSet<Integer>> unitValues, String optionalTimeZone, CronParameter optionalDayOfMonthOperator, CronParameter optionalDayOfWeekOperator) throws IllegalArgumentException {
    validate(unitValues);

    // Reduce to wildcards any unit's values set, if possible
    compress(unitValues);

    this.unitValues = unitValues;
    this.optionalTimeZone = optionalTimeZone;
    this.optionalDayOfMonthOperator = optionalDayOfMonthOperator;
    this.optionalDayOfWeekOperator = optionalDayOfWeekOperator;
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:12,代碼來源:ScheduleSpec.java

示例6: addValue

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
/**
 * For unit testing, add a single value, changing wildcards to value sets.
 *
 * @param element to add
 * @param value   to add
 */
public final void addValue(ScheduleUnit element, int value) {
    SortedSet<Integer> set = unitValues.get(element);
    if (set == null) {
        set = new TreeSet<Integer>();
        unitValues.put(element, set);
    }
    set.add(value);
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:15,代碼來源:ScheduleSpec.java

示例7: compress

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
/**
 * Function to reduce value sets for unit that cover the whole range down to a wildcard.
 * I.e. reduce 0,1,2,3,4,5,6 for week value to 'null' indicating the wildcard.
 *
 * @param unitValues is the set of valid values per unit
 */
protected static void compress(Map<ScheduleUnit, SortedSet<Integer>> unitValues) {
    for (Map.Entry<ScheduleUnit, SortedSet<Integer>> entry : unitValues.entrySet()) {
        int elementValueSetSize = entry.getKey().max() - entry.getKey().min() + 1;
        if (entry.getValue() != null) {
            if (entry.getValue().size() == elementValueSetSize) {
                unitValues.put(entry.getKey(), null);
            }
        }
    }
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:17,代碼來源:ScheduleSpec.java

示例8: testValidate

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
public void testValidate() {
    // Test all units missing
    EnumMap<ScheduleUnit, SortedSet<Integer>> unitValues = new EnumMap<ScheduleUnit, SortedSet<Integer>>(ScheduleUnit.class);
    assertInvalid(unitValues);

    // Test one unit missing
    unitValues = (new ScheduleSpec()).getUnitValues();
    unitValues.remove(ScheduleUnit.HOURS);
    assertInvalid(unitValues);

    // Test all units are wildcards
    unitValues = (new ScheduleSpec()).getUnitValues();
    new ScheduleSpec(unitValues, null, null, null);

    // Test invalid value in month
    SortedSet<Integer> values = new TreeSet<Integer>();
    values.add(0);
    unitValues.put(ScheduleUnit.MONTHS, values);
    assertInvalid(unitValues);

    // Test valid value in month
    values = new TreeSet<Integer>();
    values.add(1);
    values.add(5);
    unitValues.put(ScheduleUnit.MONTHS, values);
    new ScheduleSpec(unitValues, null, null, null);
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:28,代碼來源:TestScheduleSpec.java

示例9: testCompress

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
public void testCompress() {
    EnumMap<ScheduleUnit, SortedSet<Integer>> unitValues = new EnumMap<ScheduleUnit, SortedSet<Integer>>(ScheduleUnit.class);
    unitValues = (new ScheduleSpec()).getUnitValues();

    // Populate Month with all valid values
    SortedSet<Integer> monthValues = new TreeSet<Integer>();
    for (int i = ScheduleUnit.MONTHS.min(); i <= ScheduleUnit.MONTHS.max(); i++) {
        monthValues.add(i);
    }
    unitValues.put(ScheduleUnit.MONTHS, monthValues);

    // Construct spec, test that month was replaced with wildcards
    ScheduleSpec spec = new ScheduleSpec(unitValues, null, null, null);
    assertTrue(spec.getUnitValues().get(ScheduleUnit.MONTHS) == null);
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:16,代碼來源:TestScheduleSpec.java

示例10: assertInvalid

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
private void assertInvalid(EnumMap<ScheduleUnit, SortedSet<Integer>> unitValues) {
    try {
        new ScheduleSpec(unitValues, null, null, null);
        assertFalse(true);
    } catch (IllegalArgumentException ex) {
        log.debug(".assertInvalid Expected exception, msg=" + ex.getMessage());
        // Expected exception
    }
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:10,代碼來源:TestScheduleSpec.java

示例11: ScheduleSpec

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
/**
 * Constructor - validates that all mandatory schedule.
 * @param unitValues are the values for each minute, hour, day, month etc.
 * @throws IllegalArgumentException - if validation of value set per unit fails
 */
public ScheduleSpec(EnumMap<ScheduleUnit, SortedSet<Integer>> unitValues) throws IllegalArgumentException
{
    validate(unitValues);

    // Reduce to wildcards any unit's values set, if possible
    compress(unitValues);

    this.unitValues = unitValues;
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:15,代碼來源:ScheduleSpec.java

示例12: addValue

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
/**
 * For unit testing, add a single value, changing wildcards to value sets.
 * @param element to add
 * @param value to add
 */
public final void addValue(ScheduleUnit element, int value)
{
    SortedSet<Integer> set = unitValues.get(element);
    if (set == null)
    {
        set = new TreeSet<Integer>();
        unitValues.put(element, set);
    }
    set.add(value);
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:16,代碼來源:ScheduleSpec.java

示例13: toString

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
@SuppressWarnings({"StringConcatenationInsideStringBufferAppend"})
public final String toString()
{
    StringBuilder buffer = new StringBuilder();
    for (ScheduleUnit element : ScheduleUnit.values())
    {
        if (!unitValues.containsKey(element))
        {
            continue;
        }

        Set<Integer> valueSet = unitValues.get(element);
        buffer.append(element + "={");
        if (valueSet == null)
        {
            buffer.append("null");
        }
        else
        {
            String delimiter = "";
            for (int i : valueSet)
            {
                buffer.append(delimiter + i);
                delimiter = ",";
            }
        }
        buffer.append("} ");
    }
    return buffer.toString();
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:31,代碼來源:ScheduleSpec.java

示例14: compress

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
/**
 * Function to reduce value sets for unit that cover the whole range down to a wildcard.
 * I.e. reduce 0,1,2,3,4,5,6 for week value to 'null' indicating the wildcard.
 * @param unitValues is the set of valid values per unit
 */
protected static void compress(Map<ScheduleUnit, SortedSet<Integer>> unitValues)
{
    for (Map.Entry<ScheduleUnit, SortedSet<Integer>> entry : unitValues.entrySet())
    {
        int elementValueSetSize = entry.getKey().max() - entry.getKey().min() + 1;
        if (entry.getValue() != null)
        {
            if (entry.getValue().size() == elementValueSetSize)
            {
                unitValues.put(entry.getKey(), null);
            }
        }
    }
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:20,代碼來源:ScheduleSpec.java

示例15: setUp

import com.espertech.esper.type.ScheduleUnit; //導入依賴的package包/類
public void setUp()
{
    beginState = new MatchedEventMapImpl(new MatchedEventMapMeta(new String[0], false));

    scheduleService = new SchedulingServiceImpl(new TimeSourceServiceImpl());
    PatternAgentInstanceContext agentContext = SupportPatternContextFactory.makePatternAgentInstanceContext(scheduleService);

    ScheduleSpec scheduleSpec = new ScheduleSpec();
    scheduleSpec.addValue(ScheduleUnit.SECONDS, 1);

    evaluator = new SupportObserverEvaluator(agentContext);

    observer =  new TimerAtObserver(scheduleSpec, beginState, evaluator);
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:15,代碼來源:TestTimerCronObserver.java


注:本文中的com.espertech.esper.type.ScheduleUnit類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。