Java Code Examples for org.apache.commons.lang.StringUtils#stripToNull()
The following examples show how to use
org.apache.commons.lang.StringUtils#stripToNull() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilesystemRepositoryConfigurationPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
private void updateErrorLabel(String text) { if (StringUtils.stripToNull(text) == null) { if (isChecking.get()) { errorLabel.setIcon(LOADING_ICON); } else { if (isSuccess.get()) { errorLabel.setIcon(SUCCESS_ICON); } else { errorLabel.setIcon(UNKNOWN_ICON); } } errorLabel.setText(""); } else { if (isChecking.get()) { errorLabel.setIcon(ERROR_ICON); } else { if (isSuccess.get()) { errorLabel.setIcon(SUCCESS_ICON); } else { errorLabel.setIcon(ERROR_ICON); } } errorLabel.setText(text); } }
Example 2
Source File: SettingsItem.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Checks if the given child matches the filter. */ public boolean isInFilter(SettingsItem child, String filter) { if (!child.type.equals(Type.PARAMETER)) { return true; } filter = StringUtils.stripToNull(filter); if (filter == null) { return true; } String[] filterTokens = filter.split(" "); for (int i = 0; i < filterTokens.length; i++) { filterTokens[i] = filterTokens[i].toLowerCase(Locale.ENGLISH); } List<Supplier<String>> stringProviders = Arrays.asList(child::getKey, child::getTitle, child::getDescription); return stringProviders.stream().map(Supplier::get).filter(s -> s != null && !s.isEmpty()) .map(s -> s.toLowerCase(Locale.ENGLISH)).anyMatch(s -> Arrays.stream(filterTokens).anyMatch(s::contains)); }
Example 3
Source File: AgentStatusReportExecutorTest.java From docker-swarm-elastic-agent-plugin with Apache License 2.0 | 5 votes |
private boolean hasEnvironmentVariable(Document document, String name, String value) { final Elements elements = document.select(MessageFormat.format(".environments .name-value .name-value_pair label:contains({0})", name)); if (elements.isEmpty()) { return false; } final String envValueSpanText = StringUtils.stripToNull(elements.get(0).parent().select("span").text()); return StringUtils.equals(value, envValueSpanText); }
Example 4
Source File: RepositoryTools.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Get the suffix from a filename, will return "bar" for "foo.bar" and "gitignore" for ".gitignore". * * @param name the filename, not the path, to get the suffix from, must not be null or empty * @return the suffix of the file, can be empty if no suffix exists, never {@code null}. Always lower case. * @since 9.7 */ public static String getSuffixFromFilename(String name) { if (StringUtils.stripToNull(name) == null) { throw new IllegalArgumentException("filename must not be null or empty!"); } return FilenameUtils.getExtension(StringUtils.stripToNull(name)).toLowerCase(Locale.ENGLISH); }
Example 5
Source File: WebServiceTools.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@Override public void informParameterChanged(String key, String value) { if (WEB_SERVICE_TIMEOUT.equals(key)) { if (value != null) { TIMEOUT_URL_CONNECTION = Integer.parseInt(value); } } else if (RapidMiner.RAPIDMINER_DEFAULT_USER_AGENT.equals(key)) { userAgent = StringUtils.stripToNull(value); } }
Example 6
Source File: EncryptionProviderBuilder.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Set the context key which is used to determine which encryption key is used. * <p> * Optional, will use the local default context if not specified. * </p> * * @param context the context, must only contain alphanumeric characters plus either whitespaces, {@code _}, {@code * -}, or {@code %}. If {@code null}, will return a special encryption provider which does NOT * encrypt at all! * @return this builder */ public EncryptionProviderBuilder withContext(String context) { if (context != null) { if (StringUtils.stripToNull(context) == null) { throw new IllegalArgumentException("context must not be empty!"); } if (EncryptionProviderRegistry.INVALID_CONTEXT_PATTERN.matcher(context).find()) { throw new IllegalArgumentException("context must only contain alphanumeric characters plus whitespaces, '_', '%', or '-'!, but was " + context); } } this.context = context; return this; }
Example 7
Source File: BashTestUtils.java From BashSupport with Apache License 2.0 | 5 votes |
private static String computeBasePath() { String configuredDir = StringUtils.stripToNull(System.getenv("BASHSUPPORT_TESTDATA")); if (configuredDir != null) { File dir = new File(configuredDir); if (dir.isDirectory() && dir.exists()) { return dir.getAbsolutePath(); } } //try to find out from the current classloader URL url = BashTestUtils.class.getClassLoader().getResource("log4j.xml"); if (url != null) { try { File basePath = new File(url.toURI()); while (basePath.exists() && !new File(basePath, "testData").isDirectory()) { basePath = basePath.getParentFile(); } //we need to cut the out dir and the other resource paths //File basePath = resourceFile.getParentFile().getParentFile().getParentFile().getParentFile(); if (basePath.isDirectory()) { return new File(basePath, "testData").getAbsolutePath(); } } catch (Exception e) { //ignore, use fallback below } } else { throw new IllegalStateException("Could not find log4jx.ml"); } return null; }
Example 8
Source File: JenkinsUtils.java From docker-plugin with MIT License | 5 votes |
/** * Clones a String array but stripping all entries and omitting any that are * null or empty after stripping. * * @param arr The starting array; this will not be modified. * @return A new array no longer than the one given, but which may be empty. */ @Restricted(NoExternalUse.class) @Nonnull public static String[] filterStringArray(@Nullable String[] arr) { final ArrayList<String> strings = new ArrayList<>(); if (arr != null) { for (String s : arr) { s = StringUtils.stripToNull(s); if (s != null) { strings.add(s); } } } return strings.toArray(new String[strings.size()]); }
Example 9
Source File: BasicLTIUtil.java From lams with GNU General Public License v2.0 | 4 votes |
/** * @deprecated See: {@link #parseDescriptor(Map, Map, String)} * @param launch_info Variable is mutated by this method. * @param postProp Variable is mutated by this method. * @param descriptor * @return */ public static boolean parseDescriptor(Properties launch_info, Properties postProp, String descriptor) { // this is an ugly copy/paste of the non-@deprecated method // could not convert data types as they variables get mutated (ugh) Map<String, Object> tm = null; try { tm = XMLMap.getFullMap(descriptor.trim()); } catch (Exception e) { M_log.warning("BasicLTIUtil exception parsing BasicLTI descriptor: " + e.getMessage()); return false; } if (tm == null) { M_log.warning("Unable to parse XML in parseDescriptor"); return false; } String launch_url = StringUtils.stripToNull(XMLMap.getString(tm, "/basic_lti_link/launch_url")); String secure_launch_url = StringUtils.stripToNull(XMLMap.getString(tm, "/basic_lti_link/secure_launch_url")); if (launch_url == null && secure_launch_url == null) { return false; } setProperty(launch_info, "launch_url", launch_url); setProperty(launch_info, "secure_launch_url", secure_launch_url); // Extensions for hand-authored placements - The export process should scrub these setProperty(launch_info, "key", StringUtils.stripToNull(XMLMap.getString(tm, "/basic_lti_link/x-secure/launch_key"))); setProperty(launch_info, "secret", StringUtils.stripToNull(XMLMap.getString(tm, "/basic_lti_link/x-secure/launch_secret"))); List<Map<String, Object>> theList = XMLMap.getList(tm, "/basic_lti_link/custom/parameter"); for (Map<String, Object> setting : theList) { dPrint("Setting=" + setting); String key = XMLMap.getString(setting, "/!key"); // Get the key attribute String value = XMLMap.getString(setting, "/"); // Get the value if (key == null || value == null) { continue; } key = "custom_" + mapKeyName(key); dPrint("key=" + key + " val=" + value); postProp.setProperty(key, value); } return true; }
Example 10
Source File: BasicLTIUtil.java From lams with GNU General Public License v2.0 | 4 votes |
/** * * @param launch_info Variable is mutated by this method. * @param postProp Variable is mutated by this method. * @param descriptor * @return */ public static boolean parseDescriptor(Map<String, String> launch_info, Map<String, String> postProp, String descriptor) { Map<String, Object> tm = null; try { tm = XMLMap.getFullMap(descriptor.trim()); } catch (Exception e) { M_log.warning("BasicLTIUtil exception parsing BasicLTI descriptor: " + e.getMessage()); return false; } if (tm == null) { M_log.warning("Unable to parse XML in parseDescriptor"); return false; } String launch_url = StringUtils.stripToNull(XMLMap.getString(tm, "/basic_lti_link/launch_url")); String secure_launch_url = StringUtils.stripToNull(XMLMap.getString(tm, "/basic_lti_link/secure_launch_url")); if (launch_url == null && secure_launch_url == null) { return false; } setProperty(launch_info, "launch_url", launch_url); setProperty(launch_info, "secure_launch_url", secure_launch_url); // Extensions for hand-authored placements - The export process should scrub // these setProperty(launch_info, "key", StringUtils.stripToNull(XMLMap.getString(tm, "/basic_lti_link/x-secure/launch_key"))); setProperty(launch_info, "secret", StringUtils.stripToNull(XMLMap.getString(tm, "/basic_lti_link/x-secure/launch_secret"))); List<Map<String, Object>> theList = XMLMap.getList(tm, "/basic_lti_link/custom/parameter"); for (Map<String, Object> setting : theList) { dPrint("Setting=" + setting); String key = XMLMap.getString(setting, "/!key"); // Get the key attribute String value = XMLMap.getString(setting, "/"); // Get the value if (key == null || value == null) { continue; } key = "custom_" + mapKeyName(key); dPrint("key=" + key + " val=" + value); postProp.put(key, value); } return true; }
Example 11
Source File: ValueProviderParameterImpl.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
/** Sets the value of this parameter. Can be either {@code null} or empty. */ @Override public void setValue(String value) { this.value = StringUtils.stripToNull(value); }