當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtils.rightPad方法代碼示例

本文整理匯總了Java中org.apache.commons.lang3.StringUtils.rightPad方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.rightPad方法的具體用法?Java StringUtils.rightPad怎麽用?Java StringUtils.rightPad使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang3.StringUtils的用法示例。


在下文中一共展示了StringUtils.rightPad方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deelsOnbekendeDatumAlsStringNaarGetal

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
 * Zet een tekstuele representatie van een deels onbekende datum (formaat = yyyy-MM-dd) om naar een getal dat dezelfde datum representeert.
 * @param datum tekstuele representatie van een deels onbekende datum
 * @return getal representatie van een deels onbekende datum, null indien tekstuele representatie (1) null is, (2) leeg is of (3) een invalide formaat heeft
 */
public static Integer deelsOnbekendeDatumAlsStringNaarGetal(final String datum) {
    try {
        final DeelsOnbekendeDatum deelsOnbekendeDatum = new DeelsOnbekendeDatum(datum);
        if (!deelsOnbekendeDatum.isGeldig()) {
            return null;
        }

        String dateString = deelsOnbekendeDatum.datum.replaceAll("-", "");
        if (dateString.length() < LENGTE_DATUM) {
            dateString = StringUtils.rightPad(dateString, LENGTE_DATUM, NUL_ALS_STRING);
        }
        return Integer.parseInt(dateString);

    } catch (IllegalStateException e) {
        LOG.debug("Fout bij conversie deels onbekende datum naar getal", e);
        return null;
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:24,代碼來源:DatumFormatterUtil.java

示例2: testCheckTopic_TooLongTopic

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Test
public void testCheckTopic_TooLongTopic() {
    String tooLongTopic = StringUtils.rightPad("TooLongTopic", Validators.CHARACTER_MAX_LENGTH + 1, "_");
    assertThat(tooLongTopic.length()).isGreaterThan(Validators.CHARACTER_MAX_LENGTH);
    try {
        Validators.checkTopic(tooLongTopic);
        failBecauseExceptionWasNotThrown(MQClientException.class);
    } catch (MQClientException e) {
        assertThat(e).hasMessageStartingWith("The specified topic is longer than topic max length 255.");
    }
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:12,代碼來源:ValidatorsTest.java

示例3: createF63

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public static String createF63(String s, String bkName){
	if(null == bkName)bkName = "其它";
	StringBuffer sb = new StringBuffer(StringUtils.rightPad(s, 63));
	sb.append(getFixation(bkName, 30));
	sb.append(StringUtils.rightPad("48360000", 30));
	return sb.toString();
}
 
開發者ID:LuJiangLin,項目名稱:TestDemo1-github,代碼行數:8,代碼來源:Util.java

示例4: writeValueLine

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private static void writeValueLine(
    final int[] maxColumnWidth,
    final StringBuilder sb,
    final PsiElement currentValueLine
) {
    if (isImpexValueGroup(currentValueLine.getFirstChild())) {
        sb.append(StringUtils.rightPad("", maxColumnWidth[0] + 1));
    } else {
        final String text = StringUtils.rightPad(
            currentValueLine.getFirstChild().getText().trim(),
            maxColumnWidth[0]
        );
        sb.append(text);
    }
    final PsiElement[] children = currentValueLine.getChildren();

    int i = 1;
    for (final PsiElement element : children) {
        final int length = maxColumnWidth.length - 1;
        if (isFirstFieldValueIsEmpty(element)) {
            sb.append(';').append(' ').append(StringUtils.rightPad("", maxColumnWidth[min(i, length
            )]));
        } else {
            sb
                .append(';')
                .append(' ')
                .append(StringUtils.rightPad(
                    element.getLastChild().getText().trim(),
                    maxColumnWidth[min(i, length)]
                ));
        }
        i++;
    }
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:35,代碼來源:ImpexTableFormatter.java

示例5: datumAlsGetalNaarDatumAlsString

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
 * Zet een getal representatie van een (deels onbekende) datum om naar een tekstuele representatie dat dezelfde datum representeert.
 * @param datum een getal representatie van een (deels onbekende) datum.
 * @return een tekstuele representatie van een (deels onbekende) datum.
 */
public static String datumAlsGetalNaarDatumAlsString(final Integer datum) {
    String resultaat = null;
    if (datum != null) {
        resultaat = "";
        String dateString = String.valueOf(datum);
        // Een datum kan 0 zijn. Dit zie je bij stamgegevens.
        if (dateString.length() < LENGTE_DATUM) {
            dateString = StringUtils.rightPad(
                    dateString.length() < LENGTE_JAAR ? StringUtils.leftPad(dateString, LENGTE_JAAR, NUL_ALS_STRING) : dateString,
                    LENGTE_DATUM,
                    NUL_ALS_STRING);
        }
        final String jaar = dateString.substring(0, LENGTE_JAAR);
        final String maand = dateString.substring(LENGTE_JAAR, LENGTE_JAAR + LENGTE_MAAND);
        final String dag = dateString.substring(LENGTE_JAAR + LENGTE_MAAND, LENGTE_DATUM);
        resultaat += jaar;
        if (!DUBBEL_NUL_ALS_STRING.equals(maand)) {
            resultaat += KOPPELTEKEN;
            resultaat += maand;
            if (!DUBBEL_NUL_ALS_STRING.equals(dag)) {
                resultaat += KOPPELTEKEN;
                resultaat += dag;
            }
        }
    }
    return resultaat;
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:33,代碼來源:DatumFormatterUtil.java

示例6: givenUniqueStringWithPrefixAndLengthSavedToVariable

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Given("unique string with prefix '$prefix' and '$length' length saved to '$name' variable")
public void givenUniqueStringWithPrefixAndLengthSavedToVariable(String prefix, int length, String name) {
    String uniqueString = String.valueOf(UUID.randomUUID()).replace("-",
            "");
    String textElement = StringUtils.rightPad(prefix, length, uniqueString);
    SessionVariablesUtils.save(name, textElement);
}
 
開發者ID:tapack,項目名稱:satisfy,代碼行數:8,代碼來源:DataGenerationSteps.java

示例7: unprotect

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
 * Returns the decrypted plaintext.
 *
 * @param protectedValue the cipher text read from the {@code nifi.properties} file
 * @return the raw value to be used by the application
 * @throws SensitivePropertyProtectionException if there is an error decrypting the cipher text
 */
@Override
public String unprotect(String protectedValue) throws SensitivePropertyProtectionException {
    if (protectedValue == null || protectedValue.trim().length() < MIN_CIPHER_TEXT_LENGTH) {
        throw new IllegalArgumentException("Cannot decrypt a cipher text shorter than " + MIN_CIPHER_TEXT_LENGTH + " chars");
    }

    if (!protectedValue.contains(DELIMITER)) {
        throw new IllegalArgumentException("The cipher text does not contain the delimiter " + DELIMITER + " -- it should be of the form Base64(IV) || Base64(cipherText)");
    }

    protectedValue = protectedValue.trim();

    final String IV_B64 = protectedValue.substring(0, protectedValue.indexOf(DELIMITER));
    byte[] iv = Base64.decode(IV_B64);
    if (iv.length < IV_LENGTH) {
        throw new IllegalArgumentException("The IV (" + iv.length + " bytes) must be at least " + IV_LENGTH + " bytes");
    }

    String CIPHERTEXT_B64 = protectedValue.substring(protectedValue.indexOf(DELIMITER) + 2);

    // Restore the = padding if necessary to reconstitute the GCM MAC check
    if (CIPHERTEXT_B64.length() % 4 != 0) {
        final int paddedLength = CIPHERTEXT_B64.length() + 4 - (CIPHERTEXT_B64.length() % 4);
        CIPHERTEXT_B64 = StringUtils.rightPad(CIPHERTEXT_B64, paddedLength, '=');
    }

    try {
        byte[] cipherBytes = Base64.decode(CIPHERTEXT_B64);

        cipher.init(Cipher.DECRYPT_MODE, this.key, new IvParameterSpec(iv));
        byte[] plainBytes = cipher.doFinal(cipherBytes);
        logger.debug(getName() + " decrypted a sensitive value successfully");
        return new String(plainBytes, StandardCharsets.UTF_8);
    } catch (BadPaddingException | IllegalBlockSizeException | DecoderException | InvalidAlgorithmParameterException | InvalidKeyException e) {
        final String msg = "Error decrypting a protected value";
        logger.error(msg, e);
        throw new SensitivePropertyProtectionException(msg, e);
    }
}
 
開發者ID:apache,項目名稱:nifi-registry,代碼行數:47,代碼來源:AESSensitivePropertyProvider.java

示例8: pad

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public static String pad( String input) {
	return StringUtils.rightPad( input, 25 ) ;
}
 
開發者ID:csap-platform,項目名稱:csap-core,代碼行數:4,代碼來源:CSAP.java

示例9: rightPad

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
 * 文字列の末尾に空白を埋めて指定された長さにする
 *
 * <pre>
 * StringUtils.rightPad(null, *)   = null
 * StringUtils.rightPad("", 3)     = "   "
 * StringUtils.rightPad("bat", 3)  = "bat"
 * StringUtils.rightPad("bat", 5)  = "bat  "
 * StringUtils.rightPad("bat", 1)  = "bat"
 * StringUtils.rightPad("bat", -1) = "bat"
 * </pre>
 *
 * @param str 文字列
 * @param size 文字埋め後の長さ
 * @return 指定した長さになるまで末尾に空白を埋めた文字列
 */
public String rightPad(final String str, final int size) {
	return StringUtils.rightPad(str, size);
}
 
開發者ID:future-architect,項目名稱:uroborosql,代碼行數:20,代碼來源:StringFunction.java


注:本文中的org.apache.commons.lang3.StringUtils.rightPad方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。