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

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

Introduction

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

Prototype

public static String rightPad(String str, int size) 

Source Link

Document

Right 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 av  a2 s  . c  om*/

    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.discursive.jccook.slide.ListExample.java

public static void main(String[] args) throws HttpException, IOException {
    String url = "http://www.discursive.com/jccook/dav/";
    Credentials credentials = new UsernamePasswordCredentials("davuser", "davpass");

    // List resources in top directory
    WebdavResource resource = new WebdavResource(url, credentials);
    WebdavResource[] resources = resource.listWebdavResources();
    System.out.println("type  name           size    type                   modified");
    System.out.println("--------------------------------------------------------------------");
    for (int i = 0; i < resources.length; i++) {
        WebdavResource item = resources[i];
        String type;/*  w  w w .  j  ava  2  s  . c om*/
        if (item.isCollection()) {
            type = "dir";
        } else {
            type = "file";
        }
        System.out.print(StringUtils.rightPad(type, 6));
        System.out.print(StringUtils.rightPad(item.getName(), 15));
        System.out.print(StringUtils.rightPad(item.getGetContentLength() + "", 8));
        System.out.print(StringUtils.rightPad(item.getGetContentType(), 23));
        Date lastMod = new Date(item.getGetLastModified());
        System.out.print(StringUtils.rightPad(FastDateFormat.getInstance().format(lastMod), 25));
        System.out.print("\n");
    }
}

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  . ja  v a2s.c  o 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:mitm.common.util.StringReplaceUtils.java

/**
 * Returns the input string with all tabs replaced by tabWidth spaces.
 *//*from   w w w  . j a  va 2 s  . c  o  m*/
public static String replaceTabsWithSpaces(String input, int tabWidth) {
    return input.replaceAll("\t", StringUtils.rightPad("", tabWidth));
}

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

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

From source file:morphy.command.HelpCommand.java

public void process(String arguments, UserSession userSession) {
    String argument = arguments.trim();

    if (argument.length() == 0) {
        StringBuilder result = new StringBuilder(1000);
        result.append("Help is available on the following commands:\n");
        result.append("(Type help commandName for help on the command)\n\n");
        int counter = 0;
        Command[] commands = CommandService.getInstance().getCommands();
        for (Command command : commands) {
            if (!command.willProcess(userSession))
                continue;

            result.append(StringUtils.rightPad(command.getContext().getName(), 15));
            counter++;//from  w  w  w.java  2s  . c o m
            if (counter == 5) {
                result.append("\n");
                counter = 0;
            }
        }
        userSession.send(result.toString());
    } else {
        if (argument.contains(" ")) {
            userSession.send(getContext().getUsage());
            return;
        }

        Command command = CommandService.getInstance().getCommand(argument);
        if (command == null || !command.willProcess(userSession)) {
            userSession.send("No help avaliable on \"" + argument + "\".");
        } else {
            StringBuilder builder = new StringBuilder(200);
            builder.append("Help for " + command.getContext().getName() + "\n");
            builder.append("Usage: " + command.getContext().getUsage() + "\n");
            builder.append("Level: " + command.getContext().getUserLevel() + "\n");
            builder.append("Description:\n");
            builder.append(command.getContext().getHelp());

            StringBuilder postBuilder = new StringBuilder(200);
            postBuilder.append("\nAliases: "
                    + MorphyStringUtils.toDelimitedString(command.getContext().getAliases(), " ") + "\n");
            postBuilder.append("See Also: "
                    + MorphyStringUtils.toDelimitedString(command.getContext().getSeeAlso(), " ") + "\n");
            postBuilder.append("Last Modified By: " + command.getContext().getLastModifiedBy() + " on "
                    + command.getContext().getLastModifiedDate());

            builder.append(postBuilder.toString());
            userSession.send(builder.toString());
        }
    }

}

From source file:morphy.command.admin.AHelpCommand.java

