本文整理了Java中org.apache.commons.lang3.StringUtils.endsWithAny()
方法的一些代码示例,展示了StringUtils.endsWithAny()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringUtils.endsWithAny()
方法的具体详情如下:
包路径:org.apache.commons.lang3.StringUtils
类名称:StringUtils
方法名:endsWithAny
[英]Check if a CharSequence ends with any of the provided case-sensitive suffixes.
StringUtils.endsWithAny(null, null) = false
StringUtils.endsWithAny(null, new String[] {"abc"}) = false
StringUtils.endsWithAny("abcxyz", null) = false
StringUtils.endsWithAny("abcxyz", new String[] {""}) = true
StringUtils.endsWithAny("abcxyz", new String[] {"xyz"}) = true
StringUtils.endsWithAny("abcxyz", new String[] {null, "xyz", "abc"}) = true
StringUtils.endsWithAny("abcXYZ", "def", "XYZ") = true
StringUtils.endsWithAny("abcXYZ", "def", "xyz") = false
[中]检查CharSequence是否以提供的任何区分大小写的后缀结尾。
StringUtils.endsWithAny(null, null) = false
StringUtils.endsWithAny(null, new String[] {"abc"}) = false
StringUtils.endsWithAny("abcxyz", null) = false
StringUtils.endsWithAny("abcxyz", new String[] {""}) = true
StringUtils.endsWithAny("abcxyz", new String[] {"xyz"}) = true
StringUtils.endsWithAny("abcxyz", new String[] {null, "xyz", "abc"}) = true
StringUtils.endsWithAny("abcXYZ", "def", "XYZ") = true
StringUtils.endsWithAny("abcXYZ", "def", "xyz") = false
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testEndsWithAny() {
assertFalse("StringUtils.endsWithAny(null, null)", StringUtils.endsWithAny(null, (String)null));
assertFalse("StringUtils.endsWithAny(null, new String[] {abc})", StringUtils.endsWithAny(null, new String[] {"abc"}));
assertFalse("StringUtils.endsWithAny(abcxyz, null)", StringUtils.endsWithAny("abcxyz", (String)null));
assertTrue("StringUtils.endsWithAny(abcxyz, new String[] {\"\"})", StringUtils.endsWithAny("abcxyz", new String[] {""}));
assertTrue("StringUtils.endsWithAny(abcxyz, new String[] {xyz})", StringUtils.endsWithAny("abcxyz", new String[] {"xyz"}));
assertTrue("StringUtils.endsWithAny(abcxyz, new String[] {null, xyz, abc})", StringUtils.endsWithAny("abcxyz", new String[] {null, "xyz", "abc"}));
assertFalse("StringUtils.endsWithAny(defg, new String[] {null, xyz, abc})", StringUtils.endsWithAny("defg", new String[] {null, "xyz", "abc"}));
assertTrue(StringUtils.endsWithAny("abcXYZ", "def", "XYZ"));
assertFalse(StringUtils.endsWithAny("abcXYZ", "def", "xyz"));
assertTrue(StringUtils.endsWithAny("abcXYZ", "def", "YZ"));
/*
* Type null of the last argument to method endsWithAny(CharSequence, CharSequence...)
* doesn't exactly match the vararg parameter type.
* Cast to CharSequence[] to confirm the non-varargs invocation,
* or pass individual arguments of type CharSequence for a varargs invocation.
*
* assertFalse(StringUtils.endsWithAny("abcXYZ", null)); // replace with specific types to avoid warning
*/
assertFalse(StringUtils.endsWithAny("abcXYZ", (CharSequence) null));
assertFalse(StringUtils.endsWithAny("abcXYZ", (CharSequence[]) null));
assertTrue(StringUtils.endsWithAny("abcXYZ", ""));
assertTrue("StringUtils.endsWithAny(abcxyz, StringBuilder(abc), StringBuffer(xyz))", StringUtils.endsWithAny("abcxyz", new StringBuilder("abc"), new StringBuffer("xyz")));
assertTrue("StringUtils.endsWithAny(StringBuffer(abcxyz), StringBuilder(abc), StringBuffer(xyz))", StringUtils.endsWithAny(new StringBuffer("abcxyz"), new StringBuilder("abc"), new StringBuffer("xyz")));
}
代码示例来源:origin: org.languagetool/language-de
private boolean isNeedingFugenS (String word) {
// according to http://www.spiegel.de/kultur/zwiebelfisch/zwiebelfisch-der-gebrauch-des-fugen-s-im-ueberblick-a-293195.html
return StringUtils.endsWithAny(word, "tum", "ling", "ion", "tät", "keit", "schaft", "sicht", "ung", "en");
}
代码示例来源:origin: co.cask.re/dre-core
public static boolean endswithany(final CharSequence sequence, final CharSequence... searchStrings) {
return StringUtils.endsWithAny(sequence, searchStrings);
}
代码示例来源:origin: qcadoo/mes
private boolean checkAttachmentExtension(final String attachementPathValue) {
return StringUtils.isBlank(attachementPathValue)
|| StringUtils.endsWithAny(attachementPathValue, MasterOrdersConstants.FILE_EXTENSIONS);
}
}
代码示例来源:origin: co.cask.wrangler/wrangler-core
/**
* Remove trailing characters which may be empty string,
* space string,\t,\n,\r,\f...any space, break related characters.
*
* @param input - the input text.
* @return String
*/
public static String rtrim(String input) {
if (StringUtils.isEmpty(input)) {
return input;
}
String result = input;
while (StringUtils.endsWithAny(result, WHITESPACE_CHARS)) {
result = StringUtils.removeEnd(result, result.substring(result.length() - 1, result.length()));
}
return result;
}
}
代码示例来源:origin: com.github.davidcarboni/restolino
/**
* Scans the {@link ClassLoader} hierarchy to check if there is a
* <code>.../classes</code> entry present. This is designed to prevent
* uncertainty and frustration if you have correctly configured class
* reloading, but have also accidentally included your classes on the
* classpath. This would lead to code not being reloaded and possibly even
* confusing error messages because the classes on the classpath will take
* precedence over reloaded classes (because class loaders normally delegate
* upwards).
*/
void findClassesInClassloader(URLClassLoader urlClassLoader) {
// Check for a "classes" URL:
for (URL url : urlClassLoader.getURLs()) {
String urlPath = StringUtils.lowerCase(url.getPath());
if (StringUtils.endsWithAny(urlPath, "/classes", "/classes/")) {
classesInClasspath = url;
}
}
}
代码示例来源:origin: org.nuiton.wikitty/wikitty-api
/**
* Remove quote at beginning and ending of String in parameter if necessary
*
* <li>"toto" return toto
* <li>"toto return "toto
* <li> toto return toto"
* <li> to"to return to"to
*
* @param s
* @return
*/
protected String removeQuote(String s) {
String result = s;
if (StringUtils.startsWithAny(s, LITERAL_OPEN_SIMPLE, LITERAL_OPEN_DOUBLE)
&& StringUtils.endsWithAny(s, LITERAL_CLOSE_SIMPLE, LITERAL_CLOSE_DOUBLE)) {
result = StringUtils.substring(s, 1, -1);
}
return result;
}
代码示例来源:origin: co.cask.wrangler/wrangler-core
/**
* Remove trailing and leading characters which may be empty string,
* space string,\t,\n,\r,\f...any space, break related characters.
*
* @param input - the input text.
* @return String
*/
public static String trim(String input) {
if (StringUtils.isEmpty(input)) {
return input;
}
String result = input;
while (StringUtils.startsWithAny(result, WHITESPACE_CHARS)) {
result = StringUtils.removeStart(result, result.substring(0, 1));
}
while (StringUtils.endsWithAny(result, WHITESPACE_CHARS)) {
result = StringUtils.removeEnd(result, result.substring(result.length() - 1, result.length()));
}
return result;
}
代码示例来源:origin: co.cask.wrangler/wrangler-core
/**
* Remove trailing and leading characters which may be empty string,
* space string,\t,\n,\r,\f...any space, break related
* characters.
*
* @param input - the input text.
* @return String
*/
public String removeTrailingAndLeadingWhitespaces(String input) {
if (StringUtils.isEmpty(input)) {
return input;
}
String result = input;
while (StringUtils.startsWithAny(result, WHITESPACE_CHARS)) {
result = StringUtils.removeStart(result, result.substring(0, 1));
}
while (StringUtils.endsWithAny(result, WHITESPACE_CHARS)) {
result = StringUtils.removeEnd(result, result.substring(result.length() - 1, result.length()));
}
return result;
}
代码示例来源:origin: org.opencb.biodata/biodata-tools
protected static String buildAllele(String chromosome, Integer start, Integer end, String allele, Pair<Integer, Integer> adjustedRange, Map<Integer, Character> referenceAlleles) {
if (start.equals(adjustedRange.getLeft()) && end.equals(adjustedRange.getRight())) {
return allele; // same start / end
}
if (StringUtils.startsWith(allele, "*") || StringUtils.startsWith(allele, "<")) {
return allele; // no need for overlapping deletions and symbolic alleles
}
if (StringUtils.startsWithAny(allele, "]", "[")) {
if (allele.endsWith(".")) {
allele = allele.substring(0, allele.length() - 1);
}
return allele + getReferenceBase(chromosome, adjustedRange.getLeft(), adjustedRange.getLeft() + 1, referenceAlleles);
}
if (StringUtils.endsWithAny(allele, "]", "[")) {
if (allele.startsWith(".")) {
allele = allele.substring(1);
}
return getReferenceBase(chromosome, adjustedRange.getLeft(), start, referenceAlleles) + allele;
}
return getReferenceBase(chromosome, adjustedRange.getLeft(), start, referenceAlleles)
+ allele
+ getReferenceBase(chromosome, end + 1, adjustedRange.getRight() + 1, referenceAlleles);
}
代码示例来源:origin: com.foreach.cwb/cwb-core
private Cleaned clean( String expected ) {
boolean isRegex = StringUtils.startsWith( expected, "/" ) && StringUtils.endsWithAny( expected, "/", "/i" );
boolean shouldIgnoreCase = StringUtils.endsWith( expected, "/i" );
String cleaned = expected;
if ( isRegex ) {
cleaned = StringUtils.strip( expected, "/" );
}
if ( shouldIgnoreCase ) {
cleaned = StringUtils.stripEnd( cleaned, "/i" );
}
return new Cleaned( expected, cleaned, shouldIgnoreCase || ignoreCaseByDefault, isRegex );
}
}
代码示例来源:origin: org.languagetool/language-de
/**
* Search for modifiers (such as "sehr", "1,4 Meter") which can expand a
* determiner - adjective - noun group ("ein hohes Haus" -> "ein sehr hohes Haus",
* "ein 500 Meter hohes Haus") and return the index of the first non-modifier token ("Haus")
* @param startAt index of array where to start searching for modifier
* @return index of first non-modifier token
*/
private int getPosAfterModifier(int startAt, AnalyzedTokenReadings[] tokens) {
if ((startAt + 1) < tokens.length && MODIFIERS.contains(tokens[startAt].getToken())) {
startAt++;
}
if ((startAt + 1) < tokens.length && (StringUtils.isNumeric(tokens[startAt].getToken()) || tokens[startAt].hasPosTag("ZAL"))) {
int posAfterModifier = startAt + 1;
if ((startAt + 3) < tokens.length && ",".equals(tokens[startAt+1].getToken()) && StringUtils.isNumeric(tokens[startAt+2].getToken())) {
posAfterModifier = startAt + 3;
}
if (StringUtils.endsWithAny(tokens[posAfterModifier].getToken(), "gramm", "Gramm", "Meter", "meter")) {
return posAfterModifier + 1;
}
}
return startAt;
}
代码示例来源:origin: com.haulmont.cuba/cuba-core
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
if (StringUtils.endsWithAny(name, skipNames))
continue;
代码示例来源:origin: sofn/app-engine
String path = request.getRequestURI();
if (StringUtils.startsWithAny(path, "/webjars", "/static", "/js", "/css", "/libs", "/WEB-INF")
|| StringUtils.endsWithAny(path, GlobalConstants.staticResourceArray)) {
filterChain.doFilter(request, response);
return;
代码示例来源:origin: sofn/app-engine
if (StringUtils.equals(request.getRequestURI(), "/error")
|| StringUtils.startsWith(request.getRequestURI(), "/swagger-resources")
|| StringUtils.endsWithAny(request.getRequestURI(), GlobalConstants.staticResourceArray)
|| !StringUtils.equals(profile, "prod")) {
return super.handleInternal(request, response, handlerMethod);
代码示例来源:origin: lerry903/RuoYi
/**
* 权限错误消息提醒
*
* @param permissionsStr 错误信息
* @return
*/
public static String getMsg(String permissionsStr) {
String permission = StringUtils.substringBetween(permissionsStr, "[" , "]");
String msg = MessageUtils.message("no.view.permission" , permission);
if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.ADD_PERMISSION)) {
msg = MessageUtils.message("no.create.permission" , permission);
} else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EDIT_PERMISSION)) {
msg = MessageUtils.message("no.update.permission" , permission);
} else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.REMOVE_PERMISSION)) {
msg = MessageUtils.message("no.delete.permission" , permission);
} else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EXPORT_PERMISSION)) {
msg = MessageUtils.message("no.export.permission" , permission);
} else if (StringUtils.endsWithAny(permission,PermissionConstants.VIEW_PERMISSION, PermissionConstants.LIST_PERMISSION)) {
msg = MessageUtils.message("no.view.permission" , permission);
}
return msg;
}
}
内容来源于网络,如有侵权,请联系作者删除!