@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"))); }
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"); }
public static boolean endswithany(final CharSequence sequence, final CharSequence... searchStrings) { return StringUtils.endsWithAny(sequence, searchStrings); }
private boolean checkAttachmentExtension(final String attachementPathValue) { return StringUtils.isBlank(attachementPathValue) || StringUtils.endsWithAny(attachementPathValue, MasterOrdersConstants.FILE_EXTENSIONS); } }
/** * 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; } }
/** * 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; } } }
/** * 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; }
/** * 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; }
/** * 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; }
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); }
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 ); } }
/** * 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; }
while (names.hasMoreElements()) { String name = (String) names.nextElement(); if (StringUtils.endsWithAny(name, skipNames)) continue;
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;
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);
/** * 权限错误消息提醒 * * @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; } }