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:com.srikanthps.HbaseBenchmarking.java

public static void main(String[] args)
        throws InterruptedException, InstantiationException, IllegalAccessException {

    System.out.println("Simple HBase benchmarking application");

    long startingRowKey = 600000000000L;

    System.out.println(StringUtils.rightPad("Scenario,", 50)
            + StringUtils.leftPad("Num Threads,", LABEL_RIGHT_PAD)
            + StringUtils.leftPad("Puts,", LABEL_RIGHT_PAD) + StringUtils.leftPad("Mean,", LABEL_RIGHT_PAD)
            + StringUtils.leftPad("Stdev,", LABEL_RIGHT_PAD) + StringUtils.leftPad("Max,", LABEL_RIGHT_PAD)
            + StringUtils.leftPad("Min,", LABEL_RIGHT_PAD) + StringUtils.leftPad("80 Pctl,", LABEL_RIGHT_PAD)
            + StringUtils.leftPad("90 Pctl,", LABEL_RIGHT_PAD));

    runTest(HTablePoolBasedRowCreator.class, startingRowKey, 100, 1, DATA);
    runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 100, 1, DATA);
    runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 100, 1, DATA);
    System.out.println();//from   w w w .j a va 2s  .co  m

    runTest(HTablePoolBasedRowCreator.class, startingRowKey, 1000, 1, DATA);
    runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 1000, 1, DATA);
    runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 1000, 1, DATA);
    System.out.println();

    runTest(HTablePoolBasedRowCreator.class, startingRowKey, 10000, 1, DATA);
    runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 10000, 1, DATA);
    runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 10000, 1, DATA);
    System.out.println();

    runTest(HTablePoolBasedRowCreator.class, startingRowKey, 100, 10, DATA);
    runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 100, 10, DATA);
    runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 100, 10, DATA);
    System.out.println();

    runTest(HTablePoolBasedRowCreator.class, startingRowKey, 1000, 10, DATA);
    runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 1000, 10, DATA);
    runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 1000, 10, DATA);
    System.out.println();

    runTest(HTablePoolBasedRowCreator.class, startingRowKey, 10000, 10, DATA);
    runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 10000, 10, DATA);
    runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 10000, 10, DATA);
    System.out.println();

    runTest(HTablePoolBasedRowCreator.class, startingRowKey, 100, 100, DATA);
    runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 100, 100, DATA);
    runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 100, 100, DATA);
    System.out.println();

    runTest(HTablePoolBasedRowCreator.class, startingRowKey, 1000, 100, DATA);
    runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 1000, 100, DATA);
    runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 1000, 100, DATA);
    System.out.println();

    runTest(HTablePoolBasedRowCreator.class, startingRowKey, 10000, 100, DATA);
    runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 10000, 100, DATA);
    runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 10000, 100, DATA);
    System.out.println();

}

From source file:com.srikanthps.HbaseBenchmarkingWithHadoop.java

