Package com.espertech.esper.view

Examples of com.espertech.esper.view.ViewParameterException


    }

    private Number toNumber(String name, Object evaluated) throws ViewParameterException
    {
        if (!(evaluated instanceof Number)) {
            throw new ViewParameterException("Parameter " + name + " is not a number");
        }
        return (Number) evaluated;
    }
View Full Code Here


    public void attach(EventType parentEventType, StatementContext context, ViewFactory optionalParentViewFactory, List<ViewFactory> parentViewFactories) throws ViewParameterException
    {
        ExprNode[] validated = ViewFactorySupport.validate("Holt-Winters view", parentEventType, context, Arrays.asList(fieldName), false);

        if (!JavaClassHelper.isNumeric(validated[0].getExprEvaluator().getType())) {
            throw new ViewParameterException("The field expression for the Holt-Winters view must be of a numeric type");
        }
        fieldName = validated[0];
        eventType = HoltWinters.createEventType(context);
    }
View Full Code Here

{
    public void setViewParameters(ViewFactoryContext viewFactoryContext, List<ExprNode> expressionParameters) throws ViewParameterException
    {
        if (expressionParameters.size() != 1) {
            String errorMessage = getViewName() + " view requires a single expression as a parameter";
            throw new ViewParameterException(errorMessage);
        }
        expiryExpression = expressionParameters.get(0);
    }
View Full Code Here

    {
        ExprNode[] validated = ViewFactorySupport.validate("Correlation view", parentEventType, statementContext, viewParameters, false);
        String errorMessage = "Regression view requires two expressions providing x and y values as properties";

        if (validated.length < 2) {
            throw new ViewParameterException(errorMessage);
        }
        if ((!JavaClassHelper.isNumeric(validated[0].getExprEvaluator().getType())) || (!JavaClassHelper.isNumeric(validated[1].getExprEvaluator().getType())))
        {
            throw new ViewParameterException(errorMessage);
        }

        expressionX = validated[0];
        expressionY = validated[1];
View Full Code Here

    public void attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, List<ViewFactory> parentViewFactories) throws ViewParameterException
    {
        ExprNode[] validated = ViewFactorySupport.validate("Univariate statistics", parentEventType, statementContext, viewParameters, false);
        String errorMessage = "Univariate statistics view require a single expression returning a numeric value as a parameter";
        if (validated.length < 1) {
            throw new ViewParameterException(errorMessage);
        }
        if (!JavaClassHelper.isNumeric(validated[0].getExprEvaluator().getType()))
        {
            throw new ViewParameterException(errorMessage);
        }
        fieldExpression = validated[0];

        additionalProps = StatViewAdditionalProps.make(validated, 1);
        eventType = UnivariateStatisticsView.createEventType(statementContext, additionalProps);
View Full Code Here

    public void attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, List<ViewFactory> parentViewFactories) throws ViewParameterException
    {
        ExprNode[] validated = ViewFactorySupport.validate("Correlation view", parentEventType, statementContext, viewParameters, false);
        String errorMessage = "Correlation view requires two expressions providing x and y values as properties";
        if (validated.length < 2) {
            throw new ViewParameterException(errorMessage);
        }
        if ((!JavaClassHelper.isNumeric(validated[0].getExprEvaluator().getType())) || (!JavaClassHelper.isNumeric(validated[1].getExprEvaluator().getType())))
        {
            throw new ViewParameterException(errorMessage);
        }

        expressionX = validated[0];
        expressionY = validated[1];
View Full Code Here

    {
        ExprNode[] validated = ViewFactorySupport.validate("Correlation view", parentEventType, statementContext, viewParameters, true);
        String errorMessage = "Regression view requires two expressions providing x and y values as properties";

        if (validated.length < 2) {
            throw new ViewParameterException(errorMessage);
        }
        if ((!JavaClassHelper.isNumeric(validated[0].getExprEvaluator().getType())) || (!JavaClassHelper.isNumeric(validated[1].getExprEvaluator().getType())))
        {
            throw new ViewParameterException(errorMessage);
        }

        expressionX = validated[0];
        expressionY = validated[1];
View Full Code Here

     * @throws ViewParameterException if validation failed
     */
  protected void processExpiry(Object parameter, String errorMessage, String errorMessage2) throws ViewParameterException {
        if (!(parameter instanceof Number))
        {
            throw new ViewParameterException(errorMessage);
        }
        else
        {
            Number param = (Number) parameter;
            if (JavaClassHelper.isFloatingPointNumber(param))
            {
              millisecondsBeforeExpiry = Math.round(1000d * param.doubleValue());
            }
            else
            {
                millisecondsBeforeExpiry = 1000 * param.longValue();
            }
        }

        if (millisecondsBeforeExpiry < 1)
        {
            throw new ViewParameterException(errorMessage2);
        }
  }
View Full Code Here

   */
  protected void processKeywords(Object keywords, String errorMessage) throws ViewParameterException {

    if (!(keywords instanceof String))
    {
        throw new ViewParameterException(errorMessage);
    }

    String[] keyword = ((String) keywords).split(",");
    for (int i = 0; i < keyword.length; i++)
    {
        String keywordText = keyword[i].toLowerCase().trim();
        if (keywordText.length() == 0)
        {
            continue;
        }
        if (keywordText.equals(FORCE_UPDATE_KEYWORD))
        {
            isForceUpdate = true;
        }
        else if (keywordText.equals(START_EAGER_KEYWORD))
        {
            isForceUpdate = true;
            isStartEager = true;
        }
        else
        {
            String keywordRange = FORCE_UPDATE_KEYWORD + "," + START_EAGER_KEYWORD;
            throw new ViewParameterException("Time-length-combination view encountered an invalid keyword '" + keywordText + "', valid control keywords are: " + keywordRange);
        }
    }
  }
View Full Code Here

{
    public void setViewParameters(ViewFactoryContext viewFactoryContext, List<ExprNode> expressionParameters) throws ViewParameterException
    {
        if (expressionParameters.size() != 1) {
            String errorMessage = "Expression window view requires a single expression as a parameter";
            throw new ViewParameterException(errorMessage);
        }
        expiryExpression = expressionParameters.get(0);
    }
View Full Code Here

TOP

Related Classes of com.espertech.esper.view.ViewParameterException

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.