public void setViewParameters(
      ViewFactoryContext viewFactoryContext, List<ExprNode> expressionParameters)
      throws ViewParameterException {
    List<Object> viewParameters =
        ViewFactorySupport.validateAndEvaluate(
            "Time batch view", viewFactoryContext.getStatementContext(), expressionParameters);
    String errorMessage =
        "Time batch view requires a single numeric or time period parameter, and an optional long-typed reference point in msec, and an optional list of control keywords as a string parameter (please see the documentation)";
    if ((viewParameters.size() < 1) || (viewParameters.size() > 3)) {
      throw new ViewParameterException(errorMessage);
    }

    processExpiry(
        viewParameters.get(0), errorMessage, "Time batch view requires a size of at least 1 msec");

    if ((viewParameters.size() == 2) && (viewParameters.get(1) instanceof String)) {
      processKeywords(viewParameters.get(1), errorMessage);
    } else {
      if (viewParameters.size() >= 2) {
        Object paramRef = viewParameters.get(1);
        if ((!(paramRef instanceof Number))
            || (JavaClassHelper.isFloatingPointNumber((Number) paramRef))) {
          throw new ViewParameterException(
              "Time batch view requires a Long-typed reference point in msec as a second parameter");
        }
        optionalReferencePoint = ((Number) paramRef).longValue();
      }

      if (viewParameters.size() == 3) {
        processKeywords(viewParameters.get(2), errorMessage);
      }
    }
  }
  public void attach(
      EventType parentEventType,
      StatementContext statementContext,
      ViewFactory optionalParentFactory,
      List<ViewFactory> parentViewFactories)
      throws ViewParameterException {

    ExprNode[] validatedNodes =
        ViewFactorySupport.validate(
            "ExactStatView", parentEventType, statementContext, viewParameters, false);

    timestampExpression = validatedNodes[0];
    valueExpression = validatedNodes[1];

    if ((timestampExpression.getType() != long.class)
        && (timestampExpression.getType() != Long.class)) {
      throw new ViewParameterException("View requires long-typed timestamp values in parameter 1");
    }
    if ((valueExpression.getType() != double.class)
        && (valueExpression.getType() != Double.class)
        && (valueExpression.getType() != long.class)
        && (valueExpression.getType() != Long.class)) {
      throw new ViewParameterException(
          "View requires long-typed or double-typed values for in parameter 2");
    }
  }
Beispiel #3
0
 public void attach(
     EventType parentEventType,
     StatementContext statementContext,
     ViewFactory optionalParentFactory,
     List<ViewFactory> parentViewFactories)
     throws ViewParameterException {
   ExprNode[] validated =
       ViewFactorySupport.validate(
           getViewName(), parentEventType, statementContext, viewParameters, true);
   additionalProps = StatViewAdditionalProps.make(validated, 0, parentEventType);
   eventType = SizeView.createEventType(statementContext, additionalProps, streamNumber);
 }
  public void attach(
      EventType parentEventType,
      StatementContext statementContext,
      ViewFactory optionalParentFactory,
      List<ViewFactory> parentViewFactories)
      throws ViewParameterException {
    eventType = parentEventType;
    String message =
        NAME + " requires a numeric size parameter and a list of expressions providing sort keys";
    if (viewParameters.size() < 2) {
      throw new ViewParameterException(message);
    }

    ExprNode[] validated =
        ViewFactorySupport.validate(NAME, parentEventType, statementContext, viewParameters, true);
    for (int i = 1; i < validated.length; i++) {
      ViewFactorySupport.assertReturnsNonConstant(NAME, validated[i], i);
    }

    ExprEvaluatorContextStatement exprEvaluatorContext =
        new ExprEvaluatorContextStatement(statementContext);
    Object sortSize =
        ViewFactorySupport.evaluateAssertNoProperties(NAME, validated[0], 0, exprEvaluatorContext);
    if ((sortSize == null) || (!(sortSize instanceof Number))) {
      throw new ViewParameterException(message);
    }
    sortWindowSize = ((Number) sortSize).intValue();

    sortCriteriaExpressions = new ExprNode[validated.length - 1];
    isDescendingValues = new boolean[sortCriteriaExpressions.length];

    for (int i = 1; i < validated.length; i++) {
      if (validated[i] instanceof ExprOrderedExpr) {
        isDescendingValues[i - 1] = ((ExprOrderedExpr) validated[i]).isDescending();
        sortCriteriaExpressions[i - 1] = validated[i].getChildNodes().get(0);
      } else {
        sortCriteriaExpressions[i - 1] = validated[i];
      }
    }
  }
 public void attach(
     EventType parentEventType,
     StatementContext statementContext,
     ViewFactory optionalParentFactory,
     List<ViewFactory> parentViewFactories)
     throws ViewParameterException {
   ExprNode[] validated =
       ViewFactorySupport.validate(
           "Trend spotter view", parentEventType, statementContext, viewParameters, false);
   String message = "Trend spotter view accepts a single integer or double value";
   if (validated.length != 1) {
     throw new ViewParameterException(message);
   }
   Class resultType = validated[0].getExprEvaluator().getType();
   if ((resultType != Integer.class)
       && (resultType != int.class)
       && (resultType != Double.class)
       && (resultType != double.class)) {
     throw new ViewParameterException(message);
   }
   expression = validated[0];
   eventType = MyTrendSpotterView.createEventType(statementContext);
 }