public static void main(String[] args)
        throws InterruptedException, InstantiationException, IllegalAccessException {

    System.out.println("Simple HBase benchmarking application");

    long startingRowKey = 800000000000L;

    System.out.println(StringUtils.rightPad("Scenario,", 50)
            + StringUtils.leftPad("Num Threads", LABEL_RIGHT_PAD) + StringUtils.leftPad("Puts", LABEL_RIGHT_PAD)
            + StringUtils.leftPad("Mean,", LABEL_RIGHT_PAD) + StringUtils.leftPad("Stdev,", LABEL_RIGHT_PAD)
            + StringUtils.leftPad("Max,", LABEL_RIGHT_PAD) + StringUtils.leftPad("Min,", LABEL_RIGHT_PAD)
            + StringUtils.leftPad("80 Pctl,", LABEL_RIGHT_PAD)
            + StringUtils.leftPad("90 Pctl,", LABEL_RIGHT_PAD));

    runTest(HTablePoolBasedRowCreator.class, startingRowKey, 100, 1, DATA);
    runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 100, 1, DATA);
    runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 100, 1, DATA);
    System.out.println();/*from   w  w  w.j ava 2  s.  co  m*/
    /*
          runTest(HTablePoolBasedRowCreator.class, startingRowKey, 1000, 1, DATA);
          runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 1000, 1, DATA);
          runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 1000, 1, DATA);
          System.out.println();
            
          runTest(HTablePoolBasedRowCreator.class, startingRowKey, 10000, 1, DATA);
          runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 10000, 1, DATA);
          runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 10000, 1, DATA);
          System.out.println();
            
          runTest(HTablePoolBasedRowCreator.class, startingRowKey, 100, 10, DATA);
          runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 100, 10, DATA);
          runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 100, 10, DATA);
          System.out.println();
            
          runTest(HTablePoolBasedRowCreator.class, startingRowKey, 1000, 10, DATA);
          runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 1000, 10, DATA);
          runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 1000, 10, DATA);
          System.out.println();
            
          runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 10000, 10, DATA);
          runTest(HTablePoolBasedRowCreator.class, startingRowKey, 10000, 10, DATA);
          runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 10000, 10, DATA);
          System.out.println();
            
          runTest(HTablePoolBasedRowCreator.class, startingRowKey, 100, 100, DATA);
          runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 100, 100, DATA);
          runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 100, 100, DATA);
          System.out.println();
            
          runTest(HTablePoolBasedRowCreator.class, startingRowKey, 1000, 100, DATA);
          runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 1000, 100, DATA);
          runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 1000, 100, DATA);
          System.out.println();
    */
    runTest(HTablePoolBasedRowCreator.class, startingRowKey, 50000, 200, DATA);
    runTest(HTablePoolBasedRowCreator.class, startingRowKey, 50000, 200, DATA);
    runTest(HTablePoolBasedRowCreator.class, startingRowKey, 50000, 200, DATA);
    /*      runTest(HTableWithReusedHBaseConfiguration.class, startingRowKey, 10000, 100, DATA);
          runTest(HTableWithNewHBaseConfiguration.class, startingRowKey, 10000, 100, DATA);
    */ System.out.println();

}

From source file:com.netflix.spinnaker.halyard.cli.ui.v1.AnsiMessageList.java

private AnsiSnippet addIndentedMessage(int indentWidth, String messageText) {
    String indent = StringUtils.leftPad("", indentWidth);
    messages.add(new AnsiSnippet(indent));

    AnsiSnippet message = new AnsiSnippet(messageText);
    messages.add(message);//from   www .ja  v a  2  s  .com

    return message;
}

From source file:com.netflix.spinnaker.halyard.cli.ui.v1.AnsiParagraphBuilder.java

String getIndent() {
    return StringUtils.leftPad("", indentWidth);
}

From source file:de.codesourcery.eve.skills.market.impl.EveMarketLogParser.java

protected static final String formatLeft(Object s) {
    return StringUtils.leftPad(s.toString(), 20) + " | ";
}

From source file:at.porscheinformatik.common.spring.web.extended.util.ParboiledUtils.java

private static <T> String buildErrorMessag(ParsingResult<T> result, String resourceDescription) {
    StringBuilder builder = new StringBuilder();
    builder.append("Template " + resourceDescription + " contains errors: \n");
    for (ParseError error : result.parseErrors) {
        int start = error.getStartIndex();
        int end = error.getEndIndex();

        if (start - 10 > 0) {
            start -= 10;//from   w  ww . ja  va 2 s  . c  om
        } else {
            start = 0;
        }

        builder.append(error.getInputBuffer().extract(start, end)).append(" --> ");

        if (error.getErrorMessage() != null) {
            builder.append(error.getErrorMessage());
        } else {
            builder.append(error.toString());
        }

        builder.append("\n");

        builder.append(StringUtils.leftPad("^", error.getStartIndex() - start - 1));

        if (error.getEndIndex() > error.getStartIndex()) {
            builder.append(StringUtils.left("^", error.getEndIndex() - error.getStartIndex() - 1));
        }
    }

    return builder.toString();
}

From source file:com.fortify.processrunner.util.HelpPrinter.java

