本文整理匯總了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);
}