private void fixType(String key, PropertyType type) { // Auto-detect passwords and licenses for old versions of plugins that // do not declare property types if (type == PropertyType.STRING) { if (StringUtils.endsWith(key, ".password.secured")) { this.type = PropertyType.PASSWORD; } else if (StringUtils.endsWith(key, ".license.secured")) { this.type = PropertyType.LICENSE; } } } }
/** * <p>Check if a String ends with a specified suffix.</p> * * <p><code>null</code>s are handled without exceptions. Two <code>null</code> * 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 * </pre> * * @see java.lang.String#endsWith(String) * @param str the String to check, may be null * @param suffix the suffix to find, may be null * @return <code>true</code> if the String ends with the suffix, case sensitive, or * both <code>null</code> * @since 2.4 */ public static boolean endsWith(String str, String suffix) { return endsWith(str, suffix, false); }
/** * <p>Case insensitive check if a String ends with a specified suffix.</p> * * <p><code>null</code>s are handled without exceptions. Two <code>null</code> * 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 String to check, may be null * @param suffix the suffix to find, may be null * @return <code>true</code> if the String ends with the suffix, case insensitive, or * both <code>null</code> * @since 2.4 */ public static boolean endsWithIgnoreCase(String str, String suffix) { return endsWith(str, suffix, true); }
public boolean isLastFile(String fileName) { String needCompareName = lastDownload; if (StringUtils.isNotEmpty(needCompareName) && StringUtils.endsWith(needCompareName, "tar")) { needCompareName = needCompareName.substring(0, needCompareName.indexOf(".")); } return (needCompareName == null || fileName.equalsIgnoreCase(needCompareName)) && binlogList.isEmpty(); }
/** * <p>Check if a String ends with any of an array of specified strings.</p> * * <pre> * 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 * </pre> * * @param string the String to check, may be null * @param searchStrings the Strings to find, may be null or empty * @return <code>true</code> if the String ends with any of the the prefixes, case insensitive, or * both <code>null</code> * @since 2.6 */ public static boolean endsWithAny(String string, String[] searchStrings) { if (isEmpty(string) || ArrayUtils.isEmpty(searchStrings)) { return false; } for (int i = 0; i < searchStrings.length; i++) { String searchString = searchStrings[i]; if (StringUtils.endsWith(string, searchString)) { return true; } } return false; }
/** * Finds files within a given directory and its subdirectories * * @param classLoader * @param rootPath the root directory, for example org/sonar/sqale * @return a list of relative paths, for example {"org/sonar/sqale/foo/bar.txt}. Never null. */ public static Collection<String> listFiles(ClassLoader classLoader, String rootPath) { return listResources(classLoader, rootPath, path -> !StringUtils.endsWith(path, "/")); }
private NewController(Context context, String path) { if (StringUtils.isBlank(path)) { throw new IllegalArgumentException("WS controller path must not be empty"); } if (StringUtils.startsWith(path, "/") || StringUtils.endsWith(path, "/")) { throw new IllegalArgumentException("WS controller path must not start or end with slash: " + path); } this.context = context; this.path = path; }
static boolean isRuleProperty(String propertyKey) { return StringUtils.startsWith(propertyKey, RULE_PREFIX) && StringUtils.endsWith(propertyKey, NAME_SUFFIX) && !propertyKey.contains(".param."); } }
@Override public void start() { StringBuilder sb = new StringBuilder(); batchDir = new File(fs.getHomeDir(), "lib/scanner"); if (batchDir.exists()) { Collection<File> files = FileUtils.listFiles(batchDir, HiddenFileFilter.VISIBLE, FileFilterUtils.directoryFileFilter()); for (File file : files) { String filename = file.getName(); if (StringUtils.endsWith(filename, ".jar")) { try (FileInputStream fis = new FileInputStream(file)) { sb.append(filename).append('|').append(DigestUtils.md5Hex(fis)).append(CharUtils.LF); } catch (IOException e) { throw new IllegalStateException("Fail to compute hash", e); } } } } this.index = sb.toString(); }
private static int processLine(String line) { int ret = 0; String command = ""; for (String oneCmd : line.split(";")) { if (StringUtils.endsWith(oneCmd, "\\")) { command += StringUtils.chop(oneCmd) + ";"; continue; } else { command += oneCmd; } if (StringUtils.isBlank(command)) { continue; } ret = processCmd(command); command = ""; } return ret; }
fileName = StringUtils.substringAfter(fileName, "filename="); boolean isTar = StringUtils.endsWith(fileName, ".tar"); FileUtils.forceMkdir(parentFile); FileOutputStream fos = null;
/** * Process command line. * * @param line the command line * @return the int execution result code */ public int processLine(String line) { int lastRet = 0; int ret = 0; String command = ""; for (String oneCmd : line.split(";")) { if (StringUtils.endsWith(oneCmd, "\\")) { command += StringUtils.chop(oneCmd) + ";"; continue; } else { command += oneCmd; } if (StringUtils.isBlank(command)) { continue; } ret = processCmd(command); command = ""; lastRet = ret; if (ret != 0) { return ret; } } return lastRet; }
@Test public void listResources_use_predicate() { Collection<String> strings = ClassLoaderUtils.listResources(classLoader, "org/sonar/sqale", s -> endsWith(s, "md")); assertThat(strings).containsOnly("org/sonar/sqale/app/README.md"); }
for (String oneCmd : commands) { if (StringUtils.endsWith(oneCmd, "\\")) { command += StringUtils.chop(oneCmd) + ";"; continue;
/** * Sets the output file name for the Excel Report. The file should have 'xls' extension. * * @param fileName * The file name without any path. */ public void setExcelFileName(String fileName) { Preconditions.checkArgument(StringUtils.endsWith(fileName, ".xls"), "Excel file name must end with '.xls'."); reportFileName = fileName; }
/** * From GWT documentation: * JSNI methods are declared native and contain JavaScript code in a specially formatted comment block * between the end of the parameter list and the trailing semicolon. * A JSNI comment block begins with the exact token {@link #START_JSNI} and ends with the exact token {@link #END_JSNI}. */ private static boolean isJSNI(String comment) { return StringUtils.startsWith(comment, START_JSNI) && StringUtils.endsWith(comment, END_JSNI); }
private String addQuotes(String value) { if (StringUtils.isEmpty(value)) { return value; } if (!StringUtils.startsWith(value, QUOTE_STRING)) { value = QUOTE_STRING + value; } if (!StringUtils.endsWith(value, QUOTE_STRING)) { value = value + QUOTE_STRING; } return value; }
private NewController(Context context, String path) { if (StringUtils.isBlank(path)) { throw new IllegalArgumentException("WS controller path must not be empty"); } if (StringUtils.startsWith(path, "/") || StringUtils.endsWith(path, "/")) { throw new IllegalArgumentException("WS controller path must not start or end with slash: " + path); } this.context = context; this.path = path; }
public String getWebhookUrl(Optional<String> customParam) { StringBuilder sb = new StringBuilder(); sb.append(serverConfigurationService.getServerUrl()); if(!StringUtils.endsWith(sb.toString(), "/")) { sb.append("/"); } return String.format(WEBHOOK_URL_TEMPLATE, sb.toString(), getProviderId()) + (customParam.isPresent() ? "&custom=" + customParam.get() : ""); } }
@Override public String getQueryString() { String queryString = super.getQueryString(); // If query string ends with an ampersand, take it off if (StringUtils.endsWith(queryString, "&")) { queryString = StringUtils.chop(queryString); } return queryString; } }