当前位置: 首页>>代码示例>>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;未经允许,请勿转载。