Search in sources :

Example 1 with ElseifNode

use of org.seasar.doma.internal.jdbc.sql.node.ElseifNode in project doma by domaframework.

the class NodePreparedSqlBuilder method handleElseifNode.

protected boolean handleElseifNode(IfBlockNode node, Context p) {
    for (ElseifNode elseifNode : node.getElseifNodes()) {
        SqlLocation location = elseifNode.getLocation();
        String expression = elseifNode.getExpression();
        EvaluationResult elseifResult = p.evaluate(location, expression);
        if (elseifResult.getBooleanValue()) {
            elseifNode.accept(this, p);
            return true;
        }
    }
    return false;
}
Also used : SqlLocation(org.seasar.doma.internal.jdbc.sql.node.SqlLocation) ElseifNode(org.seasar.doma.internal.jdbc.sql.node.ElseifNode) EvaluationResult(org.seasar.doma.internal.expr.EvaluationResult)

Example 2 with ElseifNode

use of org.seasar.doma.internal.jdbc.sql.node.ElseifNode in project doma by domaframework.

the class SqlParser method parseElseifBlockComment.

protected void parseElseifBlockComment() {
    if (!isInIfBlockNode()) {
        throw new JdbcException(Message.DOMA2138, sql, tokenizer.getLineNumber(), tokenizer.getPosition());
    }
    removeNodesTo(IfBlockNode.class);
    IfBlockNode ifBlockNode = peek();
    if (ifBlockNode.isElseNodeExistent()) {
        throw new JdbcException(Message.DOMA2139, sql, tokenizer.getLineNumber(), tokenizer.getPosition());
    }
    String expression = tokenType.extract(token);
    ElseifNode node = new ElseifNode(getLocation(), expression, token);
    ifBlockNode.addElseifNode(node);
    push(node);
}
Also used : IfBlockNode(org.seasar.doma.internal.jdbc.sql.node.IfBlockNode) JdbcException(org.seasar.doma.jdbc.JdbcException) ElseifNode(org.seasar.doma.internal.jdbc.sql.node.ElseifNode)

Aggregations

ElseifNode (org.seasar.doma.internal.jdbc.sql.node.ElseifNode)2 EvaluationResult (org.seasar.doma.internal.expr.EvaluationResult)1 IfBlockNode (org.seasar.doma.internal.jdbc.sql.node.IfBlockNode)1 SqlLocation (org.seasar.doma.internal.jdbc.sql.node.SqlLocation)1 JdbcException (org.seasar.doma.jdbc.JdbcException)1