Search in sources :

Example 1 with LoopVariableType

use of org.dbflute.twowaysql.node.ForNode.LoopVariableType in project dbflute-core by dbflute.

the class LoopAbstractNode method accept.

// ===================================================================================
// Accept
// ======
public void accept(CommandContext ctx) {
    final LoopVariableType type = getLoopVariableType();
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The " + type.name() + " comment was out of FOR comment!");
    br.addItem("Advice");
    br.addElement("A " + type.name() + " comment should be in FOR comment scope.");
    br.addElement("For example:");
    br.addElement(" (x):");
    br.addElement("   /*" + type.name() + "*/.../*END*/");
    br.addElement("   /*FOR*/.../*END*/");
    br.addElement(" (o):");
    br.addElement("   /*FOR*/");
    br.addElement("   /*" + type.name() + "*/.../*END*/");
    br.addElement("   /*END*/");
    br.addItem(type.name() + " Comment Expression");
    br.addElement(_expression);
    br.addItem("Specified SQL");
    br.addElement(_specifiedSql);
    final String msg = br.buildExceptionMessage();
    throw new LoopVariableCommentOutOfForCommentException(msg);
}
Also used : LoopVariableCommentOutOfForCommentException(org.dbflute.twowaysql.exception.LoopVariableCommentOutOfForCommentException) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) LoopVariableType(org.dbflute.twowaysql.node.ForNode.LoopVariableType)

Example 2 with LoopVariableType

use of org.dbflute.twowaysql.node.ForNode.LoopVariableType in project dbflute-core by dbflute.

the class SqlAnalyzer method parseLoopVariable.

protected void parseLoopVariable() {
    // should be in FOR comment scope
    final String comment = _tokenizer.getToken();
    final String code = Srl.substringFirstFront(comment, " ");
    if (Srl.is_Null_or_TrimmedEmpty(code)) {
        // no way
        String msg = "Unknown loop variable comment: " + comment;
        throw new IllegalStateException(msg);
    }
    final LoopVariableType type = LoopVariableType.codeOf(code);
    if (type == null) {
        // no way
        String msg = "Unknown loop variable comment: " + comment;
        throw new IllegalStateException(msg);
    }
    final String condition = comment.substring(type.name().length()).trim();
    final LoopAbstractNode loopFirstNode = createLoopFirstNode(condition, type);
    peek().addChild(loopFirstNode);
    if (Srl.count(condition, "'") < 2) {
        push(loopFirstNode);
        parseEnd();
    }
}
Also used : LoopAbstractNode(org.dbflute.twowaysql.node.LoopAbstractNode) LoopVariableType(org.dbflute.twowaysql.node.ForNode.LoopVariableType)

Aggregations

LoopVariableType (org.dbflute.twowaysql.node.ForNode.LoopVariableType)2 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1 LoopVariableCommentOutOfForCommentException (org.dbflute.twowaysql.exception.LoopVariableCommentOutOfForCommentException)1 LoopAbstractNode (org.dbflute.twowaysql.node.LoopAbstractNode)1