当前位置: 首页>>代码示例>>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;未经允许,请勿转载。