Example usage for org.apache.commons.lang StringUtils leftPad

List of usage examples for org.apache.commons.lang StringUtils leftPad

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils leftPad.

Prototype

public static String leftPad(String str, int size) 

Source Link

Document

Left pad a String with spaces (' ').

Usage

From source file:org.pivot4j.ui.poi.ExcelExporter.java

/**
 * @see org.pivot4j.ui.RenderCallback#renderContent(org.pivot4j.ui.RenderContext,
 *      java.lang.String, java.lang.Double)
 *//* w w  w  . j  a  va  2 s.  c om*/
@Override
public void renderContent(TableRenderContext context, String label, Double value) {
    cell.setCellStyle(getCellStyle(context));

    if (VALUE.equals(context.getCellType()) && context.getAxis() != Axis.FILTER) {
        if (value == null) {
            cell.setCellValue("");
        } else {
            cell.setCellValue(value);
        }
    } else {
        boolean showParentMembers = context.getRenderer().getShowParentMembers();

        if (!showParentMembers && label != null && context.getAxis() == Axis.ROWS && context.getMember() != null
                && context.getCell() == null) {
            label = StringUtils.leftPad(label, context.getMember().getDepth() + label.length());
        }

        cell.setCellValue(label);
        cell.setCellType(Cell.CELL_TYPE_STRING);
    }
}

From source file:org.projectforge.business.fibu.datev.BuchungssatzImportRow.java

/**
 * Achtung: Diese Klasse ruft ggf. korrigierend und ndernd check() auf.
 * @see java.lang.Object#toString()// www.j a v a 2  s.c  o  m
 * @see #check()
 */
public String toString() {
    check(); // Leider muss dieser modifizierende check() ausgefhrt werden, da auf die aufrufende Klasse ExcelImport kein Einfluss
    // genommen werden kann.
    String txt = StringUtils.abbreviate(text, 30);
    DayHolder day = new DayHolder(datum);
    return StringUtils.leftPad(NumberHelper.getAsString(satzNr), 4) + " "
            + StringUtils.leftPad(day.isoFormat(), 10)
            + StringUtils.leftPad(
                    NumberHelper.getAsString(betrag, NumberHelper.getCurrencyFormat(Locale.GERMAN)), 12)
            + " " + kost1 != null ? StringUtils.leftPad(kost1.toString(), 12)
                    : "-           " + " " + kost2 != null ? StringUtils.leftPad(kost2.toString(), 12)
                            : "-           " + " " + StringUtils.rightPad(txt, 30);
}

From source file:org.projectforge.business.fibu.datev.KontenplanExcelRow.java

public String toString() {
    String txt = StringUtils.abbreviate(bezeichnung, 30);
    return StringUtils.leftPad(NumberHelper.getAsString(konto), 5) + " " + StringUtils.rightPad(txt, 30);
}

From source file:org.projectforge.business.fibu.kost.BusinessAssessment.java

private void asLine(final StringBuffer buf, final String no, final String title, final BigDecimal amount,
        final int indent, final int scale, final String unit, final boolean html) {
    if (html == true) {
        buf.append("  <tr><td>").append(no).append("</td><td class=\"indent-").append(indent).append("\">");
    } else {//from w ww . ja  va  2  s  .c  o m
        buf.append(StringUtils.leftPad(no, 4));
    }
    int length = 25;
    for (int i = 0; i < indent; i++) {
        if (html == false) {
            buf.append(" ");
        }
        length--; // One space lost.
    }
    if (html == true) {
        buf.append(HtmlHelper.escapeHtml(StringUtils.defaultString(title), false)).append("</td>");
    } else {
        buf.append(" ").append(StringUtils.rightPad(StringUtils.defaultString(title), length)).append(" ");
    }
    if (html == true) {
        buf.append("<td style=\"text-align: right;\">");
    }
    if (amount != null && amount.compareTo(BigDecimal.ZERO) != 0) {
        String value;
        if ("".equals(unit) == true) {
            value = CurrencyFormatter.format(amount);
        } else {
            final NumberFormat format = NumberHelper.getNumberFractionFormat(ThreadLocalUserContext.getLocale(),
                    scale);
            value = format.format(amount) + " " + unit;
        }
        buf.append(StringUtils.leftPad(value, 18));
    }
    if (html == true) {
        buf.append("</td></tr>\n");
    } else {
        buf.append("\n");
    }
}

