/** * <p>Strips whitespace from the start and end of every String in an array. * Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <p>A new array is returned each time, except for length zero. * A {@code null} array will return {@code null}. * An empty array will return itself. * A {@code null} array entry will be ignored.</p> * * <pre> * StringUtils.stripAll(null) = null * StringUtils.stripAll([]) = [] * StringUtils.stripAll(["abc", " abc"]) = ["abc", "abc"] * StringUtils.stripAll(["abc ", null]) = ["abc", null] * </pre> * * @param strs the array to remove whitespace from, may be null * @return the stripped Strings, {@code null} if null array input */ public static String[] stripAll(final String... strs) { return stripAll(strs, null); }
@Test public void testStripAll() { // test stripAll method, merely an array version of the above strip final String[] empty = new String[0]; final String[] fooSpace = new String[] { " "+FOO+" ", " "+FOO, FOO+" " }; final String[] fooDots = new String[] { ".."+FOO+"..", ".."+FOO, FOO+".." }; final String[] foo = new String[] { FOO, FOO, FOO }; assertNull(StringUtils.stripAll((String[]) null)); // Additional varargs tests assertArrayEquals(empty, StringUtils.stripAll()); // empty array assertArrayEquals(new String[]{null}, StringUtils.stripAll((String) null)); // == new String[]{null} assertArrayEquals(empty, StringUtils.stripAll(empty)); assertArrayEquals(foo, StringUtils.stripAll(fooSpace)); assertNull(StringUtils.stripAll(null, null)); assertArrayEquals(foo, StringUtils.stripAll(fooSpace, null)); assertArrayEquals(foo, StringUtils.stripAll(fooDots, ".")); }
String[] tokens = StringUtils.stripAll(replacement.getSubstFonts().split(";"));
consumer.setComponentNameRegexExclude(context.getProperty(FILTER_COMPONENT_NAME_EXCLUDE).evaluateAttributeExpressions().getValue()); final String[] targetEventTypes = StringUtils.stripAll(StringUtils.split(context.getProperty(FILTER_EVENT_TYPE).evaluateAttributeExpressions().getValue(), ',')); if(targetEventTypes != null) { for(String type : targetEventTypes) { final String[] targetEventTypesExclude = StringUtils.stripAll(StringUtils.split(context.getProperty(FILTER_EVENT_TYPE_EXCLUDE).evaluateAttributeExpressions().getValue(), ',')); if(targetEventTypesExclude != null) { for(String type : targetEventTypesExclude) { final String[] targetComponentIds = StringUtils.stripAll(StringUtils.split(context.getProperty(FILTER_COMPONENT_ID).evaluateAttributeExpressions().getValue(), ',')); if(targetComponentIds != null) { consumer.addTargetComponentId(targetComponentIds); final String[] targetComponentIdsExclude = StringUtils.stripAll(StringUtils.split(context.getProperty(FILTER_COMPONENT_ID_EXCLUDE).evaluateAttributeExpressions().getValue(), ',')); if(targetComponentIdsExclude != null) { consumer.addTargetComponentIdExclude(targetComponentIdsExclude);
public String[] stripAll(String[] strs) { return StringUtils.stripAll(strs); }
/** * <p>Strips whitespace from the start and end of every String in an array. * Whitespace is defined by {@link CharUtils#isWhitespace(char)}.</p> * * <p>A new array is returned each time, except for length zero. * A {@code null} array will return {@code null}. * An empty array will return itself. * A {@code null} array entry will be ignored.</p> * * <pre> * StringUtils.stripAll(null) = null * StringUtils.stripAll([]) = [] * StringUtils.stripAll(["abc", " abc"]) = ["abc", "abc"] * StringUtils.stripAll(["abc ", null]) = ["abc", null] * </pre> * * @param strs the array to remove whitespace from, may be null * @return the stripped Strings, {@code null} if null array input */ public static String[] stripAll(final String... strs) { return stripAll(strs, null); }
/** * <p>Strips whitespace from the start and end of every String in an array. * Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <p>A new array is returned each time, except for length zero. * A {@code null} array will return {@code null}. * An empty array will return itself. * A {@code null} array entry will be ignored.</p> * * <pre> * StringUtils.stripAll(null) = null * StringUtils.stripAll([]) = [] * StringUtils.stripAll(["abc", " abc"]) = ["abc", "abc"] * StringUtils.stripAll(["abc ", null]) = ["abc", null] * </pre> * * @param strs the array to remove whitespace from, may be null * @return the stripped Strings, {@code null} if null array input */ public static String[] stripAll(final String... strs) { return stripAll(strs, null); }
/** * <p>Strips whitespace from the start and end of every String in an array. * Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <p>A new array is returned each time, except for length zero. * A {@code null} array will return {@code null}. * An empty array will return itself. * A {@code null} array entry will be ignored.</p> * * <pre> * StringUtils.stripAll(null) = null * StringUtils.stripAll([]) = [] * StringUtils.stripAll(["abc", " abc"]) = ["abc", "abc"] * StringUtils.stripAll(["abc ", null]) = ["abc", null] * </pre> * * @param strs the array to remove whitespace from, may be null * @return the stripped Strings, {@code null} if null array input */ public static String[] stripAll(final String... strs) { return stripAll(strs, null); }
public static List<String> getCleanStrings(final String value) { final List<String> values; if (value != null) { values = Lists.newArrayList(StringUtils.stripAll(value.split(SCHEMA_DEL_REGEX))); values.removeAll(STRINGS_TO_REMOVE); } else { values = null; } return values; }
private static String[] getNamesBetweenPlaceholders(String propertiesFilesString, String contextNamePlaceHolder) { final String[] names = StringUtils.substringsBetween( propertiesFilesString, PLACEHOLDER_PREFIX + contextNamePlaceHolder, PLACEHOLDER_SUFFIX); return StringUtils.stripAll(names); }
public void init(FilterConfig filterConfig) throws ServletException { // Construct our list of ignored urls String urls = WebloggerConfig.getProperty("salt.ignored.urls"); String[] urlsArray = StringUtils.stripAll(StringUtils.split(urls, ",")); for (int i = 0; i < urlsArray.length; i++) { this.ignored.add(urlsArray[i]); } }
protected PooledResourceOptions getPoolOptions(IpAddress ipAddress, Instance instance) { PooledResourceOptions options = new PooledResourceOptions(); if (instance != null) { String ip = DataAccessor.fieldString(instance, InstanceConstants.FIELD_REQUESTED_IP_ADDRESS); if (ip != null) { if(!StringUtils.isEmpty(ip)) { options.setRequestedItems(Arrays.asList(StringUtils.stripAll(StringUtils.split(ip, ",")))); } } } return options; }
String[] plugins = StringUtils.stripAll(StringUtils.split(pluginStr, ",")); for (int i=0; i < plugins.length; i++) { log.debug("trying " + plugins[i]);
InstanceConstants.FIELD_REQUESTED_IP_ADDRESS); if (requestedIpObj != null && !StringUtils.isEmpty(requestedIpObj.toString())) { requestedIps.addAll(Arrays.asList(StringUtils.stripAll(StringUtils.split(requestedIpObj.toString(), ",")))); } else { .get(SystemLabels.LABEL_REQUESTED_IP); if (!StringUtils.isEmpty(requestedIp)) { requestedIps.addAll(Arrays.asList(StringUtils.stripAll(StringUtils.split(requestedIp, ","))));
public static String[] stripAll(ActionContext actionContext){ Thing self = actionContext.getObject("self"); String[] strs = (String[]) self.doAction("getStrs", actionContext); String stripChars = (String) self.doAction("getStripChars", actionContext); return StringUtils.stripAll(strs, stripChars); }
CombinedConfiguration load() { // Allow foo/bar/baz and foo:bar:baz final String [] configNames = StringUtils.stripAll(StringUtils.split(configName, "/:")); final CombinedConfiguration cc = new CombinedConfiguration(new OverrideCombiner()); // All properties can be overridden by the System properties. cc.addConfiguration(new SystemConfiguration(), "systemProperties"); boolean loadedConfig = false; for (int i = 0; i < configNames.length; i++) { final String configFileName = configNames[configNames.length - i - 1]; final String configFilePath = StringUtils.join(configNames, "/", 0, configNames.length - i); try { final AbstractConfiguration subConfig = configStrategy.load(configFileName, configFilePath); if (subConfig == null) { LOG.debug("Configuration '%s' does not exist, skipping", configFileName); } else { cc.addConfiguration(subConfig, configFileName); loadedConfig = true; } } catch (ConfigurationException ce) { LOG.error(String.format("While loading configuration '%s'", configFileName), ce); } } if (!loadedConfig && configNames.length > 0) { LOG.warn("Config name '%s' was given but no config file could be found, this looks fishy!", configName); } return cc; }
protected IPAssignment allocateIp(IpAddress ipAddress, Network network) { Instance instance = getInstanceForPrimaryIp(ipAddress); IPAssignment ip = null; String requestedIp = null; if (instance != null) { String allocatedIpAddress = DataAccessor .fieldString(instance, InstanceConstants.FIELD_ALLOCATED_IP_ADDRESS); if (allocatedIpAddress != null) { ip = new IPAssignment(allocatedIpAddress, null); } requestedIp = DataAccessor.fieldString(instance, InstanceConstants.FIELD_REQUESTED_IP_ADDRESS); } if (ip == null) { List<String> list = new ArrayList<>(); if (!StringUtils.isEmpty(requestedIp)) { list = Arrays.asList(StringUtils.stripAll(StringUtils.split(requestedIp, ","))); } ip = networkService.assignIpAddress(network, ipAddress, list); if (ip == null) { objectProcessManager.scheduleStandardProcess(StandardProcess.DEACTIVATE, ipAddress, null); throw new ResourceExhaustionException("IP allocation error", "Failed to allocate IP from subnet", ipAddress); } } return ip; }
@Test public void stringUtils() { String s1 = "hello, world,test ,bla"; TestUtils.assertArrayEquals(new String[] {"hello", " world", "test ", "bla"}, StringUtils.split(s1, ',')); TestUtils.assertArrayEquals(new String[] {"hello", "world", "test", "bla"}, StringUtils.stripAll(StringUtils.split(s1, ','))); } }
consumer.setComponentNameRegexExclude(context.getProperty(FILTER_COMPONENT_NAME_EXCLUDE).evaluateAttributeExpressions().getValue()); final String[] targetEventTypes = StringUtils.stripAll(StringUtils.split(context.getProperty(FILTER_EVENT_TYPE).evaluateAttributeExpressions().getValue(), ',')); if(targetEventTypes != null) { for(String type : targetEventTypes) { final String[] targetEventTypesExclude = StringUtils.stripAll(StringUtils.split(context.getProperty(FILTER_EVENT_TYPE_EXCLUDE).evaluateAttributeExpressions().getValue(), ',')); if(targetEventTypesExclude != null) { for(String type : targetEventTypesExclude) { final String[] targetComponentIds = StringUtils.stripAll(StringUtils.split(context.getProperty(FILTER_COMPONENT_ID).evaluateAttributeExpressions().getValue(), ',')); if(targetComponentIds != null) { consumer.addTargetComponentId(targetComponentIds); final String[] targetComponentIdsExclude = StringUtils.stripAll(StringUtils.split(context.getProperty(FILTER_COMPONENT_ID_EXCLUDE).evaluateAttributeExpressions().getValue(), ',')); if(targetComponentIdsExclude != null) { consumer.addTargetComponentIdExclude(targetComponentIdsExclude);
this.headers = StringUtils.stripAll(headers); this.clazz = beanType;