use of org.seasar.doma.jdbc.JdbcException in project doma by domaframework.
the class SqlParser method parseEndBlockComment.
protected void parseEndBlockComment() {
if (!isInBlockNode()) {
throw new JdbcException(Message.DOMA2104, sql, tokenizer.getLineNumber(), tokenizer.getPosition());
}
removeNodesTo(BlockNode.class);
BlockNode blockNode = pop();
EndNode node = new EndNode(token);
blockNode.setEndNode(node);
push(node);
}
use of org.seasar.doma.jdbc.JdbcException in project doma by domaframework.
the class SqlParser method appendNode.
protected void appendNode(SqlNode node) {
if (isAfterValueNode()) {
ValueNode valueNode = pop();
if (node instanceof WordNode) {
WordNode wordNode = (WordNode) node;
String word = wordNode.getWord();
Matcher matcher = LITERAL_PATTERN.matcher(word);
if (matcher.lookingAt()) {
valueNode.setWordNode(wordNode);
} else {
throw new JdbcException(Message.DOMA2142, sql, tokenizer.getLineNumber(), tokenizer.getPosition(), valueNode.getText(), word);
}
} else if (node instanceof ParensNode) {
ParensNode parensNode = (ParensNode) node;
parensNode.setAttachedWithValue(true);
valueNode.setParensNode(parensNode);
} else {
throw new JdbcException(Message.DOMA2110, sql, tokenizer.getLineNumber(), tokenizer.getPosition(), valueNode.getText());
}
} else if (isAfterExpandNode()) {
ExpandNode expandNode = pop();
if (node instanceof OtherNode) {
OtherNode otherNode = (OtherNode) node;
if (!otherNode.getOther().equals("*")) {
throw new JdbcException(Message.DOMA2143, sql, tokenizer.getLineNumber(), tokenizer.getPosition(), expandNode.getText());
}
} else {
throw new JdbcException(Message.DOMA2143, sql, tokenizer.getLineNumber(), tokenizer.getPosition(), expandNode.getText());
}
} else {
peek().appendNode(node);
}
}
use of org.seasar.doma.jdbc.JdbcException 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);
}
use of org.seasar.doma.jdbc.JdbcException in project doma by domaframework.
the class SqlParser method parseForBlockComment.
protected void parseForBlockComment() {
ForBlockNode forBlockNode = new ForBlockNode();
appendNode(forBlockNode);
push(forBlockNode);
String expr = tokenType.extract(token);
int pos = expr.indexOf(":");
if (pos == -1) {
throw new JdbcException(Message.DOMA2124, sql, tokenizer.getLineNumber(), tokenizer.getPosition());
}
String identifier = expr.substring(0, pos).trim();
if (identifier.isEmpty()) {
throw new JdbcException(Message.DOMA2125, sql, tokenizer.getLineNumber(), tokenizer.getPosition());
}
String expression = expr.substring(pos + 1).trim();
if (expression.isEmpty()) {
throw new JdbcException(Message.DOMA2126, sql, tokenizer.getLineNumber(), tokenizer.getPosition());
}
ForNode forNode = new ForNode(getLocation(), identifier, expression, token);
forBlockNode.setForNode(forNode);
push(forNode);
}
use of org.seasar.doma.jdbc.JdbcException in project doma by domaframework.
the class SqlParser method validateParensClosed.
protected void validateParensClosed() {
if (isInParensNode()) {
removeNodesTo(ParensNode.class);
ParensNode parensNode = pop();
SqlLocation location = parensNode.getLocation();
throw new JdbcException(Message.DOMA2135, sql, location.getLineNumber(), location.getPosition());
}
}
Aggregations