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:de.codesourcery.eve.skills.ui.components.impl.RefiningComponent.java

protected void putRefiningResultsOnClipboard() {

    final StringBuffer text = new StringBuffer();

    text.append(StringUtils.rightPad("Item", 35)).append(StringUtils.rightPad("Volume", 15))
            .append(StringUtils.leftPad("Quantity", 15)).append(StringUtils.leftPad("Sell value", 15))
            .append("\n\n");

    final List<RefiningResult> rows = refiningResultsModel.myData;
    final DecimalFormat VOL = new DecimalFormat("###,###,###,###,###.0###");
    for (Iterator<RefiningResult> it = rows.iterator(); it.hasNext();) {
        final RefiningResult row = it.next();

        final double volume = row.getYourQuantityMinusStationTax() * row.getType().getVolume();

        text.append(StringUtils.rightPad(row.getType().getName(), 35))
                .append(StringUtils.leftPad(VOL.format(volume), 15))
                .append(StringUtils.leftPad("" + row.getYourQuantityMinusStationTax(), 15))
                .append(StringUtils.leftPad(AmountHelper.formatISKAmount(row.getSellValue()), 15));

        if (it.hasNext()) {
            text.append("\n");
        }/*from  w  w  w .  j  av  a 2 s  . c  o  m*/
    }

    new PlainTextTransferable(text).putOnClipboard();
}

From source file:net.certiv.authmgr.task.section.core.classifier.BayesPartitionClassifier.java

@SuppressWarnings("unused")
private void report(String category, String partition, String word, double pBi, double pEoB, double wordProb) {
    BigDecimal pBiBD = new BigDecimal(pBi).setScale(5, BigDecimal.ROUND_HALF_UP);
    BigDecimal pEoBiBD = new BigDecimal(pEoB).setScale(8, BigDecimal.ROUND_HALF_UP);
    BigDecimal probBD = new BigDecimal(wordProb).setScale(8, BigDecimal.ROUND_HALF_UP);
    String wordAbbr = StringUtils.abbreviate(word, 13);
    wordAbbr = StringUtils.rightPad(wordAbbr, 14);
    Log.warn(this, "Bayes: " + wordAbbr + pEoBiBD + " (" + probBD + ":" + pBiBD + ")");
}

From source file:com.grantingersoll.intell.clustering.KMeansClusteringEngine.java

public static String getTopFeatures(Vector vector, String[] dictionary, int numTerms) {

    List<TermIndexWeight> vectorTerms = new ArrayList<TermIndexWeight>();

    Iterator<Vector.Element> iter = vector.iterateNonZero();
    while (iter.hasNext()) {
        Vector.Element elt = iter.next();
        vectorTerms.add(new TermIndexWeight(elt.index(), elt.get()));
    }/*from  w  w  w .  j  a v  a2  s  .c  o m*/

    // Sort results in reverse order (ie weight in descending order)
    Collections.sort(vectorTerms, new Comparator<TermIndexWeight>() {

        public int compare(TermIndexWeight one, TermIndexWeight two) {
            return Double.compare(two.weight, one.weight);
        }
    });

    Collection<Pair<String, Double>> topTerms = new LinkedList<Pair<String, Double>>();

    for (int i = 0; (i < vectorTerms.size()) && (i < numTerms); i++) {
        int index = vectorTerms.get(i).index;
        String dictTerm = dictionary[index];
        if (dictTerm == null) {
            log.error("Dictionary entry missing for {}", index);
            continue;
        }
        topTerms.add(new Pair<String, Double>(dictTerm, vectorTerms.get(i).weight));
    }

    StringBuilder sb = new StringBuilder(100);

    for (Pair<String, Double> item : topTerms) {
        String term = item.getFirst();
        sb.append("\n\t\t");
        sb.append(StringUtils.rightPad(term, 40));
        sb.append("=>");
        sb.append(StringUtils.leftPad(item.getSecond().toString(), 20));
    }
    return sb.toString();
}

From source file:de.codesourcery.eve.skills.ui.components.impl.planning.ShoppingListComponent.java

