本文整理汇总了Java中org.apache.commons.lang3.StringUtils.right方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.right方法的具体用法?Java StringUtils.right怎么用?Java StringUtils.right使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.right方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeTicketId
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Remove ticket id from the log message.
*
* @param msg the message
* @return the modified message with tgt id removed
*/
private String removeTicketId(final String msg) {
String modifiedMessage = msg;
if (StringUtils.isNotBlank(msg)) {
final Matcher matcher = TICKET_ID_PATTERN.matcher(msg);
while (matcher.find()) {
final String match = matcher.group();
final String newId = matcher.group(1) + '-'
+ StringUtils.repeat("*", match.length() - VISIBLE_ID_TAIL_LENGTH)
+ StringUtils.right(match, VISIBLE_ID_TAIL_LENGTH);
modifiedMessage = modifiedMessage.replaceAll(match, newId);
}
}
return modifiedMessage;
}
示例2: sanitize
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Remove ticket id from the message.
*
* @param msg the message
* @return the modified message with tgt id removed
*/
public static String sanitize(final String msg) {
String modifiedMessage = msg;
if (StringUtils.isNotBlank(msg) && !Boolean.getBoolean("CAS_TICKET_ID_SANITIZE_SKIP")) {
final Matcher matcher = TICKET_ID_PATTERN.matcher(msg);
while (matcher.find()) {
final String match = matcher.group();
final String newId = matcher.group(1) + '-'
+ StringUtils.repeat("*", match.length() - VISIBLE_TAIL_LENGTH)
+ StringUtils.right(match, VISIBLE_TAIL_LENGTH);
modifiedMessage = modifiedMessage.replaceAll(match, newId);
}
}
return modifiedMessage;
}
示例3: generateRid
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Generates request id based on UID and SHA-256.
*
* @return request identity
*/
public static String generateRid() {
byte[] encode = Base64.getEncoder().encode(DigestUtils.sha256(UUID.randomUUID().toString()));
try {
String rid = new String(encode, StandardCharsets.UTF_8.name());
rid = StringUtils.replaceChars(rid, "+/=", "");
return StringUtils.right(rid, RID_LENGTH);
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}
示例4: right
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* 文字列の最後から指定した文字数の文字列を取得する
*
* <pre>
* StringUtils.right(null, *) = null
* StringUtils.right(*, -ve) = ""
* StringUtils.right("", *) = ""
* StringUtils.right("abc", 0) = ""
* StringUtils.right("abc", 2) = "bc"
* StringUtils.right("abc", 4) = "abc"
* </pre>
*
* @param str 対象文字列
* @param len 文字数
* @return 文字列の最後から文字数で指定した長さの文字列
*/
public String right(final String str, final int len) {
return StringUtils.right(str, len);
}