Package com.espertech.esper.type

Examples of com.espertech.esper.type.CronParameter


        {
            throw new EPException("Expression node has not been validated");
        }
        if (this.getChildNodes().length == 0)
        {
            return new CronParameter(cronOperator, null, timeProvider.getTime());
        }
        Object value = evaluator.evaluate(eventsPerStream, isNewData, exprEvaluatorContext);
        if (value == null)
        {
            log.warn("Null value returned for cron parameter");
            return new CronParameter(cronOperator, null, timeProvider.getTime());
        }
        else
        {
            int intValue = ((Number) value).intValue();
            return new CronParameter(cronOperator, intValue, timeProvider.getTime());
        }
    }
View Full Code Here


            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))
View Full Code Here

        {
            throw new EPException("Expression node has not been validated");
        }
        if (this.getChildNodes().isEmpty())
        {
            return new CronParameter(cronOperator, null, timeProvider.getTime());
        }
        Object value = evaluator.evaluate(eventsPerStream, isNewData, exprEvaluatorContext);
        if (value == null)
        {
            log.warn("Null value returned for cron parameter");
            return new CronParameter(cronOperator, null, timeProvider.getTime());
        }
        else
        {
            int intValue = ((Number) value).intValue();
            return new CronParameter(cronOperator, intValue, timeProvider.getTime());
        }
    }
View Full Code Here

            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))
View Full Code Here

        int dayOfMonth;

        // If days of week is a wildcard, just go by days of month
        if (spec.getOptionalDayOfMonthOperator() != null || spec.getOptionalDayOfWeekOperator() != null) {
            boolean isWeek = false;
            CronParameter op = spec.getOptionalDayOfMonthOperator();
            if (spec.getOptionalDayOfMonthOperator() == null) {
                op = spec.getOptionalDayOfWeekOperator();
                isWeek = true;
            }

            // may return the current day or a future day in the same month,
            // and may advance the "after" date to the next month
            int currentYYMMDD = getTimeYYYYMMDD(after);
            increaseAfterDayOfMonthSpecialOp(op.getOperator(), op.getDay(), op.getMonth(), isWeek, after);
            int rolledYYMMDD = getTimeYYYYMMDD(after);

            // if rolled then reset time portion
            if (rolledYYMMDD > currentYYMMDD) {
                result.setSecond(nextValue(secondsSet, 0));
                result.setMinute(nextValue(minutesSet, 0));
                result.setHour(nextValue(hoursSet, 0));
                return after.get(Calendar.DAY_OF_MONTH);
            }
            // rolling backwards is not allowed
            else if (rolledYYMMDD < currentYYMMDD) {
                throw new IllegalStateException("Failed to evaluate special date op, rolled date less then current date");
            }
            else {
                Calendar work = (Calendar) after.clone();
                work.set(Calendar.SECOND, result.getSecond());
                work.set(Calendar.MINUTE, result.getMinute());
                work.set(Calendar.HOUR_OF_DAY, result.getHour());
                if (!work.after(after)) {    // new date is not after current date, so bump
                    after.add(Calendar.DAY_OF_MONTH, 1);
                    result.setSecond(nextValue(secondsSet, 0));
                    result.setMinute(nextValue(minutesSet, 0));
                    result.setHour(nextValue(hoursSet, 0));
                    increaseAfterDayOfMonthSpecialOp(op.getOperator(), op.getDay(), op.getMonth(), isWeek, after);
                }
                return after.get(Calendar.DAY_OF_MONTH);
            }
        }
        else if (daysOfWeekSet == null)
View Full Code Here

            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));
        }
        String timezone = null;
        if (args.length > 6) {
            if (!(args[6] instanceof WildcardParameter)) {
                if (!(args[6] instanceof String)) {
                    throw new ScheduleParameterException("Invalid timezone parameter '" + args[6] + "' for timer:at, expected a string-type value");
                }
                timezone = (String) args[6];
            }
        }
        CronParameter optionalDayOfMonthOp = getOptionalSpecialOp(daysOfMonth);
        CronParameter optionalDayOfWeekOp = getOptionalSpecialOp(daysOfWeek);
        return new ScheduleSpec(unitMap, timezone, optionalDayOfMonthOp, optionalDayOfWeekOp);
    }
View Full Code Here

            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))
View Full Code Here

        {
            throw new EPException("Expression node has not been validated");
        }
        if (this.getChildNodes().isEmpty())
        {
            return new CronParameter(cronOperator, null, timeProvider.getTime());
        }
        Object value = evaluator.evaluate(eventsPerStream, isNewData, exprEvaluatorContext);
        if (value == null)
        {
            log.warn("Null value returned for cron parameter");
            return new CronParameter(cronOperator, null, timeProvider.getTime());
        }
        else
        {
            int intValue = ((Number) value).intValue();
            return new CronParameter(cronOperator, intValue, timeProvider.getTime());
        }
    }
View Full Code Here

    public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext)
    {
        if (this.getChildNodes().length == 0)
        {
            return new CronParameter(cronOperator, null);
        }
        Object value = evaluator.evaluate(eventsPerStream, isNewData, exprEvaluatorContext);
        if (value == null)
        {
            log.warn("Null value returned for cron parameter");
            return new CronParameter(cronOperator, null);
        }
        else
        {
            int intValue = ((Number) value).intValue();
            return new CronParameter(cronOperator, intValue);
        }
    }
View Full Code Here

            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));
        }
        String timezone = null;
        if (args.length > 6) {
            if (!(args[6] instanceof WildcardParameter)) {
                if (!(args[6] instanceof String)) {
                    throw new ScheduleParameterException("Invalid timezone parameter '" + args[6] + "' for timer:at, expected a string-type value");
                }
                timezone = (String) args[6];
            }
        }
        CronParameter optionalDayOfMonthOp = getOptionalSpecialOp(daysOfMonth);
        CronParameter optionalDayOfWeekOp = getOptionalSpecialOp(daysOfWeek);
        return new ScheduleSpec(unitMap, timezone, optionalDayOfMonthOp, optionalDayOfWeekOp);
    }
View Full Code Here

TOP

Related Classes of com.espertech.esper.type.CronParameter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.