private void putSelectedShoppingListOnClipboard() {

    final StringBuffer result = new StringBuffer();

    final ITreeNode selected = getSelectedTreeNode();
    if (selected == null) {
        return;/*from   w  w  w  .  j a v a 2  s  .co m*/
    }

    final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

    ShoppingList list = null;
    if (selected.getValue() instanceof ShoppingList) {
        list = (ShoppingList) selected.getValue();
    } else if (selected.getValue() instanceof ShoppingListEntry) {
        final ShoppingListEntry entry = (ShoppingListEntry) selected.getValue();
        list = entry.getShoppingList();
    }

    if (list == null) {
        return;
    }

    result.append(list.getTitle()).append(Misc.newLine());
    if (!StringUtils.isBlank(list.getDescription())) {
        result.append(Misc.newLine()).append(list.getDescription()).append(Misc.newLine().twice());
    }

    final DecimalFormat quantityFormat = new DecimalFormat("###,###,###,###,##0");

    for (Iterator<ShoppingListEntry> it = list.iterator(); it.hasNext();) {
        final ShoppingListEntry entry = it.next();

        result.append(StringUtils.rightPad(entry.getType().getName(), 30))
                .append(StringUtils.leftPad(quantityFormat.format(entry.getQuantity()), 20));

        if (it.hasNext()) {
            result.append(Misc.newLine());
        }
    }

    clipboard.setContents(new PlainTextTransferable(result.toString()), null);
}

From source file:de.codesourcery.eve.skills.ui.components.impl.AssetListComponent.java

private String pad(String s) {
    return StringUtils.rightPad(s, 12);
}

From source file:de.codesourcery.eve.skills.ui.components.impl.AssetListComponent.java

private String pad(String s, int len) {
    return StringUtils.rightPad(s, len);
}

From source file:de.codesourcery.eve.skills.ui.components.impl.AssetListComponent.java

private String createLine(String col1) {
    return StringUtils.rightPad(col1, 45) + "\n";
}

From source file:com.cubeia.firebase.server.lobby.systemstate.StateLobby.java

public String printPacketCounts() {
    ConcurrentMap<LobbyPath, Integer> fullPacketCount = new ConcurrentHashMap<LobbyPath, Integer>();
    ConcurrentMap<LobbyPath, Integer> deltaPacketCount = new ConcurrentHashMap<LobbyPath, Integer>();

    for (SnapshotGenerator generator : generators.values()) {
        ConcurrentMap<LobbyPath, FullSnapshot> fullSnapshots = generator.getFullSnapshots();
        ConcurrentMap<LobbyPath, DeltaSnapshot> deltaSnapshots = generator.getDeltaSnapshots();

        for (LobbyPath path : fullSnapshots.keySet()) {
            FullSnapshot fullSnapshot = fullSnapshots.get(path);
            fullPacketCount.put(path, fullSnapshot.getLobbyData().size());
        }//from w  ww  .  j  a  v  a  2  s.  co  m

        for (LobbyPath path : deltaSnapshots.keySet()) {
            DeltaSnapshot deltaSnapshot = deltaSnapshots.get(path);
            deltaPacketCount.put(path, deltaSnapshot.getLobbyData().size());
        }
    }

    String info = "Lobby Snapshots Per Chached Lobby Path\n";
    info += "-----------------------\n";
    info += "Full Packet Path Count:  " + fullPacketCount.size() + "\n";
    info += "Delta Packet Path Count: " + deltaPacketCount.size() + "\n";
    info += "-----------------------\n";
    info += "FULL PACKET COUNT PER PATH\n";
    for (LobbyPath path : fullPacketCount.keySet()) {
        info += StringUtils.rightPad(path.toString(), 60) + "\t : " + fullPacketCount.get(path) + "\n";
    }
    info += "-----------------------\n";
    info += "DELTA PACKET COUNT PER PATH\n";
    for (LobbyPath path : deltaPacketCount.keySet()) {
        info += StringUtils.rightPad(path.toString(), 60) + "\t : " + deltaPacketCount.get(path) + "\n";
        ;
    }

    return info;
}

