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

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

Introduction

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

Prototype

public static String repeat(String str, int repeat) 

Source Link

Document

Repeat a String repeat times to form a new String.

Usage

From source file:net.rllcommunity.plugins.rpgitems.item.RPGItem.java

public List<String> getTooltipLines(String locale) {
    ArrayList<String> output = new ArrayList<String>();
    int width = 150;
    output.add(encodedID + quality.colour + ChatColor.BOLD + displayName);
    int dWidth = getStringWidthBold(ChatColor.stripColor(displayName));
    if (dWidth > width)
        width = dWidth;/*from w  w w .ja v a  2 s.  c  o m*/

    dWidth = getStringWidth(ChatColor.stripColor(hand + "     " + type));
    if (dWidth > width)
        width = dWidth;
    String damageStr = null;
    if (damageMin == 0 && damageMax == 0 && armour != 0) {
        damageStr = armour + "% " + RpgItems.plugin.getConfig().getString("defaults.armour", "Armour");
    } else if (armour == 0 && damageMin == 0 && damageMax == 0) {
        damageStr = null;
    } else if (damageMin == damageMax) {
        damageStr = damageMin + " " + RpgItems.plugin.getConfig().getString("defaults.damage", "Damage");
    } else {
        damageStr = damageMin + "-" + damageMax + " "
                + RpgItems.plugin.getConfig().getString("defaults.damage", "Damage");
    }
    if (damageMin != 0 || damageMax != 0 || armour != 0) {
        dWidth = getStringWidth(damageStr);
        if (dWidth > width)
            width = dWidth;
    }

    for (Power p : powers) {
        dWidth = getStringWidth(ChatColor.stripColor(p.displayText(locale)));
        if (dWidth > width)
            width = dWidth;
    }

    for (String s : description) {
        dWidth = getStringWidth(ChatColor.stripColor(s));
        if (dWidth > width)
            width = dWidth;
    }

    tooltipWidth = width;

    output.add(ChatColor.WHITE + hand
            + StringUtils.repeat(" ", (width - getStringWidth(ChatColor.stripColor(hand + type))) / 4) + type);
    if (damageStr != null) {
        output.add(ChatColor.WHITE + damageStr);
    }

    for (Power p : powers) {
        output.add(p.displayText(locale));
    }
    if (loreText.length() != 0) {
        int cWidth = 0;
        int tWidth = 0;
        StringBuilder out = new StringBuilder();
        StringBuilder temp = new StringBuilder();
        out.append(ChatColor.YELLOW);
        out.append(ChatColor.ITALIC);
        String currentColour = ChatColor.YELLOW.toString();
        String dMsg = "\"" + loreText + "\"";
        for (int i = 0; i < dMsg.length(); i++) {
            char c = dMsg.charAt(i);
            temp.append(c);
            if (c == ChatColor.COLOR_CHAR || c == '&') {
                i += 1;
                temp.append(dMsg.charAt(i));
                currentColour = ChatColor.COLOR_CHAR + "" + dMsg.charAt(i);
                continue;
            }
            if (c == ' ')
                tWidth += 4;
            else
                tWidth += Font.widths[c] + 1;
            if (c == ' ' || i == dMsg.length() - 1) {
                if (cWidth + tWidth > width) {
                    cWidth = 0;
                    cWidth += tWidth;
                    tWidth = 0;
                    output.add(out.toString());
                    out = new StringBuilder();
                    out.append(currentColour);
                    out.append(ChatColor.ITALIC);
                    out.append(temp);
                    temp = new StringBuilder();
                } else {
                    out.append(temp);
                    temp = new StringBuilder();
                    cWidth += tWidth;
                    tWidth = 0;
                }
            }
        }
        out.append(temp);
        output.add(out.toString());
    }

    for (String s : description) {
        output.add(s);
    }
    return output;
}

From source file:adalid.core.Instance.java

private String message(Class<?> type, String name, Object value, int depth, int round) {
    String s1 = StringUtils.repeat(" ", 0 + 4 * depth);
    String s2 = this + "," + depth + "," + round;
    String s3 = type.getSimpleName() + " " + name + "=" + value;
    String s4 = s1 + s2 + " " + s3;
    return s4;/*from w  ww  .jav  a  2s.  com*/
}

From source file:de.codesourcery.jasm16.utils.Misc.java

public static String padRight(String input, int length) {
    final int delta = length - input.length();
    final String result;
    if (delta <= 0) {
        result = input;/*  w w  w .j  a  v a2  s  .co  m*/
    } else {
        result = input + StringUtils.repeat(" ", delta);
    }
    return result;
}

From source file:de.codesourcery.jasm16.utils.Misc.java

