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:com.github.capone.protocol.crypto.VerifyKeyTest.java

@Before
public void setUp() throws VerifyKey.InvalidKeyException {
    key = VerifyKey.fromString(StringUtils.repeat("0", SigningKey.BYTES * 2));
}

From source file:com.github.capone.protocol.crypto.SigningKeyTest.java

@Before
public void setUp() throws SigningKey.InvalidSeedException {
    key = SigningKey.fromSeed(StringUtils.repeat("0", SigningKey.BYTES * 2));
}

From source file:com.tesora.dve.common.PatternLayoutWithHeader.java

@Override
public String getHeader() {
    Runtime runtime = Runtime.getRuntime();

    StringBuffer header = new StringBuffer();
    header.append(StringUtils.repeat("-", 80));
    header.append("\nLog Started : ").append(new Date().toString());
    header.append("\nBuild Info  : ").append(PELogUtils.getBuildVersionString(true));
    header.append("\nMemory      : max=").append(String.format("%,d", runtime.maxMemory())).append(" total=")
            .append(String.format("%,d", runtime.totalMemory())).append(" free=")
            .append(String.format("%,d", runtime.freeMemory()));
    header.append("\nProcessors  : ").append(runtime.availableProcessors());
    try {// w  w w  .  j av a2s.c o m
        header.append("\nHost        : ").append(InetAddress.getLocalHost());
    } catch (UnknownHostException e) {
        header.append("\nHost        : unknown");
    }
    header.append("\n");
    return header.toString();
}

From source file:dmh.swing.huxley.action.InsertHeadingAction.java

@Override
public int manipulateText(Document document, int start, int end) {
    try {//from  w  w w  .ja v  a2s.c om
        final int offset = start;
        final int length = end - start;

        // Extract the selected text.
        String title = StringUtils.trimToEmpty(document.getText(offset, length));
        document.remove(offset, length);

        // Add the header.
        String bar = StringUtils.repeat(token, 40);
        String insertText = "\n " + title + "\n" + bar + "\n";
        document.insertString(offset, insertText, null);

        // Return the caret position.
        return start + ("".equals(title) ? 2 : insertText.length());
    } catch (BadLocationException e) {
        // This indicates a programming error.
        throw new RuntimeException(e);
    }
}

From source file:com.agapsys.utils.console.printer.TableTest.java

@Test
public void printTable() {
    TableBuilder tb = new TableBuilder().addCol(2).addCol(1).addCol(11).addCol(1).addCol(40).addCol(1)
            .addCol(3);//from w ww  . ja  v a 2 s  .  co m

    RowBuilder lineBorder = new RowBuilder(tb).addCell("--").addCell("+").addCell("-----------").addCell("+")
            .addCell(StringUtils.repeat("-", 40)).addCell("+").addCell("---");

    tb.addRow().addCell(ConsoleColor.CYAN, "ID").addCell().addCell(ConsoleColor.CYAN, "DATE").addCell()
            .addCell(ConsoleColor.CYAN, "NAME").addCell().addCell(ConsoleColor.CYAN, "G").endRow()
            .addRow(lineBorder).addRow().addCell("1").addCell().addCell("abcd-ef-gh ").addCell()
            .addCell("aaaaa bbbbbb cccccc dd eeeeeeee f gggg hhhh i jjjjj kk lll mm nnnn").addCell()
            .addCell(CellAlignment.RIGHT, ConsoleColor.WHITE, ConsoleColor.RED, "f").endRow().addRow(lineBorder)
            .addRow().addCell("2").addCell().addCell("ijkl-mn-op ").addCell()
            .addCell("ooooooo pppp qqqqqq rr ssssssss").addCell().addCell(ConsoleColor.LIGHT_YELLOW, "m")
            .endRow().addRow(lineBorder).addRow().addCell("3").addCell().addCell("qrst-uv-wx ").addCell()
            .addCell("tttttt uuuuuu vv wwwwwwww").addCell().addCell(ConsoleColor.RED, "m").endRow();

    StringBuilder expected = new StringBuilder();
    expected.append(
            "\033[49;36mID\033[0m\033[49;39m \033[0m\033[49;36mDATE       \033[0m\033[49;39m \033[0m\033[49;36mNAME                                    \033[0m\033[49;39m \033[0m\033[49;36mG  \033[0m\n");
    expected.append(
            "\033[49;39m--\033[0m\033[49;39m+\033[0m\033[49;39m-----------\033[0m\033[49;39m+\033[0m\033[49;39m----------------------------------------\033[0m\033[49;39m+\033[0m\033[49;39m---\033[0m\n");
    expected.append(
            "\033[49;39m1 \033[0m\033[49;39m \033[0m\033[49;39mabcd-ef-gh \033[0m\033[49;39m \033[0m\033[49;39maaaaa bbbbbb cccccc dd eeeeeeee f gggg  \033[0m\033[49;39m \033[0m\033[41;97m  f\033[0m\n");
    expected.append(
            "\033[49;39m  \033[0m\033[49;39m \033[0m\033[49;39m           \033[0m\033[49;39m \033[0m\033[49;39mhhhh i jjjjj kk lll mm nnnn             \033[0m\033[49;39m \033[0m\033[49;39m   \033[0m\n");
    expected.append(
            "\033[49;39m--\033[0m\033[49;39m+\033[0m\033[49;39m-----------\033[0m\033[49;39m+\033[0m\033[49;39m----------------------------------------\033[0m\033[49;39m+\033[0m\033[49;39m---\033[0m\n");
    expected.append(
            "\033[49;39m2 \033[0m\033[49;39m \033[0m\033[49;39mijkl-mn-op \033[0m\033[49;39m \033[0m\033[49;39mooooooo pppp qqqqqq rr ssssssss         \033[0m\033[49;39m \033[0m\033[49;93mm  \033[0m\n");
    expected.append(
            "\033[49;39m--\033[0m\033[49;39m+\033[0m\033[49;39m-----------\033[0m\033[49;39m+\033[0m\033[49;39m----------------------------------------\033[0m\033[49;39m+\033[0m\033[49;39m---\033[0m\n");
    expected.append(
            "\033[49;39m3 \033[0m\033[49;39m \033[0m\033[49;39mqrst-uv-wx \033[0m\033[49;39m \033[0m\033[49;39mtttttt uuuuuu vv wwwwwwww               \033[0m\033[49;39m \033[0m\033[49;31mm  \033[0m");

    Assert.assertEquals(expected.toString(), tb.toString());
    ConsolePrinter.println(tb.toString());
}