public HelpPrinter append(int indent, String str) {
    int leadingSpaces = str.indexOf(str.trim());
    indent += leadingSpaces;//from   www  . j  a  v a 2s.  c  o m
    str = str.substring(leadingSpaces);
    String padding = StringUtils.leftPad("", indent);
    sb.append(padding + WordUtils.wrap(str, width - indent, "\n" + padding, false)).append("\n");
    return this;
}

From source file:eionet.cr.dao.helpers.QueryHelper.java

private static String formatSparqlQuery(String query) {
    query = StringUtils.replace(query, PREFIX.toLowerCase(), PREFIX);
    query = StringUtils.replace(query, SELECT.toLowerCase(), SELECT);
    query = StringUtils.replace(query, WHERE.toLowerCase(), WHERE);
    query = StringUtils.replace(query, FROM.toLowerCase(), FROM);

    query = StringUtils.replace(query, PREFIX, "\n" + PREFIX);
    query = StringUtils.replace(query, SELECT, "\n" + SELECT);
    query = StringUtils.replace(query, WHERE, "\n" + WHERE);
    query = StringUtils.replace(query, FROM, "\n" + FROM);

    query = StringUtils.replace(query, "{", "{\n ");
    query = StringUtils.replace(query, "}", "\n}");
    query = StringUtils.replace(query, " .", ".\n");

    String[] lines = query.split("\n");
    StringBuilder result = new StringBuilder();
    int spaces = 0;
    for (String line : lines) {
        line = line.trim();/*from w  ww.j  av  a2  s  .  c o  m*/
        if (StringUtils.isNotEmpty(line)) {
            result.append(StringUtils.leftPad(line, spaces + line.length()));
            result.append("\n");
            spaces = countSpaces(spaces, line);
        }
    }
    return result.toString();
}

From source file:com.vamonossoftware.core.TextTable.java

public String toString() {
    StringBuilder sb = new StringBuilder();
    for (Object[] objects : data) {
        sb.append(leftPad);/*from   w w  w. j  av  a 2 s .co m*/
        for (int i = 0; i < objects.length; i++) {
            Object object = objects[i];
            if (alignment.length > i) {
                switch (alignment[i]) {
                case CENTER:
                    sb.append(StringUtils.center(object.toString(), maxWidths.get(i)));
                    break;
                case RIGHT:
                    sb.append(StringUtils.leftPad(object.toString(), maxWidths.get(i)));
                    break;
                default:
                    sb.append(StringUtils.rightPad(object.toString(), maxWidths.get(i)));
                    break;
                }
            }
            sb.append(" ");
        }
        sb.append("\n");
    }
    return sb.toString();
}

From source file:com.leavesfly.lia.advsearching.SortingExample.java

public void displayResults(Query query, Sort sort) // #1
        throws IOException {
    IndexSearcher searcher = new IndexSearcher(directory);

    searcher.setDefaultFieldSortScoring(true, false); // #2

    TopDocs results = searcher.search(query, null, // #3
            20, sort); // #3

    System.out.println("\nResults for: " + // #4
            query.toString() + " sorted by " + sort);

    System.out.println(StringUtils.rightPad("Title", 30) + StringUtils.rightPad("pubmonth", 10)
            + StringUtils.center("id", 4) + StringUtils.center("score", 15));

    PrintStream out = new PrintStream(System.out, true, "UTF-8"); // #5

    DecimalFormat scoreFormatter = new DecimalFormat("0.######");
    for (ScoreDoc sd : results.scoreDocs) {
        int docID = sd.doc;
        float score = sd.score;
        Document doc = searcher.doc(docID);
        out.println(StringUtils.rightPad( // #6
                StringUtils.abbreviate(doc.get("title"), 29), 30) + // #6
                StringUtils.rightPad(doc.get("pubmonth"), 10) + // #6
                StringUtils.center("" + docID, 4) + // #6
                StringUtils.leftPad( // #6
                        scoreFormatter.format(score), 12)); // #6
        out.println("   " + doc.get("category"));
        // out.println(searcher.explain(query, docID)); // #7
    }/* w w w  .jav  a 2 s .  co  m*/

    searcher.close();
}