Search in sources :

Example 81 with StatementBuilder

use of org.h2.util.StatementBuilder in project h2database by h2database.

the class Doclet method writeMethodDetails.

private void writeMethodDetails(PrintWriter writer, ClassDoc clazz, ExecutableMemberDoc method, String signature) {
    String name = method.name();
    if (skipMethod(method)) {
        return;
    }
    Parameter[] params = method.parameters();
    StatementBuilder buff = new StatementBuilder();
    buff.append('(');
    int i = 0;
    for (Parameter p : params) {
        boolean isVarArgs = method.isVarArgs() && i++ == params.length - 1;
        buff.appendExceptFirst(", ");
        buff.append(getTypeName(false, isVarArgs, p.type()));
        buff.append(' ');
        buff.append(p.name());
    }
    buff.append(')');
    ClassDoc[] exceptions = method.thrownExceptions();
    if (exceptions.length > 0) {
        buff.append(" throws ");
        buff.resetCount();
        for (ClassDoc ex : exceptions) {
            buff.appendExceptFirst(", ");
            buff.append(ex.typeName());
        }
    }
    if (isDeprecated(method)) {
        name = "<span class=\"deprecated\">" + name + "</span>";
    }
    writer.println("<a id=\"" + signature + "\" href=\"#" + signature + "\">" + name + "</a>" + buff.toString());
    boolean hasComment = method.commentText() != null && method.commentText().trim().length() != 0;
    writer.println("<div class=\"methodText\">" + formatText(method.commentText()) + "</div>");
    ParamTag[] paramTags = method.paramTags();
    ThrowsTag[] throwsTags = method.throwsTags();
    boolean hasThrowsTag = throwsTags != null && throwsTags.length > 0;
    if (paramTags.length != params.length) {
        if (hasComment && !method.commentText().startsWith("[")) {
            // [Not supported] and such are not problematic
            addError("Undocumented parameter(s) (" + getLink(clazz, method.position().line()) + ") " + name + " documented: " + paramTags.length + " params: " + params.length);
        }
    }
    for (int j = 0; j < paramTags.length; j++) {
        String paramName = paramTags[j].parameterName();
        String comment = paramTags[j].parameterComment();
        if (comment.trim().length() == 0) {
            addError("Undocumented parameter (" + getLink(clazz, method.position().line()) + ") " + name + " " + paramName);
        }
        String p = paramName + " - " + comment;
        if (j == 0) {
            writer.println("<div class=\"itemTitle\">Parameters:</div>");
        }
        writer.println("<div class=\"item\">" + p + "</div>");
    }
    Tag[] returnTags = method.tags("return");
    Type returnType = getReturnType(method);
    if (returnTags != null && returnTags.length > 0) {
        writer.println("<div class=\"itemTitle\">Returns:</div>");
        String returnComment = returnTags[0].text();
        if (returnComment.trim().length() == 0) {
            addError("Undocumented return value (" + getLink(clazz, method.position().line()) + ") " + name);
        }
        writer.println("<div class=\"item\">" + returnComment + "</div>");
    } else if (returnType != null && !returnType.toString().equals("void")) {
        if (hasComment && !method.commentText().startsWith("[") && !hasThrowsTag) {
            // [Not supported] and such are not problematic
            // also not problematic are methods that always throw an
            // exception
            addError("Undocumented return value (" + getLink(clazz, method.position().line()) + ") " + name + " " + getReturnType(method));
        }
    }
    if (hasThrowsTag) {
        writer.println("<div class=\"itemTitle\">Throws:</div>");
        for (ThrowsTag tag : throwsTags) {
            String p = tag.exceptionName();
            String c = tag.exceptionComment();
            if (c.length() > 0) {
                p += " - " + c;
            }
            writer.println("<div class=\"item\">" + p + "</div>");
        }
    }
}
Also used : ParamTag(com.sun.javadoc.ParamTag) ThrowsTag(com.sun.javadoc.ThrowsTag) Type(com.sun.javadoc.Type) StatementBuilder(org.h2.util.StatementBuilder) Parameter(com.sun.javadoc.Parameter) Tag(com.sun.javadoc.Tag) ParamTag(com.sun.javadoc.ParamTag) ThrowsTag(com.sun.javadoc.ThrowsTag) ClassDoc(com.sun.javadoc.ClassDoc)