From source file:gda.device.scannable.ScannableUtils.java

public static String prettyPrintScannable(Scannable obj, int paddingSize) {
    String formattedString = obj.toFormattedString();

    int index = formattedString.indexOf(":");
    if (index == -1) {
        return formattedString;
    }/*from w  w  w  . j  a  va  2s.  c  om*/

    String output = StringUtils.rightPad(formattedString.substring(0, index), paddingSize);
    output += formattedString.substring(index, formattedString.length());
    return output;
}

From source file:edu.cornell.kfs.fp.batch.service.impl.AdvanceDepositServiceImpl.java

private List<String> addRMRAndNTELinesToNotes(AchIncomeFileTransaction achIncomeFileTransaction,
        StringBuilder notes) {/*from   www  .  j  a  va  2s  . co  m*/
    List<String> achNotes = new ArrayList<>();

    boolean header = true;
    Integer lineCount = 1;

    for (AchIncomeFileTransactionOpenItemReference openItemReference : achIncomeFileTransaction
            .getOpenItemReferences()) {
        int leftNoteSize = MAX_NOTE_SIZE - notes.length();
        if ((notes.length() >= MAX_NOTE_SIZE) || (leftNoteSize <= MIN_NOTE_SIZE)) {
            achNotes.add(notes.toString());
            notes = new StringBuilder();
            header = true;
        }
        String type = openItemReference.getType();
        if (CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_REFERENCE_TYPE_CR.equals(type)
                || CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_REFERENCE_TYPE_IV.equals(type)
                || CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_REFERENCE_TYPE_OI.equals(type)) {
            if (header) {
                notes.append(StringUtils.rightPad("LINE",
                        CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_LINE_COLUMN_WIDTH));
                notes.append(StringUtils.rightPad("INVOICE NUMBER",
                        CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_INVOICE_NUMBER_COLUMN_WIDTH));
                notes.append(StringUtils.rightPad("NETAMOUNT PAID",
                        CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_NET_AMOUNT_COLUMN_WIDTH));
                notes.append(StringUtils.rightPad("INVOICE AMOUNT",
                        CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_INVOICE_AMOUNT_COLUMN_WIDTH));
                notes.append("\n");
                header = false;
            }

            notes.append(StringUtils.rightPad(getFormattedAmount("00000", lineCount),
                    CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_LINE_COLUMN_WIDTH));
            notes.append(StringUtils.rightPad(openItemReference.getInvoiceNumber(),
                    CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_INVOICE_NUMBER_COLUMN_WIDTH));
            if (openItemReference.getNetAmount() != null) {
                notes.append(StringUtils.leftPad(
                        getFormattedAmount("##,##,###.00", openItemReference.getNetAmount()),
                        CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_NET_AMOUNT_COLUMN_WIDTH));

            }
            if (openItemReference.getInvoiceAmount() != null) {
                notes.append(StringUtils.leftPad(
                        getFormattedAmount("##,##,###.00", openItemReference.getInvoiceAmount()),
                        CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_INVOICE_AMOUNT_COLUMN_WIDTH));
            }
            notes.append("\n");
            lineCount++;
        }
    }

    List<AchIncomeFileTransactionNote> fileTransactionNotes = achIncomeFileTransaction.getNotes();
    for (AchIncomeFileTransactionNote fileTransactionNote : fileTransactionNotes) {
        if (fileTransactionNote.getType() != null) {
            String nteTxt = fileTransactionNote.getType().toUpperCase() + ": " + fileTransactionNote.getValue();
            int notesPlusNoteTxtLength = nteTxt.length() + notes.length();
            if (notesPlusNoteTxtLength >= MAX_NOTE_SIZE) {
                achNotes.add(notes.toString());
                notes = new StringBuilder();
            }
            notes.append(nteTxt.trim());
            notes.append("\n");
        }

    }
    achNotes.add(notes.toString());

    return achNotes;
}