public static String padLeft(String input, int length) {
    final int delta = length - input.length();
    final String result;
    if (delta <= 0) {
        result = input;/*from   w w w  . j  a v a2s  .c  om*/
    } else {
        result = StringUtils.repeat(" ", delta) + input;
    }
    return result;
}

From source file:eulermind.importer.LineNode.java

private static String lineTreeToString(LineNode root, int level) {
    String str = StringUtils.repeat(" ", level);
    str += root.toString() + "\n";

    for (int i = 0; i < root.getChildCount(); i++) {
        str += lineTreeToString(root.getChildAt(i), level + 1);
    }//from ww w  .j  a v a2s. co m

    return str;
}

From source file:eulermind.importer.LineNode.java

private static String lineListToString(List<LineNode> list) {
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append("\n");
    for (LineNode node : list) {
        stringBuilder.append(StringUtils.repeat(" ", node.m_indent));
        stringBuilder.append(node.m_trimLine);
        stringBuilder.append("\n");

    }/*from   w  w w.  j a  v a2s  .c  o  m*/

    return stringBuilder.toString();
}

From source file:de.codesourcery.jasm16.utils.Misc.java

public static String toBinaryString(int value, int padToLength, int... separatorsAtBits) {

    final StringBuilder result = new StringBuilder();
    final Set<Integer> separators = new HashSet<Integer>();
    if (!ArrayUtils.isEmpty(separatorsAtBits)) {
        for (int bitPos : separatorsAtBits) {
            separators.add(bitPos);// www . j a v  a2  s . c  om
        }
    }

    for (int i = 15; i >= 0; i--) {
        if ((value & (1 << i)) != 0) {
            result.append("1");
        } else {
            result.append("0");
        }
    }

    final String s = result.toString();
    if (s.length() < padToLength) {
        final int delta = padToLength - s.length();
        return StringUtils.repeat("0", delta) + s;
    }
    if (!separators.isEmpty()) {
        final StringBuilder finalResult = new StringBuilder();
        for (int i = result.length() - 1; i >= 0; i--) {
            finalResult.append(result.charAt(i));
            final int bitOffset = result.length() - 2 - i;
            if (separators.contains(bitOffset)) {
                finalResult.append(" ");
            }
        }
        return finalResult.toString();
    }
    return s;
}

From source file:com.pentaho.di.purge.RepositoryCleanupUtil.java

/**
 * Format strings for command line output
 * /*from w ww . j ava2  s  .  c  o  m*/
 * @param unformattedText
 * @param indentFirstLine
 * @param indentBalance
 * @return
 */
private String indentFormat(String unformattedText, int indentFirstLine, int indentBalance) {
    final int maxWidth = 79;
    String leadLine = WordUtils.wrap(unformattedText, maxWidth - indentFirstLine);
    StringBuilder result = new StringBuilder();
    result.append("\n");
    if (leadLine.indexOf(NEW_LINE) == -1) {
        result.append(NEW_LINE).append(StringUtils.repeat(" ", indentFirstLine)).append(unformattedText);
    } else {
        int lineBreakPoint = leadLine.indexOf(NEW_LINE);
        String indentString = StringUtils.repeat(" ", indentBalance);
        result.append(NEW_LINE).append(StringUtils.repeat(" ", indentFirstLine))
                .append(leadLine.substring(0, lineBreakPoint));
        String formattedText = WordUtils.wrap(unformattedText.substring(lineBreakPoint),
                maxWidth - indentBalance);
        for (String line : formattedText.split(NEW_LINE)) {
            result.append(NEW_LINE).append(indentString).append(line);
        }
    }
    return result.toString();
}

From source file:adalid.core.AbstractExpression.java

@Override
protected String fieldsToString(int n, String key, boolean verbose, boolean fields, boolean maps) {
    String tab = verbose ? StringUtils.repeat(" ", 4) : "";
    String fee = verbose ? StringUtils.repeat(tab, n) : "";
    String faa = " = ";
    String foo = verbose ? EOL : ", ";
    String string = super.fieldsToString(n, key, verbose, fields, maps);
    if (fields || verbose) {
        if (verbose) {
            string += fee + tab + "type" + faa + _dataType + foo;
            string += fee + tab + "parentExpression" + faa + _parentExpression + foo;
        }//  ww w .  jav a 2 s .  c o  m
    }
    return string;
}

From source file:net.bible.service.format.osistohtml.OsisToHtmlSaxHandler.java

private String getPaddingAtBottom() {
    return StringUtils.repeat(HTML.BR, commonHandlerData.getParameters().getNumPaddingBrsAtBottom());
}