Example usage for org.apache.commons.lang3.text StrBuilder deleteCharAt

List of usage examples for org.apache.commons.lang3.text StrBuilder deleteCharAt

Introduction

In this page you can find the example usage for org.apache.commons.lang3.text StrBuilder deleteCharAt.

Prototype

public StrBuilder deleteCharAt(final int index) 

Source Link

Document

Deletes the character at the specified index.

Usage

From source file:de.vandermeer.asciithemes.TA_Line_String.java

/**
 * Returns a line of given length.//from w  w w  .j a  va  2  s. com
 * @param length number of in the line
 * @param builder builder to append the line to, new builder will be created if null
 * @return line of given length, empty if length was null or negative
 */
default StrBuilder getLine(int length, StrBuilder builder) {
    StrBuilder append = new StrBuilder();
    if (this.getLineString().length() == 0 || length == 0) {
        return append;
    }
    while (append.length() < (length)) {
        append.append(this.getLineString());
    }
    while (append.length() > length) {
        append.deleteCharAt(append.length() - 1);
    }
    if (builder == null) {
        return append;
    }
    return builder.append(append);
}

From source file:com.hotpot.commons.pagination.PageHelper.java

/**
 * ?SQL./*from  w  w  w.  j a v  a 2 s.c o m*/
 *
 * @param sql the sql
 * @param page the page
 * @return the sort sql
 */
private String getSortSql(String sql, Page page) {

    if (ArrayUtils.isEmpty(page.getSidxs())) {
        return sql;
    }

    StrBuilder pageSql = new StrBuilder(200);
    if ("mysql".equals(dialect)) {
        pageSql.append("select _s.* from (");
        pageSql.append(sql);
        pageSql.append(") _s order by ");
        for (int idx = 0, max = page.getSidxs().length; idx < max; idx++) {
            pageSql.append(page.getSidxs()[idx]).append(" ");
            if (ArrayUtils.getLength(page.getSorts()) > idx) {
                pageSql.append(page.getSorts()[idx]).append(" ,");
            } else {
                pageSql.append("desc ").append(",");
            }
        }
        pageSql.deleteCharAt(pageSql.length() - 1);
    }
    return pageSql.toString();
}