From source file:org.projectforge.business.fibu.kost.BusinessAssessmentRow.java

@Override
public String toString() {
    return StringUtils.leftPad(getNo(), 4) + " " + StringUtils.rightPad(getTitle(), 20) + " "
            + StringUtils.leftPad(CurrencyFormatter.format(getAmount()), 18);
    /*/*from w  w w .  java  2 s.co m*/
     * StringBuffer buf = new StringBuffer(); buf.append(row); for (KontoUmsatz umsatz : kontoUmsaetze) { buf.append("\n ");
     * buf.append(umsatz.toString()); } return buf.toString();
     */
}

From source file:org.projectforge.business.fibu.KostFormatter.java

public static String formatNummer(final KontoDO konto) {
    return StringUtils.leftPad(String.valueOf(konto.getNummer()), 5);
}

From source file:org.projectforge.fibu.kost.BusinessAssessment.java

private void asLine(final StringBuffer buf, final String no, final String title, final BigDecimal amount,
        final int indent, final int scale, final String unit, final boolean html) {
    if (html == true) {
        buf.append("  <tr><td>").append(no).append("</td><td class=\"indent-").append(indent).append("\">");
    } else {/*from  w  w  w.  ja  va2s.  com*/
        buf.append(StringUtils.leftPad(no, 4));
    }
    int length = 25;
    for (int i = 0; i < indent; i++) {
        if (html == false) {
            buf.append(" ");
        }
        length--; // One space lost.
    }
    if (html == true) {
        buf.append(HtmlHelper.escapeHtml(StringUtils.defaultString(title), false)).append("</td>");
    } else {
        buf.append(" ").append(StringUtils.rightPad(StringUtils.defaultString(title), length)).append(" ");
    }
    if (html == true) {
        buf.append("<td style=\"text-align: right;\">");
    }
    if (amount != null && amount.compareTo(BigDecimal.ZERO) != 0) {
        String value;
        if ("".equals(unit) == true) {
            value = CurrencyFormatter.format(amount);
        } else {
            final NumberFormat format = NumberHelper.getNumberFractionFormat(PFUserContext.getLocale(), scale);
            value = format.format(amount) + " " + unit;
        }
        buf.append(StringUtils.leftPad(value, 18));
    }
    if (html == true) {
        buf.append("</td></tr>\n");
    } else {
        buf.append("\n");
    }
}

From source file:org.qipki.crypto.x509.DistinguishedNameTest.java

private void doTestWithSample(String fromFormat, DistinguishedName dn, DistinguishedName.Format toFormat,
        String expected) {/*from   ww w.  j  av  a  2s .co  m*/
    String testedRepresentation = dn.toString(toFormat);
    System.out.println(
            StringUtils.leftPad(fromFormat + " as " + toFormat.name() + ": ", 45) + testedRepresentation);
    assertEquals(expected, testedRepresentation);
}

From source file:org.rhq.bindings.TabularWriterTest.java

@Test
public void theIdShouldBeTheFirstPropertyPrintedForEntity() {
    User user = new User(1, "rhqadmin", "rhqadmin");

    writer.print(user);/*ww  w .ja v a 2s  . c om*/

    int paddingSize = "username".length();
    int idLineNumber = 1;
    String expected = "\t" + StringUtils.leftPad("id", paddingSize) + ": " + user.getId();

    assertLineEquals(idLineNumber, expected, "The id property should be the 2nd line printed");
}

From source file:org.rhq.bindings.TabularWriterTest.java

String padResourceField(String field) {
    return StringUtils.leftPad(field, "currentAvailability".length());
}