Example 82 with StatementBuilder

use of org.h2.util.StatementBuilder in project ignite by apache.

the class GridSqlDelete method getSQL.

/**
 * {@inheritDoc}
 */
@Override
public String getSQL() {
    char delim = delimeter();
    StatementBuilder buff = new StatementBuilder(explain() ? "EXPLAIN " : "");
    buff.append("DELETE").append(delim).append("FROM ").append(from.getSQL());
    if (where != null)
        buff.append(delim).append("WHERE ").append(StringUtils.unEnclose(where.getSQL()));
    if (limit != null)
        buff.append(delim).append("LIMIT (").append(StringUtils.unEnclose(limit.getSQL())).append(')');
    return buff.toString();
}
Also used : StatementBuilder(org.h2.util.StatementBuilder)

Example 83 with StatementBuilder

use of org.h2.util.StatementBuilder in project ignite by apache.

the class GridSqlJoin method getSQL.

/**
 * {@inheritDoc}
 */
@Override
public String getSQL() {
    char delim = delimeter();
    StatementBuilder buff = new StatementBuilder();
    buff.append(leftTable().getSQL());
    buff.append(' ').append(delim).append(leftOuter ? " LEFT OUTER JOIN " : " INNER JOIN ");
    buff.append(rightTable().getSQL());
    buff.append(' ').append(delim).append(" ON ").append(StringUtils.unEnclose(on().getSQL()));
    return buff.toString();
}
Also used : StatementBuilder(org.h2.util.StatementBuilder)

Example 84 with StatementBuilder

use of org.h2.util.StatementBuilder in project ignite by apache.

the class GridSqlSelect method getSQL.

/**
 * {@inheritDoc}
 */
@Override
public String getSQL() {
    char delim = delimeter();
    StatementBuilder buff = new StatementBuilder(explain() ? "EXPLAIN SELECT" : "SELECT");
    if (distinct)
        buff.append(" DISTINCT");
    for (GridSqlAst expression : columns(true)) {
        buff.appendExceptFirst(",");
        buff.append(delim);
        buff.append(expression.getSQL());
    }
    if (from != null)
        buff.append(delim).append("FROM ").append(from.getSQL());
    if (where != null)
        buff.append(delim).append("WHERE ").append(StringUtils.unEnclose(where.getSQL()));
    if (grpCols != null) {
        buff.append(delim).append("GROUP BY ");
        buff.resetCount();
        for (int grpCol : grpCols) {
            buff.appendExceptFirst(", ");
            addAlias(buff, cols.get(grpCol));
        }
    }
    if (havingCol >= 0) {
        buff.append(delim).append("HAVING ");
        addAlias(buff, cols.get(havingCol));
    }
    getSortLimitSQL(buff);
    if (isForUpdate)
        buff.append(delim).append("FOR UPDATE");
    return buff.toString();
}
Also used : StatementBuilder(org.h2.util.StatementBuilder)

Aggregations

StatementBuilder (org.h2.util.StatementBuilder)82 Value (org.h2.value.Value)16 Column (org.h2.table.Column)15 IndexColumn (org.h2.table.IndexColumn)11 PreparedStatement (java.sql.PreparedStatement)9 Expression (org.h2.expression.Expression)9 ValueString (org.h2.value.ValueString)7 Index (org.h2.index.Index)6 DbException (org.h2.message.DbException)6 ResultSet (java.sql.ResultSet)5 Row (org.h2.result.Row)4 SQLException (java.sql.SQLException)3 ArrayList (java.util.ArrayList)3 Constraint (org.h2.constraint.Constraint)3 Database (org.h2.engine.Database)3 ExpressionColumn (org.h2.expression.ExpressionColumn)3 HashMap (java.util.HashMap)2 SelectOrderBy (org.h2.command.dml.SelectOrderBy)2 ResultInterface (org.h2.result.ResultInterface)2 SearchRow (org.h2.result.SearchRow)2