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

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

Introduction

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

Prototype

public static String repeat(final char ch, final int repeat) 

Source Link

Document

<p>Returns padding using the specified delimiter repeated to a given length.</p> <pre> StringUtils.repeat('e', 0) = "" StringUtils.repeat('e', 3) = "eee" StringUtils.repeat('e', -2) = "" </pre> <p>Note: this method doesn't not support padding with <a href="http://www.unicode.org/glossary/#supplementary_character">Unicode Supplementary Characters</a> as they require a pair of char s to be represented.

Usage

From source file:org.auraframework.util.javascript.MultiStreamReaderTest.java

public void testReadMultipleStreamsWithSecondBeingLonger() throws Exception {
    assertReadingMultipleStreams(1, "a", StringUtils.repeat("b", 100), "c");
}

From source file:org.auraframework.util.javascript.MultiStreamReaderTest.java

public void testReadMultipleStreamsInChunksWithSecondBeingLonger() throws Exception {
    assertReadingMultipleStreams(3, "a", StringUtils.repeat("b", 100), "c");
}

From source file:org.auraframework.util.javascript.MultiStreamReaderTest.java

public void testReadMultipleStreamsWithThirdBeingLonger() throws Exception {
    assertReadingMultipleStreams(1, "a", "b", StringUtils.repeat("c", 100));
}

From source file:org.auraframework.util.javascript.MultiStreamReaderTest.java

public void testReadMultipleStreamsInChunksWithThirdBeingLonger() throws Exception {
    assertReadingMultipleStreams(3, "a", "b", StringUtils.repeat("c", 100));
}

From source file:org.beryx.viewreka.fxapp.codearea.SimpleCodeArea.java

protected void applyTab() {
    IndexRange selection = getSelection();
    Position startPos = offsetToPosition(selection.getStart(), Bias.Forward);
    if (selection.getLength() == 0) {
        int spaceCount = tabAdvance - startPos.getMinor() % tabAdvance;
        replaceSelection(StringUtils.repeat(' ', spaceCount));
    } else {/*w  ww  .ja  v  a  2s  .c om*/
        int startParagraph = startPos.getMajor();
        Position endPos = offsetToPosition(selection.getEnd(), Bias.Forward);
        int endParagraph = endPos.getMajor();
        String spaces = StringUtils.repeat(' ', tabAdvance);
        for (int pg = startParagraph; pg <= endParagraph; pg++) {
            insertText(position(pg, 0).toOffset(), spaces);
        }
        int newStartOffset = startPos.offsetBy(tabAdvance, Bias.Forward).toOffset();
        int newEndOffset = endPos.offsetBy(tabAdvance, Bias.Forward).toOffset();
        selectRange(newStartOffset, newEndOffset);
    }
}

From source file:org.biofuzztk.ptree.BioFuzzParseTree.java

private String genStr(BioFuzzParseNode node, int level) {
    String s = "";

    List<BioFuzzParseNode> children = null;

    //if ((children = node.getChildren()) != null) {
    if (node.hasChildren()) {
        children = node.getChildren();/*from  w  w  w  .  j  a  v a  2s.  co  m*/
        assert (children != null);
        Iterator<BioFuzzParseNode> iter = children.iterator();

        while (iter.hasNext()) {
            BioFuzzParseNode child = iter.next();
            s += StringUtils.repeat(" ", level) + "|--" + child.toString();
            s += "[AttackTag: " + child.getAtagName() + "(" + child.getAtagType().toString() + ")" + "("
                    + child.getVal() + ")]\n" + genStr(child, level + 1);
        }
    } else {
        if (this.tokLst != null) {
            s += StringUtils.repeat(" ", level) + "|--" + node.toString();

            s += "[Tok: " + this.tokLst.get(node.getTokIdx()) + "(" + node.getAtagType().toString() + ")" + "("
                    + node.getVal() + ")]\n";
        }
    }
    //}
    return s;
}

From source file:org.blockartistry.mod.ThermalRecycling.util.Diagnostics.java

public void dumpItemStack(final Logger log, final String title, final ItemStack... items) {

    log.info("");
    log.info(title);//from w  ww . j  a va 2  s.co m
    log.info(StringUtils.repeat('-', 32));

    if (items == null || items.length == 0) {
        log.info("No items in list");
        return;
    }

    for (final ItemStack stack : items) {
        log.info(String.format("%s (%s)", ItemStackHelper.resolveName(stack), stack.toString()));
    }
    log.info(StringUtils.repeat('-', 32));
    log.info(String.format("Total: %d item stacks", items.length));
}

From source file:org.blockartistry.mod.ThermalRecycling.util.ItemStackHelper.java

public void dumpItemStack(final Logger log, final String title, final ItemStack... items) {

    log.info("");
    log.info(title);//www .  ja v  a  2s  . co  m
    log.info(StringUtils.repeat('-', 32));

    if (items == null || items.length == 0) {
        log.info("No items in list");
        return;
    }

    for (final ItemStack stack : items) {
        log.info(String.format("%s (%s)", resolveName(stack), stack.toString()));
    }
    log.info(StringUtils.repeat('-', 32));
    log.info(String.format("Total: %d item stacks", items.length));
}

From source file:org.blocks4j.reconf.client.setup.DatabaseURL.java

private static String getSecretKey(int keySize) {
    String key = LocalHostname.getName();
    int missing = keySize - StringUtils.length(key);
    if (missing == 0) {
        return key;
    }//www  .  j av a2 s . co m
    if (missing < 0) {
        return StringUtils.substring(key, 0, keySize);
    }
    return key + StringUtils.repeat("#", missing);
}

From source file:org.bug4j.client.Bug4jTest.java

@Test
public void testLongTitle() throws Exception {
    Bug4jAgent.report(StringUtils.repeat("This_is_a_long_title", 100), (Throwable) null);
    Bug4jAgent.shutdown();/*w w w. j av  a 2 s  .c o  m*/
}