本文整理汇总了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);
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
示例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
}
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
}
}
}
示例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);
}