本文整理汇总了Java中com.espertech.esper.type.ScheduleUnit类的典型用法代码示例。如果您正苦于以下问题:Java ScheduleUnit类的具体用法?Java ScheduleUnit怎么用?Java ScheduleUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScheduleUnit类属于com.espertech.esper.type包,在下文中一共展示了ScheduleUnit类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: 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);
// 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);
}
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:29,代码来源:TestScheduleSpec.java
示例17: assertInvalid
import com.espertech.esper.type.ScheduleUnit; //导入依赖的package包/类
private void assertInvalid(EnumMap<ScheduleUnit, SortedSet<Integer>> unitValues)
{
try
{
new ScheduleSpec(unitValues);
assertFalse(true);
}
catch (IllegalArgumentException ex)
{
log.debug(".assertInvalid Expected exception, msg=" + ex.getMessage());
// Expected exception
}
}
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:14,代码来源:TestScheduleSpec.java
示例18: equals
import com.espertech.esper.type.ScheduleUnit; //导入依赖的package包/类
public final boolean equals(Object otherObject) {
if (otherObject == this) {
return true;
}
if (otherObject == null) {
return false;
}
if (getClass() != otherObject.getClass()) {
return false;
}
ScheduleSpec other = (ScheduleSpec) otherObject;
if (this.unitValues.size() != other.unitValues.size()) {
return false;
}
for (Map.Entry<ScheduleUnit, SortedSet<Integer>> entry : unitValues.entrySet()) {
Set<Integer> mySet = entry.getValue();
Set<Integer> otherSet = other.unitValues.get(entry.getKey());
if ((otherSet == null) && (mySet != null)) {
return false;
}
if ((otherSet != null) && (mySet == null)) {
return false;
}
if ((otherSet == null) && (mySet == null)) {
continue;
}
if (mySet.size() != otherSet.size()) {
return false;
}
// Commpare value by value
for (int i : mySet) {
if (!(otherSet.contains(i))) {
return false;
}
}
}
return true;
}
开发者ID:espertechinc,项目名称:esper,代码行数:46,代码来源:ScheduleSpec.java
示例19: testWaitAndSpecTogether
import com.espertech.esper.type.ScheduleUnit; //导入依赖的package包/类
public void testWaitAndSpecTogether() {
Calendar calendar = Calendar.getInstance();
calendar.set(2004, 11, 9, 15, 27, 10);
calendar.set(Calendar.MILLISECOND, 500);
long startTime = calendar.getTimeInMillis();
service.setTime(startTime);
// Add a specification
ScheduleSpec spec = new ScheduleSpec();
spec.addValue(ScheduleUnit.MONTHS, 12);
spec.addValue(ScheduleUnit.DAYS_OF_MONTH, 9);
spec.addValue(ScheduleUnit.HOURS, 15);
spec.addValue(ScheduleUnit.MINUTES, 27);
spec.addValue(ScheduleUnit.SECONDS, 20);
service.add(ScheduleComputeHelper.computeDeltaNextOccurance(spec, service.getTime(), TimeZone.getDefault(), TimeAbacusMilliseconds.INSTANCE), callbacks[3], slots[1][1]);
spec.addValue(ScheduleUnit.SECONDS, 15);
service.add(ScheduleComputeHelper.computeDeltaNextOccurance(spec, service.getTime(), TimeZone.getDefault(), TimeAbacusMilliseconds.INSTANCE), callbacks[4], slots[2][0]);
// Add some more callbacks
service.add(5000, callbacks[0], slots[0][0]);
service.add(10000, callbacks[1], slots[0][1]);
service.add(15000, callbacks[2], slots[1][0]);
// Now send a times reflecting various seconds later and check who got a callback
service.setTime(startTime + 1000);
SupportScheduleCallback.setCallbackOrderNum(0);
evaluateSchedule();
checkCallbacks(callbacks, new Integer[]{0, 0, 0, 0, 0});
service.setTime(startTime + 2000);
evaluateSchedule();
checkCallbacks(callbacks, new Integer[]{0, 0, 0, 0, 0});
service.setTime(startTime + 4000);
evaluateSchedule();
checkCallbacks(callbacks, new Integer[]{0, 0, 0, 0, 0});
service.setTime(startTime + 5000);
evaluateSchedule();
checkCallbacks(callbacks, new Integer[]{1, 0, 0, 0, 2});
service.setTime(startTime + 9000);
evaluateSchedule();
checkCallbacks(callbacks, new Integer[]{0, 0, 0, 0, 0});
service.setTime(startTime + 10000);
evaluateSchedule();
checkCallbacks(callbacks, new Integer[]{0, 3, 0, 4, 0});
service.setTime(startTime + 11000);
evaluateSchedule();
checkCallbacks(callbacks, new Integer[]{0, 0, 0, 0, 0});
service.setTime(startTime + 15000);
evaluateSchedule();
checkCallbacks(callbacks, new Integer[]{0, 0, 5, 0, 0});
service.setTime(startTime + Integer.MAX_VALUE);
evaluateSchedule();
checkCallbacks(callbacks, new Integer[]{0, 0, 0, 0, 0});
}
开发者ID:espertechinc,项目名称:esper,代码行数:65,代码来源:TestSchedulingServiceImpl.java
示例20: computeValues
import com.espertech.esper.type.ScheduleUnit; //导入依赖的package包/类
/**
* Compute from parameters a crontab schedule.
* @param args parameters
* @return crontab schedule
* @throws ScheduleParameterException if the parameters are invalid
*/
public static ScheduleSpec computeValues(Object[] args) throws ScheduleParameterException
{
EnumMap<ScheduleUnit, SortedSet<Integer>> unitMap = new EnumMap<ScheduleUnit, SortedSet<Integer>>(ScheduleUnit.class);
Object minutes = args[0];
Object hours = args[1];
Object daysOfMonth = args[2];
Object months = args[3];
Object daysOfWeek = args[4];
unitMap.put(ScheduleUnit.MINUTES, computeValues(minutes, ScheduleUnit.MINUTES));
unitMap.put(ScheduleUnit.HOURS, computeValues(hours, ScheduleUnit.HOURS));
SortedSet<Integer> resultMonths = computeValues(months, ScheduleUnit.MONTHS);
if (daysOfWeek instanceof CronParameter && daysOfMonth instanceof CronParameter)
{
throw new ScheduleParameterException("Invalid combination between days of week and days of month fields for timer:at");
}
if (resultMonths != null && resultMonths.size() == 1 && (resultMonths.first() instanceof Integer))
{
// If other arguments are cronParameters, use it for later computations
CronParameter parameter = null;
if (daysOfMonth instanceof CronParameter)
{
parameter = ((CronParameter) daysOfMonth);
}
else if (daysOfWeek instanceof CronParameter)
{
parameter = ((CronParameter) daysOfWeek);
}
if (parameter != null)
{
parameter.setMonth(resultMonths.first());
}
}
SortedSet<Integer> resultDaysOfWeek = computeValues(daysOfWeek, ScheduleUnit.DAYS_OF_WEEK);
SortedSet<Integer> resultDaysOfMonth = computeValues(daysOfMonth, ScheduleUnit.DAYS_OF_MONTH);
if (resultDaysOfWeek != null && resultDaysOfWeek.size() == 1 && (resultDaysOfWeek.first() instanceof Integer))
{
// The result is in the form "last xx of the month
// Days of week is replaced by a wildcard and days of month is updated with
// the computation of "last xx day of month".
// In this case "days of month" parameter has to be a wildcard.
if (resultDaysOfWeek.first() > 6)
{
if (resultDaysOfMonth != null)
{
throw new ScheduleParameterException("Invalid combination between days of week and days of month fields for timer:at");
}
resultDaysOfMonth = resultDaysOfWeek;
resultDaysOfWeek = null;
}
}
if (resultDaysOfMonth != null && resultDaysOfMonth.size() == 1 && (resultDaysOfMonth.first() instanceof Integer))
{
if (resultDaysOfWeek != null)
{
throw new ScheduleParameterException("Invalid combination between days of week and days of month fields for timer:at");
}
}
unitMap.put(ScheduleUnit.DAYS_OF_WEEK, resultDaysOfWeek);
unitMap.put(ScheduleUnit.DAYS_OF_MONTH, resultDaysOfMonth);
unitMap.put(ScheduleUnit.MONTHS, resultMonths);
if (args.length > 5)
{
unitMap.put(ScheduleUnit.SECONDS, computeValues(args[5], ScheduleUnit.SECONDS));
}
return new ScheduleSpec(unitMap);
}
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:73,代码来源:ScheduleSpecUtil.java
注:本文中的com.espertech.esper.type.ScheduleUnit类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论