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

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

Introduction

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

Prototype

public static String rightPad(final String str, final int size, String padStr) 

Source Link

Document

Right pad a String with a specified String.

The String is padded to the size of size .

 StringUtils.rightPad(null, *, *)      = null StringUtils.rightPad("", 3, "z")      = "zzz" StringUtils.rightPad("bat", 3, "yz")  = "bat" StringUtils.rightPad("bat", 5, "yz")  = "batyz" StringUtils.rightPad("bat", 8, "yz")  = "batyzyzy" StringUtils.rightPad("bat", 1, "yz")  = "bat" StringUtils.rightPad("bat", -1, "yz") = "bat" StringUtils.rightPad("bat", 5, null)  = "bat  " StringUtils.rightPad("bat", 5, "")    = "bat  " 

Usage

From source file:org.apache.phoenix.end2end.index.IndexMaintenanceIT.java

private void verifyResult(ResultSet rs, int i) throws SQLException {
    assertTrue(rs.next());/*from   w  w w . j  a  va2  s. c  o m*/
    assertEquals("VARCHAR" + String.valueOf(i) + "_" + StringUtils.rightPad("CHAR" + String.valueOf(i), 10, ' ')
            + "_A.VARCHAR" + String.valueOf(i) + "_"
            + StringUtils.rightPad("B.CHAR" + String.valueOf(i), 10, ' '), rs.getString(1));
    assertEquals(i * 3, rs.getInt(2));
    Date date = new Date(DateUtil.parseDate("2015-01-01 00:00:00").getTime() + (i) * MILLIS_IN_DAY);
    assertEquals(date, rs.getDate(3));
    assertEquals(date, rs.getDate(4));
    assertEquals(date, rs.getDate(5));
    assertEquals("varchar" + String.valueOf(i), rs.getString(6));
    assertEquals("char" + String.valueOf(i), rs.getString(7));
    assertEquals(i, rs.getInt(8));
    assertEquals(i, rs.getLong(9));
    assertEquals(i * 0.5d, rs.getDouble(10), 0.000001);
    assertEquals(i, rs.getLong(11));
    assertEquals(i, rs.getLong(12));
}

From source file:org.apache.rocketmq.client.ValidatorsTest.java

@Test
public void testCheckTopic_TooLongTopic() {
    String tooLongTopic = StringUtils.rightPad("TooLongTopic", Validators.CHARACTER_MAX_LENGTH + 1, "_");
    assertThat(tooLongTopic.length()).isGreaterThan(Validators.CHARACTER_MAX_LENGTH);
    try {//  w w w  .ja  va2  s  . c  o m
        Validators.checkTopic(tooLongTopic);
        failBecauseExceptionWasNotThrown(MQClientException.class);
    } catch (MQClientException e) {
        assertThat(e).hasMessageStartingWith("The specified topic is longer than topic max length 255.");
    }
}

From source file:org.codice.ddf.catalog.plugin.metacard.backup.storage.filestorage.MetacardBackupFileStorage.java

public Path getMetacardDirectory(String id) {
    if (StringUtils.isEmpty(id)) {
        return null;
    }// ww  w  .ja v a  2s .  c om

    if (id.length() < 6) {
        id = StringUtils.rightPad(id, 6, "0");
    }

    try {
        return Paths.get(outputDirectory, id.substring(0, 3), id.substring(3, 6), id);
    } catch (InvalidPathException e) {
        LOGGER.debug("Unable to create path from id {}", outputDirectory, e);
        return null;
    }
}

From source file:org.iota.wallet.helper.SeedValidator.java

public static String getSeed(String seed) {

    seed = seed.toUpperCase();/* www .  j a va 2s . c o  m*/

    if (seed.length() > SEED_LENGTH_MAX)
        seed = seed.substring(0, SEED_LENGTH_MAX);

    seed = seed.replaceAll("[^A-Z9]", "9");

    seed = StringUtils.rightPad(seed, SEED_LENGTH_MAX, '9');

    return seed;
}

From source file:org.iota.wallet.ui.fragment.NewTransferFragment.java

private String getTaG() {
    if (tagEditText.getText().toString().isEmpty()) {
        return Constants.NEW_TRANSFER_TAG;
    } else if (tagEditText.getText().toString().length() < 27)
        return StringUtils.rightPad(tagEditText.getText().toString(), 27, '9');
    return tagEditText.getText().toString();
}

From source file:org.javabeanstack.util.Strings.java

public static String rightPad(String str, int size, String padStr) {
    return StringUtils.rightPad(str, size, padStr);
}

From source file:org.moe.gradle.remote.AbstractServerTask.java

private int printTaskMarker(PrintStream stream, TermColor color, String message) {
    final String sep = StringUtils.rightPad("", message.length() + 1, "=");
    stream.println("\n" + color.toString() + sep + "\n" + message + "\n" + sep + FM_RES_ALL + "\n");
    stream.flush();/*from w  w w . j  a v  a  2s.c  o  m*/
    return sep.length();
}

From source file:org.moe.gradle.remote.AbstractServerTask.java

private void printTaskEnd(@NotNull PrintStream stream, TermColor color, String message, int sepWidth) {
    final int size = sepWidth - message.length();
    final int size_2 = size / 2;
    stream.println(color.toString() + StringUtils.rightPad("", size_2, "<") + message
            + StringUtils.rightPad("", size - size_2, ">") + FM_RES_ALL);
    stream.flush();//from  w  ww. j  a v a2 s.  c  o m
}

From source file:org.openmrs.module.distrotools.api.impl.DistroToolsServiceImplTest.java

/**
 * Converts a simple identifier to a valid UUID (at least by our standards)
 * @return the UUID//  w  w w  .  j  a va  2 s.com
 */
protected static String uuid(String name) {
    return StringUtils.rightPad(name, 36, 'x');
}

From source file:org.openwms.common.domain.values.Barcode.java

/**
 * Force the Barcode to be aligned to the determined rules regarding padding, alignment.
 * //from w ww . j a v  a2s. com
 * @param val
 *            The old Barcode as String
 * @return The new aligned Barcode
 */
public final String adjustBarcode(String val) {
    if (val == null) {
        throw new IllegalArgumentException("Cannot create a barcode without value");
    }
    if (isPadded()) {
        this.value = (alignment == BARCODE_ALIGN.RIGHT) ? StringUtils.leftPad(val, length, padder)
                : StringUtils.rightPad(val, length, padder);
    } else {
        this.value = val;
    }
    return this.value;
}