本文整理匯總了Java中org.apache.commons.lang3.StringUtils.substringAfterLast方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.substringAfterLast方法的具體用法?Java StringUtils.substringAfterLast怎麽用?Java StringUtils.substringAfterLast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.substringAfterLast方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendSlackImageResponse
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private void sendSlackImageResponse(ObjectNode json, String s3Key) {
try {
ObjectMapper mapper = new ObjectMapper();
ObjectNode message = mapper.createObjectNode();
ArrayNode attachments = mapper.createArrayNode();
ObjectNode attachment = mapper.createObjectNode();
String emoji = json.get("text").asText();
if (UrlValidator.getInstance().isValid(emoji)) {
attachment.put("title_link", emoji);
emoji = StringUtils.substringAfterLast(emoji, "/");
}
String username = json.get("user_name").asText();
String responseUrl = json.get("response_url").asText();
String slackChannelId = json.get("channel_id").asText();
String imageUrl = String.format("https://s3.amazonaws.com/%s/%s", PROPERTIES.getProperty(S3_BUCKET_NAME), s3Key);
message.put("response_type", "in_channel");
message.put("channel_id", slackChannelId);
attachment.put("title", resolveMessage("slackImageResponse", emoji, username));
attachment.put("fallback", resolveMessage("approximated", emoji));
attachment.put("image_url", imageUrl);
attachments.add(attachment);
message.set("attachments", attachments);
HttpClient client = HttpClientBuilder.create().build();
HttpPost slackResponseReq = new HttpPost(responseUrl);
slackResponseReq.setEntity(new StringEntity(mapper.writeValueAsString(message), ContentType.APPLICATION_JSON));
HttpResponse slackResponse = client.execute(slackResponseReq);
int status = slackResponse.getStatusLine().getStatusCode();
LOG.info("Got {} status from Slack API after sending approximation to response url.", status);
} catch (UnsupportedOperationException | IOException e) {
LOG.error("Exception occured when sending Slack response", e);
}
}
示例2: parse
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* Parses the specified schedule into {@link #period execution period}.
*
* @param schedule
* the specified schedule
*/
private void parse(final String schedule) {
final int num = Integer.valueOf(StringUtils.substringBetween(schedule, " ", " "));
final String timeUnit = StringUtils.substringAfterLast(schedule, " ");
logger.trace("Parsed a cron job [schedule={}]: [num={}, timeUnit={}, description={}], ",
new Object[] { schedule, num, timeUnit, description });
if ("hours".equals(timeUnit)) {
period = num * SIXTY * SIXTY * THOUSAND;
} else if ("minutes".equals(timeUnit)) {
period = num * SIXTY * THOUSAND;
} else if ("seconds".equals(timeUnit)) {
period = num * THOUSAND;
}
}
示例3: getNamespace
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
public String getNamespace() {
String fileName = getBlobPath();
if (fileName.contains("/"))
fileName = StringUtils.substringAfterLast(fileName, "/");
return fileName;
}
示例4: isSet
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* Says if a class must be in debug mode
*
* @param clazz
* the class to analyze if debug must be on
* @return true if the class must be on debug mode, else false
*/
public static boolean isSet(Class<?> clazz) {
load();
String className = clazz.getName();
String rawClassName = StringUtils.substringAfterLast(className, ".");
if (CLASSES_TO_DEBUG.contains(className)
|| CLASSES_TO_DEBUG.contains(rawClassName)) {
return true;
} else {
return false;
}
}
示例5: isDuplicatedDirectory
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* Java MacOS workaround to detect the duplicated entry at the end of the path
*
* @param file the file to check
* @return whether the directory at the end of the path is duplicated
*/
private boolean isDuplicatedDirectory(File file) {
String path = file.getAbsolutePath();
log.debug("Path: {}", path);
String lastDir = File.separator+StringUtils.substringAfterLast(path, File.separator);
log.debug("Last dir: {}", lastDir);
String pathWithoutLastDir = StringUtils.substringBeforeLast(path, lastDir);
log.debug("Path without Last dir: {}", pathWithoutLastDir);
boolean eval = lastDir.length()>1 && pathWithoutLastDir.endsWith(lastDir);
log.debug("Eval {}", eval);
return eval;
}
示例6: render
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
public Component render(String componentId) {
String fileName = getBlobPath();
if (fileName.contains("/"))
fileName = StringUtils.substringAfterLast(fileName, "/");
return new HighlightableLabel(componentId, fileName, matchRange);
}
示例7: enumValue
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private String enumValue(String input) {
if(StringUtils.contains(input, '.')) {
return StringUtils.substringAfterLast(input, ".");
}
return input;
}
示例8: convert
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
public String convert(Tenant tenant, Event event) {
Group group = event.getGroup();
if (group == null) {
return null;
}
String convertedClassId = null;
String groupId = null;
String groupType = group.getType();
if (isCourseSection(groupType)) {
groupId = group.getId();
}
else {
groupId = findCourseSectionId(group.getSubOrganizationOf());
}
if (StringUtils.isBlank(groupId)) {
return null;
}
if (StringUtils.startsWith(groupId, "http")) {
Map<String, String> tenantMetadata = tenant.getMetadata();
if (tenantMetadata != null && !tenantMetadata.isEmpty()) {
String tenantClassPrefix = tenantMetadata.get(Vocabulary.TENANT_CLASS_PREFIX);
if (StringUtils.isNotBlank(tenantClassPrefix)) {
String classIdAfterPrefix = StringUtils.substringAfter(groupId, tenantClassPrefix);
if (StringUtils.startsWith(classIdAfterPrefix, "/")) {
convertedClassId = StringUtils.substringAfter(classIdAfterPrefix, "/");
}
else {
convertedClassId = classIdAfterPrefix;
}
}
}
else {
convertedClassId = StringUtils.substringAfterLast(groupId, "/");
}
}
else {
convertedClassId = groupId;
}
return convertedClassId;
}
示例9: getTableNameFromDmlStatement
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* Returns the table name in use type from a DML SQL order.
*
* @param statementType
* the statement type (INSERT, ...)
* @param sql
* the sql order
*
* @return the table name in use (the first one in a <code>SELECT</code>
* statement) for a DML statement. Returns null if statement is not
* DML.
*/
private String getTableNameFromDmlStatement(String statementType, String sql)
throws IllegalArgumentException {
// Extract the first order
String statementTypeUpper = statementType.toUpperCase();
String sqlUpper = sql.toUpperCase();
// Extract the table depending on the ordOer
sqlUpper = StringUtils.substringAfter(sqlUpper, statementTypeUpper);
sqlUpper = sqlUpper.trim();
String table = null;
if (statementTypeUpper.equals(INSERT)) {
sqlUpper = StringUtils.substringAfter(sqlUpper, "INTO ");
sqlUpper = sqlUpper.trim();
table = StringUtils.substringBefore(sqlUpper, " ");
} else if (statementTypeUpper.equals(SELECT)
|| statementTypeUpper.equals(DELETE)) {
sqlUpper = StringUtils.substringAfter(sqlUpper, "FROM ");
sqlUpper = sqlUpper.trim();
// Remove commas in the statement and replace with blanks in case we
// have
// a join: "TABLE," ==> "TABLE "
sqlUpper = sqlUpper.replaceAll(",", " ");
table = StringUtils.substringBefore(sqlUpper, BLANK);
} else if (statementTypeUpper.equals(UPDATE)) {
// debug("sqlLocal :" + sqlUpper + ":");
table = StringUtils.substringBefore(sqlUpper, BLANK);
} else {
return null; // No table
}
if (table != null) {
table = table.trim();
}
// Return the part after last dot
if (table.contains(".")) {
table = StringUtils.substringAfterLast(table, ".");
}
table = table.replace("\'", "");
table = table.replace("\"", "");
return table;
}
示例10: fromString
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public static Submodule fromString(String str) {
String url = StringUtils.substringBeforeLast(str, SEPARATOR);
String commitHash = StringUtils.substringAfterLast(str, SEPARATOR);
return new Submodule(url, commitHash);
}
示例11: ShowQrcodeRequest
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 構造函數
* @param ticket 獲取的二維碼ticket,憑借此ticket可以在有效時間內換取二維碼
* @param fullDownPath 下載文件路徑+文件名
*/
public ShowQrcodeRequest(String ticket, String fullDownPath) {
this.ticket = ticket;
this.fileName = StringUtils.substringAfterLast(fullDownPath, File.separator);
this.filePath = StringUtils.substringBeforeLast(fullDownPath, File.separator) + File.separator;
}
示例12: PerpetualMediaGetRequest
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 構造器
* @param mediaId 媒體文件ID
* @param fullDownPath 下載文件路徑+文件名
*/
public PerpetualMediaGetRequest(String mediaId, String fullDownPath) {
this.media_id = mediaId;
this.fileName = StringUtils.substringAfterLast(fullDownPath, File.separator);
this.filePath = StringUtils.substringBeforeLast(fullDownPath, File.separator) + File.separator;
}
示例13: NewsInnerImgAddRequest
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 構造器
* @param fullFilePath 媒體文件路徑+文件名
*/
public NewsInnerImgAddRequest(String fullFilePath) {
this.fileName = StringUtils.substringAfterLast(fullFilePath, File.separator);
this.filePath = StringUtils.substringBeforeLast(fullFilePath, File.separator) + File.separator;
}
示例14: TempMaterialGetRequest
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 構造器
* @param mediaId 媒體文件ID
* @param fullDownPath 下載文件路徑+文件名
*/
public TempMaterialGetRequest(String mediaId, String fullDownPath) {
this.media_id = mediaId;
this.fileName = StringUtils.substringAfterLast(fullDownPath, File.separator);
this.filePath = StringUtils.substringBeforeLast(fullDownPath, File.separator) + File.separator;
}
示例15: KfUploadHeadimgRequest
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
/**
* 構造函數
* @param fullFilePath 圖像文件路徑+文件名
* @param kfAccount 客戶帳號
*/
public KfUploadHeadimgRequest(String kfAccount, String fullFilePath) {
this.kf_account = kfAccount;
this.fileName = StringUtils.substringAfterLast(fullFilePath, File.separator);
this.filePath = StringUtils.substringBeforeLast(fullFilePath, File.separator) + File.separator;
}