/** * <p>Case insensitive check if a CharSequence ends with a specified suffix.</p> * * <p>{@code null}s are handled without exceptions. Two {@code null} * references are considered to be equal. The comparison is case insensitive.</p> * * <pre> * 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 * </pre> * * @see java.lang.String#endsWith(String) * @param str the CharSequence to check, may be null * @param suffix the suffix to find, may be null * @return {@code true} if the CharSequence ends with the suffix, case insensitive, or * both {@code null} * @since 2.4 * @since 3.0 Changed signature from endsWithIgnoreCase(String, String) to endsWithIgnoreCase(CharSequence, CharSequence) */ public static boolean endsWithIgnoreCase(final CharSequence str, final CharSequence suffix) { return endsWith(str, suffix, true); }
@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); } }
/** * <p>Check if a CharSequence ends with a specified suffix.</p> * * <p>{@code null}s are handled without exceptions. Two {@code null} * references are considered to be equal. The comparison is case sensitive.</p> * * <pre> * StringUtils.endsWith(null, null) = true * StringUtils.endsWith(null, "def") = false * StringUtils.endsWith("abcdef", null) = false * StringUtils.endsWith("abcdef", "def") = true * StringUtils.endsWith("ABCDEF", "def") = false * StringUtils.endsWith("ABCDEF", "cde") = false * StringUtils.endsWith("ABCDEF", "") = true * </pre> * * @see java.lang.String#endsWith(String) * @param str the CharSequence to check, may be null * @param suffix the suffix to find, may be null * @return {@code true} if the CharSequence ends with the suffix, case sensitive, or * both {@code null} * @since 2.4 * @since 3.0 Changed signature from endsWith(String, String) to endsWith(CharSequence, CharSequence) */ public static boolean endsWith(final CharSequence str, final CharSequence suffix) { return endsWith(str, suffix, false); }
/** * Appends the suffix to the end of the string if the string does not * already end with the suffix. * * @param str The string. * @param suffix The suffix to append to the end of the string. * @param ignoreCase Indicates whether the compare should ignore case. * @param suffixes Additional suffixes that are valid terminators (optional). * * @return A new String if suffix was appended, the same string otherwise. */ private static String appendIfMissing(final String str, final CharSequence suffix, final boolean ignoreCase, final CharSequence... suffixes) { if (str == null || isEmpty(suffix) || endsWith(str, suffix, ignoreCase)) { return str; } if (suffixes != null && suffixes.length > 0) { for (final CharSequence s : suffixes) { if (endsWith(str, s, ignoreCase)) { return str; } } } return str + suffix.toString(); }
if (endsWith(sequence, searchString)) { return true;
if (startsWith(str, wrapToken) && endsWith(str, wrapToken)) { final int startIndex = str.indexOf(wrapToken); final int endIndex = str.lastIndexOf(wrapToken);
private File[] toModuleJarFileArray() { if (moduleLibDir.exists() && moduleLibDir.isFile() && moduleLibDir.canRead() && StringUtils.endsWith(moduleLibDir.getName(), ".jar")) { return new File[]{ moduleLibDir }; } else { return convertFileCollectionToFileArray( listFiles(moduleLibDir, new String[]{"jar"}, false) ); } }
private String jsonp2Json(String jsonp) { if (jsonp == null) { return null; } jsonp = StringUtils.trim(jsonp); if(jsonp.startsWith("try")||StringUtils.endsWith(jsonp, ")")){ if(jsonp.indexOf("catch")!=-1){ jsonp = jsonp.substring(0,jsonp.indexOf("catch")); } int fromIndex = jsonp.indexOf('('); int toIndex = jsonp.lastIndexOf(')'); if(fromIndex!=-1&&toIndex!=-1){ jsonp = jsonp.substring(fromIndex+1,toIndex).trim(); return jsonp; } } if (StringUtils.endsWith(jsonp, ";")) { jsonp = StringUtils.substringBeforeLast(jsonp, ";"); jsonp = StringUtils.trim(jsonp); } /*if (StringUtils.endsWith(jsonp, ")")) { String jsonStr = StringUtils.substring(jsonp, "(", ")"); jsonStr = StringUtils.trim(jsonStr); return jsonStr; }*/ return jsonp; }
if (StringUtils.endsWith(line, "\\")) {
/** * Test StringUtils.endsWith() */ @Test public void testEndsWith() { assertTrue("endsWith(null, null)", StringUtils.endsWith(null, null)); assertFalse("endsWith(FOOBAR, null)", StringUtils.endsWith(FOOBAR, null)); assertFalse("endsWith(null, FOO)", StringUtils.endsWith(null, FOO)); assertTrue("endsWith(FOOBAR, \"\")", StringUtils.endsWith(FOOBAR, "")); assertFalse("endsWith(foobar, foo)", StringUtils.endsWith(foobar, foo)); assertFalse("endsWith(FOOBAR, FOO)", StringUtils.endsWith(FOOBAR, FOO)); assertFalse("endsWith(foobar, FOO)", StringUtils.endsWith(foobar, FOO)); assertFalse("endsWith(FOOBAR, foo)", StringUtils.endsWith(FOOBAR, foo)); assertFalse("endsWith(foo, foobar)", StringUtils.endsWith(foo, foobar)); assertFalse("endsWith(foo, foobar)", StringUtils.endsWith(bar, foobar)); assertTrue("endsWith(foobar, bar)", StringUtils.endsWith(foobar, bar)); assertTrue("endsWith(FOOBAR, BAR)", StringUtils.endsWith(FOOBAR, BAR)); assertFalse("endsWith(foobar, BAR)", StringUtils.endsWith(foobar, BAR)); assertFalse("endsWith(FOOBAR, bar)", StringUtils.endsWith(FOOBAR, bar)); // "alpha,beta,gamma,delta".endsWith("delta") assertTrue("endsWith(\u03B1\u03B2\u03B3\u03B4, \u03B4)", StringUtils.endsWith("\u03B1\u03B2\u03B3\u03B4", "\u03B4")); // "alpha,beta,gamma,delta".endsWith("gamma,DELTA") assertFalse("endsWith(\u03B1\u03B2\u03B3\u03B4, \u03B3\u0394)", StringUtils.endsWith("\u03B1\u03B2\u03B3\u03B4", "\u03B3\u0394")); }
@Override public boolean accept(File f) { if (f.isDirectory()) { return true; } return StringUtils.endsWith(f.getName(), ".settings"); }
/** * Exports the current firmware settings to a file. The file will be in JSON format with * {@link FirmwareSettingsFile} * * @param settingsFile the file to write the settings to. * @param controller the controller to get the firmware settings from */ public static void exportSettings(final File settingsFile, IController controller) { File file = settingsFile; if (!StringUtils.endsWith(settingsFile.getName(), ".settings")) { file = new File(settingsFile.getAbsolutePath() + ".settings"); } FirmwareSettingsFile firmwareSettingsFile = new FirmwareSettingsFileBuilder() .setCreatedBy(System.getProperty("user.name")) .setDate(LocalDate.now().format(DateTimeFormatter.ISO_DATE)) .setFirmwareName(controller.getFirmwareVersion()) .setName(Localization.getString("firmware.settings.exportSettingsDefaultName")) .setSettings(controller.getFirmwareSettings().getAllSettings()) .build(); Gson gson = new GsonBuilder() .setPrettyPrinting() .create(); try { String json = gson.toJson(firmwareSettingsFile); FileUtils.writeStringToFile(file, json); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Couldn't write the settings file " + settingsFile.getAbsolutePath(), e); } }
private String completeViewName(String view) { if (!StringUtils.startsWith(view, "/")) { view = "/WEB-INF/jsp/" + view; } if (!StringUtils.endsWith(view, ".jsp")) { view = view + ".jsp"; } return view; } }
public boolean isPrecededByStyle(final String html) { if (isBlank(html)) { return false; } for (String wiki : styleMap.values()) { if (endsWith(html, wiki)) { return true; } } return false; }
private static InputStream readFileFromTestResource(String path) { String fullPath = StringUtils.endsWith(path, YAML) ? path : path + YAML; return YamlReader.class.getClassLoader().getResourceAsStream(fullPath); } }
public static String name(final String path) { if(String.valueOf(Path.DELIMITER).equals(path)) { return path; } if(StringUtils.endsWith(path, String.valueOf(Path.DELIMITER))) { return FilenameUtils.getName(normalize(path)); } return FilenameUtils.getName(path); }
public static boolean endsWithZipExtension(String path) { for (String extension : getZipExtensions()) { if (StringUtils.endsWith(path, "." + extension)) { return true; } } return false; }
public static boolean endsWithZipExtension(String path) { for (String extension : getZipExtensions()) { if (StringUtils.endsWith(path, "." + extension)) { return true; } } return false; }
if (StringUtils.endsWith(oneCmd, "\\")) { command += StringUtils.chop(oneCmd) + "\\;"; continue;