org.apache.commons.lang3.StringUtils.endsWithIgnoreCase()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(11.6k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中org.apache.commons.lang3.StringUtils.endsWithIgnoreCase()方法的一些代码示例,展示了StringUtils.endsWithIgnoreCase()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringUtils.endsWithIgnoreCase()方法的具体详情如下:
包路径:org.apache.commons.lang3.StringUtils
类名称:StringUtils
方法名:endsWithIgnoreCase

StringUtils.endsWithIgnoreCase介绍

[英]Case insensitive check if a CharSequence ends with a specified suffix.

nulls are handled without exceptions. Two nullreferences are considered to be equal. The comparison is case insensitive.

StringUtils.endsWithIgnoreCase(null, null)      = true 
StringUtils.endsWithIgnoreCase(null, "def")     = false 
StringUtils.endsWithIgnoreCase("abcdef", null)  = false 
StringUtils.endsWithIgnoreCase("abcdef", "def") = true 
StringUtils.endsWithIgnoreCase("ABCDEF", "def") = true 
StringUtils.endsWithIgnoreCase("ABCDEF", "cde") = false

[中]不区分大小写检查字符序列是否以指定的后缀结尾。
空值的处理没有异常。两个空引用被认为是相等的。比较不区分大小写。

StringUtils.endsWithIgnoreCase(null, null)      = true 
StringUtils.endsWithIgnoreCase(null, "def")     = false 
StringUtils.endsWithIgnoreCase("abcdef", null)  = false 
StringUtils.endsWithIgnoreCase("abcdef", "def") = true 
StringUtils.endsWithIgnoreCase("ABCDEF", "def") = true 
StringUtils.endsWithIgnoreCase("ABCDEF", "cde") = false

代码示例

代码示例来源:origin: gocd/gocd

public boolean isSame(String scope) {
  return StringUtils.endsWithIgnoreCase(this.scope, scope);
}

代码示例来源:origin: rest-assured/rest-assured

public static Parser fromContentType(String contentType) {
    if(contentType == null) {
      return null;
    }
    contentType = ContentTypeExtractor.getContentTypeWithoutCharset(contentType.toLowerCase());
    final Parser foundParser;
    if(contains(XML.contentTypes, contentType) || endsWithIgnoreCase(contentType, PLUS_XML)) {
      foundParser = XML;
    } else if(contains(JSON.contentTypes, contentType) || endsWithIgnoreCase(contentType, PLUS_JSON)) {
      foundParser = JSON;
    } else if(contains(TEXT.contentTypes, contentType)) {
      foundParser = TEXT;
    } else if(contains(HTML.contentTypes, contentType) || endsWithIgnoreCase(contentType, PLUS_HTML)) {
      foundParser = HTML;
    } else {
      foundParser = null;
    }
    return foundParser;
  }
}

代码示例来源:origin: org.apache.commons/commons-lang3

