本文整理了Java中org.apache.commons.lang3.StringUtils.removeEndIgnoreCase()
方法的一些代码示例,展示了StringUtils.removeEndIgnoreCase()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringUtils.removeEndIgnoreCase()
方法的具体详情如下:
包路径:org.apache.commons.lang3.StringUtils
类名称:StringUtils
方法名:removeEndIgnoreCase
[英]Case insensitive removal of a substring if it is at the end of a source string, otherwise returns the source string.
A null source string will return null. An empty ("") source string will return the empty string. A null search string will return the source string.
StringUtils.removeEndIgnoreCase(null, *) = null
StringUtils.removeEndIgnoreCase("", *) = ""
StringUtils.removeEndIgnoreCase(*, null) =
StringUtils.removeEndIgnoreCase("www.domain.com", ".com.") = "www.domain.com"
StringUtils.removeEndIgnoreCase("www.domain.com", ".com") = "www.domain"
StringUtils.removeEndIgnoreCase("www.domain.com", "domain") = "www.domain.com"
StringUtils.removeEndIgnoreCase("abc", "") = "abc"
StringUtils.removeEndIgnoreCase("www.domain.com", ".COM") = "www.domain")
StringUtils.removeEndIgnoreCase("www.domain.COM", ".com") = "www.domain")
[中]如果子字符串位于源字符串的末尾,则不区分大小写删除该子字符串,否则返回源字符串。
空源字符串将返回空值。空(“”)源字符串将返回空字符串。空搜索字符串将返回源字符串。
StringUtils.removeEndIgnoreCase(null, *) = null
StringUtils.removeEndIgnoreCase("", *) = ""
StringUtils.removeEndIgnoreCase(*, null) =
StringUtils.removeEndIgnoreCase("www.domain.com", ".com.") = "www.domain.com"
StringUtils.removeEndIgnoreCase("www.domain.com", ".com") = "www.domain"
StringUtils.removeEndIgnoreCase("www.domain.com", "domain") = "www.domain.com"
StringUtils.removeEndIgnoreCase("abc", "") = "abc"
StringUtils.removeEndIgnoreCase("www.domain.com", ".COM") = "www.domain")
StringUtils.removeEndIgnoreCase("www.domain.COM", ".com") = "www.domain")
代码示例来源:origin: gocd/gocd
private String trimMegaFromSize(String sizeInMega) {
return StringUtils.removeEndIgnoreCase(sizeInMega, "M");
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testRemoveEndIgnoreCase() {
// StringUtils.removeEndIgnoreCase("", *) = ""
assertNull("removeEndIgnoreCase(null, null)", StringUtils.removeEndIgnoreCase(null, null));
assertNull("removeEndIgnoreCase(null, \"\")", StringUtils.removeEndIgnoreCase(null, ""));
assertNull("removeEndIgnoreCase(null, \"a\")", StringUtils.removeEndIgnoreCase(null, "a"));
// StringUtils.removeEnd(*, null) = *
assertEquals("removeEndIgnoreCase(\"\", null)", StringUtils.removeEndIgnoreCase("", null), "");
assertEquals("removeEndIgnoreCase(\"\", \"\")", StringUtils.removeEndIgnoreCase("", ""), "");
assertEquals("removeEndIgnoreCase(\"\", \"a\")", StringUtils.removeEndIgnoreCase("", "a"), "");
// All others:
assertEquals("removeEndIgnoreCase(\"www.domain.com.\", \".com\")", StringUtils.removeEndIgnoreCase("www.domain.com.", ".com"), "www.domain.com.");
assertEquals("removeEndIgnoreCase(\"www.domain.com\", \".com\")", StringUtils.removeEndIgnoreCase("www.domain.com", ".com"), "www.domain");
assertEquals("removeEndIgnoreCase(\"www.domain\", \".com\")", StringUtils.removeEndIgnoreCase("www.domain", ".com"), "www.domain");
assertEquals("removeEndIgnoreCase(\"domain.com\", \"\")", StringUtils.removeEndIgnoreCase("domain.com", ""), "domain.com");
assertEquals("removeEndIgnoreCase(\"domain.com\", null)", StringUtils.removeEndIgnoreCase("domain.com", null), "domain.com");
// Case insensitive:
assertEquals("removeEndIgnoreCase(\"www.domain.com\", \".COM\")", StringUtils.removeEndIgnoreCase("www.domain.com", ".COM"), "www.domain");
assertEquals("removeEndIgnoreCase(\"www.domain.COM\", \".com\")", StringUtils.removeEndIgnoreCase("www.domain.COM", ".com"), "www.domain");
}
代码示例来源:origin: mulesoft/mule
public void deploy(String resource) throws IOException, URISyntaxException {
int lastSeparator = resource.lastIndexOf(File.separator);
String appName = removeEndIgnoreCase(resource.substring(lastSeparator + 1), JAR_FILE_SUFFIX);
deploy(resource, appName);
}
代码示例来源:origin: mulesoft/mule
@Override
public T deployPackagedArtifact(String zip, Optional<Properties> deploymentProperties) throws DeploymentException {
URI uri;
File artifactZip;
try {
final String artifactName = removeEndIgnoreCase(zip, JAR_FILE_SUFFIX);
artifactZip = new File(artifactDir, zip);
uri = artifactZip.toURI();
return deployPackagedArtifact(uri, artifactName, deploymentProperties);
} catch (DeploymentException e) {
throw e;
} catch (Exception e) {
throw new DeploymentException(createStaticMessage("Failed to deploy from zip: " + zip), e);
}
}
代码示例来源:origin: mulesoft/mule
private File installArtifact(URI artifactAchivedUri) throws IOException {
File artifactLocation;
try {
artifactLocation = installFrom(artifactAchivedUri);
} catch (Throwable t) {
File artifactArchive = new File(artifactAchivedUri);
String artifactName = removeEndIgnoreCase(artifactArchive.getName(), JAR_FILE_SUFFIX);
// error text has been created by the deployer already
logDeploymentFailure(t, artifactName);
addZombieFile(artifactName, artifactArchive);
deploymentListener.onDeploymentFailure(artifactName, t);
throw t;
}
return artifactLocation;
}
代码示例来源:origin: mulesoft/mule
LOGGER.info("deploying artifact: " + uri);
File bundleFile = new File(uri);
final String bundleName = removeEndIgnoreCase(bundleFile.getName(), ZIP_FILE_SUFFIX);
deploymentListener.onDeploymentStart(bundleName);
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-samples
/**
* This method perform the sample work of removing ".html" from the Location header value.
* @param value the original location value
* @return the updated location value
*/
private String getUpdatedLocation(String value) {
return StringUtils.removeEndIgnoreCase(value, ".html");
}
}
代码示例来源:origin: jenkins-infra/update-center2
@VisibleForTesting
public static String simplifyPluginName(String name) {
name = StringUtils.removeStart(name, "Jenkins ");
name = StringUtils.removeStart(name, "Hudson ");
name = StringUtils.removeEndIgnoreCase(name, " for Jenkins");
name = StringUtils.removeEndIgnoreCase(name, " Jenkins Plugin");
name = StringUtils.removeEndIgnoreCase(name, " Plugin");
name = StringUtils.removeEndIgnoreCase(name, " Plug-In");
name = name.replaceAll("[- .!]+$", ""); // remove trailing punctuation e.g. for 'Acme Foo - Jenkins Plugin'
return name;
}
代码示例来源:origin: com.sap.cloud.servicesdk.prov/odata4.web
private String getServiceName(String edmxfileName) {
/*-- Returns the Service Name --*/
if (StringUtils.endsWithIgnoreCase(edmxfileName, v4_default_xml)) {
return StringUtils.removeEndIgnoreCase(edmxfileName, v4_default_xml);
}
return StringUtils.removeEndIgnoreCase(edmxfileName, xml);
}
代码示例来源:origin: com.erudika/para
/**
* Quick and dirty singular to plural conversion.
* @param singul a word
* @return a guess of its plural form
*/
public static String singularToPlural(String singul) {
return StringUtils.isBlank(singul) ? singul :
(singul.endsWith("s") ? singul + "es" :
(singul.endsWith("y") ? StringUtils.removeEndIgnoreCase(singul, "y") + "ies" :
singul + "s"));
}
代码示例来源:origin: Erudika/para
/**
* Quick and dirty singular to plural conversion.
* @param singul a word
* @return a guess of its plural form
*/
public static String singularToPlural(String singul) {
return (StringUtils.isBlank(singul) || singul.endsWith("es") || singul.endsWith("ies")) ? singul :
(singul.endsWith("s") ? singul + "es" :
(singul.endsWith("y") ? StringUtils.removeEndIgnoreCase(singul, "y") + "ies" :
singul + "s"));
}
代码示例来源:origin: danielflower/app-runner
public static String nameFromUrl(String gitUrl) {
String name = StringUtils.removeEndIgnoreCase(StringUtils.removeEnd(gitUrl, "/"), ".git");
name = name.substring(Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')) + 1);
return name;
}
}
代码示例来源:origin: io.wcm.qa/io.wcm.qa.galenium.galenium
@Override
public String getName() {
if (StringUtils.isBlank(name)) {
String simpleName = getClass().getSimpleName();
simpleName = StringUtils.removeStartIgnoreCase(simpleName, CLASS_NAME_PART_DIFFERENCE);
simpleName = StringUtils.removeEndIgnoreCase(simpleName, CLASS_NAME_PART_DIFFERENCE);
return simpleName;
}
return name;
}
代码示例来源:origin: io.wcm.qa/io.wcm.qa.galenium.differences
@Override
public String getName() {
if (StringUtils.isBlank(name)) {
String simpleName = getClass().getSimpleName();
simpleName = StringUtils.removeStartIgnoreCase(simpleName, CLASS_NAME_PART_DIFFERENCE);
simpleName = StringUtils.removeEndIgnoreCase(simpleName, CLASS_NAME_PART_DIFFERENCE);
return simpleName;
}
return name;
}
代码示例来源:origin: dhis2/dhis2-core
/**
* Removes the last occurrence of the word "or" from the given string,
* including potential trailing spaces, case-insensitive.
*
* @param string the string.
* @return the chopped string.
*/
public static String removeLastOr( String string )
{
string = StringUtils.stripEnd( string, " " );
return StringUtils.removeEndIgnoreCase( string, "or" );
}
代码示例来源:origin: dhis2/dhis2-core
/**
* Removes the last occurrence of the word "and" from the given string,
* including potential trailing spaces, case-insensitive.
*
* @param string the string.
* @return the chopped string.
*/
public static String removeLastAnd( String string )
{
string = StringUtils.stripEnd( string, " " );
return StringUtils.removeEndIgnoreCase( string, "and" );
}
代码示例来源:origin: dhis2/dhis2-core
/**
* Removes the last occurrence of the the given string, including potential
* trailing spaces.
*
* @param string the string, without potential trailing spaces.
* @param remove the text to remove.
* @return the chopped string.
*/
public static String removeLast( String string, String remove )
{
string = StringUtils.stripEnd( string, " " );
return StringUtils.removeEndIgnoreCase( string, remove );
}
代码示例来源:origin: rancher/cattle
public static String getDriver(Object obj) {
Map<String, Object> fields = DataUtils.getFields(obj);
for (Map.Entry<String, Object> field : fields.entrySet()) {
if (StringUtils.endsWithIgnoreCase(field.getKey(), MachineConstants.CONFIG_FIELD_SUFFIX) && field.getValue() != null) {
return StringUtils.removeEndIgnoreCase(field.getKey(), MachineConstants.CONFIG_FIELD_SUFFIX);
}
}
return null;
}
代码示例来源:origin: jenkins-infra/update-center2
private String requireGitHubRepoExistence(String url) {
GitHubSource gh = GitHubSource.getInstance();
String shortenedUrl = StringUtils.removeEndIgnoreCase(url, "-plugin");
return gh.isRepoExisting(url) ? url : (gh.isRepoExisting(shortenedUrl) ? shortenedUrl : null);
}
代码示例来源:origin: org.xworker/xworker_core
public static String removeEndIgnoreCase(ActionContext actionContext){
Thing self = actionContext.getObject("self");
String str = (String) self.doAction("getStr", actionContext);
String remove = (String) self.doAction("getRemove", actionContext);
return StringUtils.removeEndIgnoreCase(str, remove);
}
内容来源于网络,如有侵权,请联系作者删除!