use of org.dbflute.twowaysql.context.CommandContextCreator in project dbflute-core by dbflute.
the class SqlAnalyzerTest method prepareCtx.
protected CommandContext prepareCtx(SimpleMapPmb<Object> pmb, Node node) {
CommandContextCreator creator = new CommandContextCreator(new String[] { "pmb" }, new Class<?>[] { pmb.getClass() });
CommandContext ctx = creator.createCommandContext(new Object[] { pmb });
node.accept(ctx);
return ctx;
}
use of org.dbflute.twowaysql.context.CommandContextCreator in project dbflute-core by dbflute.
the class SqlAnalyzer method convertTwoWaySql2DisplaySql.
public static String convertTwoWaySql2DisplaySql(SqlAnalyzerFactory factory, String twoWaySql, String[] argNames, Class<?>[] argTypes, Object[] args, BoundDateDisplayStyle dateDisplayStyle) {
final CommandContext context;
{
final SqlAnalyzer parser = createSqlAnalyzer4DisplaySql(factory, twoWaySql);
final Node node = parser.analyze();
final CommandContextCreator creator = new CommandContextCreator(argNames, argTypes);
context = creator.createCommandContext(args);
node.accept(context);
}
final String preparedSql = context.getSql();
final DisplaySqlBuilder builder = new DisplaySqlBuilder(dateDisplayStyle);
return builder.buildDisplaySql(preparedSql, context.getBindVariables());
}
use of org.dbflute.twowaysql.context.CommandContextCreator in project lastaflute by lastaflute.
the class SimpleTemplateManager method prepareContext.
// ===================================================================================
// Prepare Context
// ===============
protected CommandContext prepareContext(Object pmb) {
final Object filteredPmb = filterPmb(pmb);
final String[] argNames = new String[] { "pmb" };
final Class<?>[] argTypes = new Class<?>[] { filteredPmb.getClass() };
final CommandContextCreator creator = newCommandContextCreator(argNames, argTypes);
return creator.createCommandContext(new Object[] { filteredPmb });
}
use of org.dbflute.twowaysql.context.CommandContextCreator in project dbflute-core by dbflute.
the class EmbeddedVariableNode method processDynamicBinding.
protected boolean processDynamicBinding(CommandContext ctx, Object firstValue, Class<?> firstType, String embeddedString) {
final ScopeInfo first = Srl.extractScopeFirst(embeddedString, "/*", "*/");
if (first == null) {
return false;
}
// unsupported general purpose options in dynamic for now, e.g. MailFlute, may be almost unneeded
final SqlAnalyzer analyzer = new SqlAnalyzer(embeddedString, _blockNullParameter);
final Node rootNode = analyzer.analyze();
final CommandContextCreator creator = new CommandContextCreator(new String[] { "pmb" }, new Class<?>[] { firstType });
final CommandContext rootCtx = creator.createCommandContext(new Object[] { firstValue });
rootNode.accept(rootCtx);
final String sql = rootCtx.getSql();
ctx.addSql(sql, rootCtx.getBindVariables(), rootCtx.getBindVariableTypes());
return true;
}
Aggregations