return str;
if (endsWithIgnoreCase(str, remove)) {
  return str.substring(0, str.length() - remove.length());

代码示例来源:origin: rest-assured/rest-assured

public static ContentType fromContentType(String contentType) {
  if (contentType == null) {
    return null;
  }
  contentType = ContentTypeExtractor.getContentTypeWithoutCharset(contentType.toLowerCase());
  final ContentType foundContentType;
  if (contains(XML.ctStrings, contentType) || endsWithIgnoreCase(contentType, PLUS_XML)) {
    foundContentType = XML;
  } else if (contains(JSON.ctStrings, contentType) || endsWithIgnoreCase(contentType, PLUS_JSON)) {
    foundContentType = JSON;
  } else if (contains(TEXT.ctStrings, contentType)) {
    foundContentType = TEXT;
  } else if (contains(HTML.ctStrings, contentType) || endsWithIgnoreCase(contentType, PLUS_HTML)) {
    foundContentType = HTML;
  } else if (contains(URLENC.ctStrings, contentType)) {
    foundContentType = URLENC;
  } else if (contains(BINARY.ctStrings, contentType)) {
    foundContentType = BINARY;
  } else if (contains(ANY.ctStrings, contentType)) {
    foundContentType = ANY;
  } else {
    foundContentType = null;
  }
  return foundContentType;
}

代码示例来源:origin: alibaba/jvm-sandbox

foundModuleJarFiles.addAll(FileUtils.listFiles(new File(path), new String[]{"jar"}, false));
} else {
  if(StringUtils.endsWithIgnoreCase(fileOfPath.getPath(), ".jar")) {
    foundModuleJarFiles.add(fileOfPath);

代码示例来源:origin: Graylog2/graylog2-server

@Override
public Boolean evaluate(FunctionArgs args, EvaluationContext context) {
  final String value = valueParam.required(args, context);
  final String suffix = suffixParam.required(args, context);
  final boolean ignoreCase = ignoreCaseParam.optional(args, context).orElse(false);
  if (ignoreCase) {
    return StringUtils.endsWithIgnoreCase(value, suffix);
  } else {
    return StringUtils.endsWith(value, suffix);
  }
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Test StringUtils.endsWithIgnoreCase()
 */
@Test
public void testEndsWithIgnoreCase() {
  assertTrue("endsWithIgnoreCase(null, null)",    StringUtils.endsWithIgnoreCase(null, null));
  assertFalse("endsWithIgnoreCase(FOOBAR, null)", StringUtils.endsWithIgnoreCase(FOOBAR, null));
  assertFalse("endsWithIgnoreCase(null, FOO)",    StringUtils.endsWithIgnoreCase(null, FOO));
  assertTrue("endsWithIgnoreCase(FOOBAR, \"\")",  StringUtils.endsWithIgnoreCase(FOOBAR, ""));
  assertFalse("endsWithIgnoreCase(foobar, foo)", StringUtils.endsWithIgnoreCase(foobar, foo));
  assertFalse("endsWithIgnoreCase(FOOBAR, FOO)", StringUtils.endsWithIgnoreCase(FOOBAR, FOO));
  assertFalse("endsWithIgnoreCase(foobar, FOO)", StringUtils.endsWithIgnoreCase(foobar, FOO));
  assertFalse("endsWithIgnoreCase(FOOBAR, foo)", StringUtils.endsWithIgnoreCase(FOOBAR, foo));
  assertFalse("endsWithIgnoreCase(foo, foobar)", StringUtils.endsWithIgnoreCase(foo, foobar));
  assertFalse("endsWithIgnoreCase(foo, foobar)", StringUtils.endsWithIgnoreCase(bar, foobar));
  assertTrue("endsWithIgnoreCase(foobar, bar)", StringUtils.endsWithIgnoreCase(foobar, bar));
  assertTrue("endsWithIgnoreCase(FOOBAR, BAR)", StringUtils.endsWithIgnoreCase(FOOBAR, BAR));
  assertTrue("endsWithIgnoreCase(foobar, BAR)", StringUtils.endsWithIgnoreCase(foobar, BAR));
  assertTrue("endsWithIgnoreCase(FOOBAR, bar)", StringUtils.endsWithIgnoreCase(FOOBAR, bar));
  // javadoc
  assertTrue(StringUtils.endsWithIgnoreCase("abcdef", "def"));
  assertTrue(StringUtils.endsWithIgnoreCase("ABCDEF", "def"));
  assertFalse(StringUtils.endsWithIgnoreCase("ABCDEF", "cde"));
  // "alpha,beta,gamma,delta".endsWith("DELTA")
  assertTrue("endsWith(\u03B1\u03B2\u03B3\u03B4, \u0394)",
      StringUtils.endsWithIgnoreCase("\u03B1\u03B2\u03B3\u03B4", "\u0394"));
  // "alpha,beta,gamma,delta".endsWith("GAMMA")
  assertFalse("endsWith(\u03B1\u03B2\u03B3\u03B4, \u0393)",
      StringUtils.endsWithIgnoreCase("\u03B1\u03B2\u03B3\u03B4", "\u0393"));
}

代码示例来源:origin: mulesoft/mule

private boolean isCompressed(String resource) {
  return endsWithIgnoreCase(resource, ".zip") || endsWithIgnoreCase(resource, ".jar");
 }
}

代码示例来源:origin: com.jayway.restassured/rest-assured

public static ContentType fromContentType(String contentType) {
  if (contentType == null) {
    return null;
  }
  contentType = ContentTypeExtractor.getContentTypeWithoutCharset(contentType.toLowerCase());
  final ContentType foundContentType;
  if (contains(XML.ctStrings, contentType) || endsWithIgnoreCase(contentType, PLUS_XML)) {
    foundContentType = XML;
  } else if (contains(JSON.ctStrings, contentType) || endsWithIgnoreCase(contentType, PLUS_JSON)) {
    foundContentType = JSON;
  } else if (contains(TEXT.ctStrings, contentType)) {
    foundContentType = TEXT;
  } else if (contains(HTML.ctStrings, contentType) || endsWithIgnoreCase(contentType, PLUS_HTML)) {
    foundContentType = HTML;
  } else {
    foundContentType = null;
  }
  return foundContentType;
}

代码示例来源:origin: com.jayway.restassured/rest-assured

public static Parser fromContentType(String contentType) {
    if(contentType == null) {
      return null;
    }
    contentType = ContentTypeExtractor.getContentTypeWithoutCharset(contentType.toLowerCase());
    final Parser foundParser;
    if(contains(XML.contentTypes, contentType) || endsWithIgnoreCase(contentType, PLUS_XML)) {
      foundParser = XML;
    } else if(contains(JSON.contentTypes, contentType) || endsWithIgnoreCase(contentType, PLUS_JSON)) {
      foundParser = JSON;
    } else if(contains(TEXT.contentTypes, contentType)) {
      foundParser = TEXT;
    } else if(contains(HTML.contentTypes, contentType) || endsWithIgnoreCase(contentType, PLUS_HTML)) {
      foundParser = HTML;
    } else {
      foundParser = null;
    }
    return foundParser;
  }
}

代码示例来源:origin: mulesoft/mule

/**
 * Finds the corresponding {@link URL} in class path grouped by folder {@link Map} for the given artifact {@link File}.
 *
 * @param classpathFolders a {@link Map} that has as entry the folder of the artifacts from class path and value a {@link List}
 *        with the artifacts (jar, tests.jar, etc).
 * @param artifactResolvedFile the {@link Artifact} resolved from the Maven dependencies and resolved as SNAPSHOT
 * @return {@link URL} for the artifact found in the class path or {@code null}
 */
private URL findArtifactUrlFromClassPath(Map<File, List<URL>> classpathFolders, File artifactResolvedFile) {
 List<URL> urls = classpathFolders.get(artifactResolvedFile.getParentFile());
 logger.debug("URLs found for '{}' in class path are: {}", artifactResolvedFile, urls);
 if (urls.size() == 1) {
  return urls.get(0);
 }
 // If more than one is found, we have to check for the case of a test-jar...
 Optional<URL> urlOpt;
 if (endsWithIgnoreCase(artifactResolvedFile.getName(), TESTS_JAR)) {
  urlOpt = urls.stream().filter(url -> toFile(url).getAbsolutePath().endsWith(TESTS_JAR)).findFirst();
 } else {
  urlOpt = urls.stream()
    .filter(url -> {
     String filePath = toFile(url).getAbsolutePath();
     return !filePath.endsWith(TESTS_JAR) && filePath.endsWith(JAR_EXTENSION);
    }).findFirst();
 }
 return urlOpt.orElse(null);
}

代码示例来源:origin: mulesoft/mule

return !(endsWithIgnoreCase(file, POM_XML) || endsWithIgnoreCase(file, POM_EXTENSION) || endsWithIgnoreCase(file,
                                                       ZIP_EXTENSION));
}).collect(toList());