public void process(String arguments, UserSession userSession) {
    String argument = arguments.trim();

    if (argument.length() == 0) {
        StringBuilder result = new StringBuilder(1000);
        result.append("Help is available on the following commands:\n");
        result.append("(Type ahelp commandName for help on the command)\n\n");
        int counter = 0;
        Command[] commands = CommandService.getInstance().getCommands();
        for (Command command : commands) {
            if (command.getContext().getUserLevel().ordinal() < UserLevel.Admin.ordinal()) {
                continue;
            }/* www  . j a v  a  2s . c o m*/

            result.append(StringUtils.rightPad(command.getContext().getName(), 15));
            counter++;
            if (counter == 5) {
                result.append("\n");
                counter = 0;
            }
        }
        userSession.send(result.toString());
    } else {
        if (argument.contains(" ")) {
            userSession.send(getContext().getUsage());
            return;
        }

        Command command = CommandService.getInstance().getCommand(argument);
        if (command == null || !command.willProcess(userSession)) {
            userSession.send("No ahelp avaliable on \"" + argument + "\".");
        } else {
            StringBuilder builder = new StringBuilder(200);
            builder.append("Help for " + command.getContext().getName() + "\n");
            builder.append("Usage: " + command.getContext().getUsage() + "\n");
            builder.append("Level: " + command.getContext().getUserLevel() + "\n");
            builder.append("Description:\n");
            builder.append(command.getContext().getHelp());

            StringBuilder postBuilder = new StringBuilder(200);
            postBuilder.append("\nAliases: "
                    + MorphyStringUtils.toDelimitedString(command.getContext().getAliases(), " ") + "\n");
            postBuilder.append("See Also: "
                    + MorphyStringUtils.toDelimitedString(command.getContext().getSeeAlso(), " ") + "\n");
            postBuilder.append("Last Modified By: " + command.getContext().getLastModifiedBy() + " on "
                    + command.getContext().getLastModifiedDate());

            builder.append(postBuilder.toString());
            userSession.send(builder.toString());
            return;
        }
    }

}

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  . j a va 2s . c  o m*/

    searcher.close();
}

From source file:$.java

    /**
 * Convert the user input as an Object, it returns a String that matches the input with a right padding. The padding attribute is given as a converter
 * parameter, the default padding character is ' '.
 *///w  w  w.  j a  va 2  s.c  o  m
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    if (context == null || component == null) {
        throw new NullPointerException();
    }
    int padding = getPadding(context, component);
    if (StringUtils.isBlank(value)) {
        return StringUtils.rightPad("", padding);
    }
    return StringUtils.rightPad(value, padding);
}

From source file:com.receipts.services.ExportService.java

public InputStream createExportFile(Store store) {
    InputStream is = null;/*  ww w .jav a 2  s  . c  o m*/

    String storeId = store.getStoreId();
    String storeIdStr = StringUtils.leftPad(storeId, 3, "0");

    Date storeDate = store.getStoreDate();
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    String storeDateStr = sdf.format(storeDate);

    DecimalFormatSymbols dfs = new DecimalFormatSymbols();
    dfs.setDecimalSeparator('.');

    StringBuilder sb = new StringBuilder();
    for (Receipt receipt : store.getReceipts()) {
        if (receipt.isComplete()) {
            String receiptId = receipt.getId().toString();
            String receiptTime = receipt.getReceiptTime();

            for (Product product : receipt.getProducts()) {
                // Store Id: 3 chars
                storeIdStr = StringUtils.substring(storeIdStr, 0, 3);
                sb.append(storeIdStr);

                // Product Name: 32 chars
                String productName = StringUtils.substring(product.getProductName(), 0, 32);
                String productNameStr = StringUtils.rightPad(productName, 32);
                sb.append(productNameStr);

                String productPrice = new DecimalFormat("0000.00", dfs).format(product.getProductPrice());
                String productPriceStr = StringUtils.leftPad(productPrice, 7, "0");
                sb.append(productPriceStr);

                // Receipt Id: 10 chars
                String receiptIdStr = StringUtils.leftPad(StringUtils.substring(receiptId, 0, 10), 10);
                sb.append(receiptIdStr);

                sb.append(storeDateStr);

                sb.append(receiptTime);

                String productQuantity = new DecimalFormat("#0.000", dfs).format(product.getProductQuantity());
                String productQuantityStr = StringUtils.leftPad(productQuantity, 6, "0");
                sb.append(productQuantityStr);

                sb.append(System.getProperty("line.separator"));
            }
        }
    }

    is = IOUtils.toInputStream(sb.toString());

    return is;
}