From source file:dmh.kuebiko.view.NotePanelTest.java

@Test
public void multipleUpdateTest() {
    final String magicString = "!";

    final NoteManager noteMngr = new NoteManager(TestHelper.newDummyNoteDao());
    final Note note = noteMngr.getNoteAt(0);
    final String initialNoteText = note.getText();

    assertFalse(initialNoteText.contains(magicString), "Initial note text should not contain magic string.");

    final NotePanel notePanel = new NotePanel();
    final HuxleyUiManager huxley = notePanel.getHuxleyUiManager();
    notePanel.setNote(note);/*from  w  w  w.j  a  v a  2s  .c o  m*/

    for (int i = 0; i < 5; i++) {
        final String cumulativeMagicString = StringUtils.repeat(magicString, i + 1);

        assertFalse(huxley.getText().contains(cumulativeMagicString),
                "UI text should not yet contain cumulative magic string. " + i);

        huxley.setText(initialNoteText + cumulativeMagicString);

        assertTrue(huxley.getText().contains(cumulativeMagicString),
                "UI text should contain cumulative magic string. " + i);

        assertFalse(note.getText().contains(cumulativeMagicString),
                "Changed note text should not yet contain cumulative magic string. " + i);

        notePanel.syncNote();

        assertTrue(note.getText().contains(cumulativeMagicString),
                "Changed note text should contain cumulative magic string. " + i);

        noteMngr.saveAll();

        assertTrue(note.getText().contains(cumulativeMagicString),
                "Changed note text should still contain cumulative magic string. " + i);

        Note refreshedNote = noteMngr.getNoteAt(0);
        Assert.assertEquals(refreshedNote.getTitle(), note.getTitle(), "Note title should not change.");
        assertTrue(refreshedNote.getText().contains(cumulativeMagicString),
                "Refreshed note text should contain cumulative magic string. " + i);
    }
}

From source file:at.ac.tuwien.big.momot.problem.unit.parameter.increment.IncrementalStringValue.java

public IncrementalStringValue(final int startLength) {
    this("", StringUtils.repeat("a", startLength), "", StringMode.LOWER);
}

From source file:com.github.capone.protocol.crypto.VerifyKeyTest.java

@Test
public void keyFromValidStringSucceeds() throws VerifyKey.InvalidKeyException {
    key = VerifyKey.fromString(StringUtils.repeat("a", SigningKey.BYTES * 2));
    Assert.assertEquals(StringUtils.repeat("a", SigningKey.BYTES * 2), key.toString());
}

From source file:com.github.capone.protocol.crypto.SigningKeyTest.java

@Test
public void signingKeyFromValidSeedSucceeds() throws SigningKey.InvalidSeedException {
    key = SigningKey.fromSeed(StringUtils.repeat("a", SigningKey.BYTES * 2));
    Assert.assertEquals(StringUtils.repeat("a", SigningKey.BYTES * 2), key.toString());
}

From source file:io.mindmaps.graql.internal.parser.SyntaxError.java

@Override
public String toString() {
    // Error message appearance:
    ////from w  w w  .  ja  v  a2 s  . co  m
    // syntax error at line 1:
    // match $
    //       ^
    // blah blah antlr blah
    String pointer = StringUtils.repeat(" ", charPositionInLine) + "^";
    return ErrorMessage.SYNTAX_ERROR.getMessage(line, queryLine, pointer, msg);
}