代码示例来源:origin: org.kuali.common/kuali-util

/**
 * Return true if, and only if, location ends with <code>rice-properties.xml</code> (case insensitive).
 */
public static final boolean isRiceProperties(String location) {
  return StringUtils.endsWithIgnoreCase(location, Constants.RICE_PROPERTIES_SUFFIX);
}

代码示例来源:origin: esig/dss

@Override
public boolean endsWithIgnoreCase(String text, String expected) {
  return StringUtils.endsWithIgnoreCase(text, expected);
}

代码示例来源:origin: org.eclipse.scout.sdk.s2e/org.eclipse.scout.sdk.s2e

protected String calcPageBaseName() {
 String name = getPageName();
 String[] suffixes = new String[]{ISdkProperties.SUFFIX_PAGE_WITH_NODES, ISdkProperties.SUFFIX_PAGE_WITH_TABLE, "Page"};
 for (String suffix : suffixes) {
  if (StringUtils.endsWithIgnoreCase(name, suffix)) {
   name = name.substring(0, name.length() - suffix.length());
  }
 }
 return name;
}

代码示例来源:origin: virjar/vscrawler

@Override
protected boolean handle(String input, String searchString, boolean ignoreCase) {
  if (ignoreCase) {
    return StringUtils.endsWithIgnoreCase(input, searchString);
  } else {
    return StringUtils.endsWith(input, searchString);
  }
}

代码示例来源: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: org.kuali.common/torque-executor

protected Table getTable(String location, KualiDatabase database, String extension) {
  String filename = LocationUtils.getFilename(location);
  if (!StringUtils.endsWithIgnoreCase(filename, extension)) {
    throw new IllegalArgumentException(location + " does not end with " + extension);
  }
  int end = filename.length() - extension.length();
  String tableName = StringUtils.substring(filename, 0, end);
  return getTable(database, tableName);
}

代码示例来源:origin: org.kuali.common/kuali-util

public static long getBytes(String size, List<String> tokens, int base) {
  Assert.notBlank(size);
  for (int i = 0; i < tokens.size(); i++) {
    String token = tokens.get(i);
    long multiplier = (long) Math.pow(base, i);
    if (StringUtils.endsWithIgnoreCase(size, token)) {
      return getByteValue(size, token, multiplier);
    }
  }
  // Assume bytes
  return getByteValue(size, "", 1);
}

代码示例来源:origin: org.xworker/xworker_core

public static boolean endsWithIgnoreCase(ActionContext actionContext){
  Thing self = actionContext.getObject("self");
  CharSequence cs1  = (CharSequence) self.doAction("getCs1", actionContext);
  CharSequence cs2  = (CharSequence) self.doAction("getCs2", actionContext);
  return StringUtils.endsWithIgnoreCase(cs1, cs2);
}

相关文章

StringUtils类方法