net.sf.aguacate.function.spi.impl.FunctionSqlSelectCount Maven / Gradle / Ivy
package net.sf.aguacate.function.spi.impl;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import net.sf.aguacate.function.FunctionContext;
import net.sf.aguacate.function.FunctionEvalResult;
import net.sf.aguacate.function.Parameter;
import net.sf.aguacate.function.spi.AbstractFunctionSql;
public class FunctionSqlSelectCount extends AbstractFunctionSql {
private final String[] outputContext;
private final String outputName;
public FunctionSqlSelectCount(Collection methods, String name, String message, List parameters,
List outputContext, String outputName, String table) {
super(methods, name, message,
MessageFormat.format("SELECT count(*) FROM {0} WHERE {1} = ?", table, parameters.get(0).getName()),
new String[] { parameters.get(0).getName() }, new String[] { outputName });
this.outputContext = outputContext.toArray(new String[outputContext.size()]);
this.outputName = outputName;
}
@Override
public FunctionEvalResult evaluate(FunctionContext functionContext, Map context) {
return new FunctionEvalResult(null, selectSingle(functionContext, context));
}
@Override
public String getOutputName() {
return outputName;
}
@Override
public String[] getOutputContext() {
return outputContext;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy