All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebeaninternal.server.grammer.EqlWhereAdapter Maven / Gradle / Ivy

There is a newer version: 15.8.1
Show newest version
package io.ebeaninternal.server.grammer;

import io.ebean.ExpressionFactory;
import io.ebean.ExpressionList;
import io.ebeaninternal.server.util.ArrayStack;

class EqlWhereAdapter extends EqlWhereListener {

  private final ExpressionList where;
  private final ExpressionFactory expr;
  private final Object[] params;

  private int paramIndex;

  EqlWhereAdapter(ExpressionList where, ExpressionFactory expr, Object[] params) {
    this.where = where;
    this.expr = expr;
    this.params = params;
  }

  @Override
  ExpressionList peekExprList() {
    if (whereStack == null) {
      whereStack = new ArrayStack<>();
      whereStack.push(where);
    }
    return whereStack.peek();
  }

  @Override
  ExpressionFactory expressionFactory() {
    return expr;
  }

  @Override
  Object positionParam(String paramPosition) {
    if ("?".equals(paramPosition)) {
      return params[paramIndex++];
    }
    final int pos = Integer.parseInt(paramPosition.substring(1));
    return params[pos -1];
  }

  @Override
  Object namedParam(String substring) {
    throw new RuntimeException("Not supported");
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy