net.sf.aguacate.context.spi.sql.impl.AbstractSentenceSql Maven / Gradle / Ivy
package net.sf.aguacate.context.spi.sql.impl;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import net.sf.aguacate.function.Function;
import net.sf.aguacate.function.FunctionContext;
import net.sf.aguacate.function.FunctionEvalResult;
public abstract class AbstractSentenceSql implements Function {
public static final String SQL_SELECT_LIST = "SQL_SELECT_LIST";
public static final String SQL_SELECT_MULTIPLE_ROW = "SQL_SELECT_MULTIPLE_ROW";
public static final String INSERT = "INSERT";
public static final String INSERT_RECOVER_ID = "INSERT_RECOVER_ID";
public static final String UPDATE = "UPDATE";
public static final String SELECT_SINGLE_ROW = "SELECT_SINGLE_ROW";
public static final String SELECT_SINGLE = "SELECT_SINGLE";
public static final String SELECT_MULTIPLE_ROW = "SELECT_MULTIPLE_ROW";
public static final String ARRAY_ITERATOR = "ARRAY_ITERATOR";
public static final String SELECT = "SELECT";
public static final String UPDATE_STATIC = "UPDATE_STATIC";
public static final String SELECT_STATIC = "SELECT_STATIC";
public static final String BEGIN_TRANSACTION = "BEGIN_TRANSACTION";
public static final String END_TRANSACTION = "END_TRANSACTION";
public static final String DELETE = "DELETE";
public static final String RESPONSE = "RESPONSE";
static final FunctionEvalResult SUCCESS = new FunctionEvalResult(true);
static final FunctionEvalResult FAILURE = new FunctionEvalResult(false);
private final String name;
private final String message;
private final List methods;
public AbstractSentenceSql(String name, String message, List methods) {
this.name = name;
this.message = message;
this.methods = methods;
}
@Override
public FunctionEvalResult evaluate(FunctionContext functionContext, Map context) {
try {
return evaluate0(functionContext, context);
} catch (SQLException e) {
throw new IllegalStateException(e);
}
}
protected abstract FunctionEvalResult evaluate0(FunctionContext functionContext, Map context)
throws SQLException;
@Override
public String getName() {
return name;
}
public String getMessage() {
return message;
}
@Override
public boolean validFor(String method) {
return methods.contains(method);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy