org.springframework.util.StringUtils.commaDelimitedListToStringArray()

Here are the examples of the java api org.springframework.util.StringUtils.commaDelimitedListToStringArray() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

82 Examples 7

19 Source : RandomValuePropertySource.java
with Apache License 2.0
from yuanmabiji

private int getNextIntInRange(String range) {
    String[] tokens = StringUtils.commaDelimitedListToStringArray(range);
    int start = Integer.parseInt(tokens[0]);
    if (tokens.length == 1) {
        return getSource().nextInt(start);
    }
    return start + getSource().nextInt(Integer.parseInt(tokens[1]) - start);
}

19 Source : RandomValuePropertySource.java
with Apache License 2.0
from yuanmabiji

private long getNextLongInRange(String range) {
    String[] tokens = StringUtils.commaDelimitedListToStringArray(range);
    if (tokens.length == 1) {
        return Math.abs(getSource().nextLong() % Long.parseLong(tokens[0]));
    }
    long lowerBound = Long.parseLong(tokens[0]);
    long upperBound = Long.parseLong(tokens[1]) - lowerBound;
    return lowerBound + Math.abs(getSource().nextLong() % upperBound);
}

19 Source : ConditionPropertySource.java
with MIT License
from yizzuide

private boolean getBoolValue(String range) {
    range = StringUtils.trimAllWhitespace(range);
    String[] parts = StringUtils.commaDelimitedListToStringArray(range);
    if (parts.length != 2) {
        throw new IllegalArgumentException("Condition.bool set args error.");
    }
    return parts[0].equals(parts[1]);
}

19 Source : CCPropertyPlaceholderConfigurer.java
with Apache License 2.0
from warlock-china

private List<String> parseAllRemoteUrls(Properties config) throws FileNotFoundException, IOException {
    List<String> result = new ArrayList<>();
    // 应用私有配置文件
    String fileNames = config.getProperty("app.config.files");
    if (org.apache.commons.lang3.StringUtils.isNotBlank(fileNames)) {
        String[] appFiles = StringUtils.commaDelimitedListToStringArray(fileNames);
        for (String file : appFiles) {
            result.add(String.format("%s/download?app=%s&env=%s&ver=%s&file=%s", apiBaseUrl, app, env, version, file));
        }
    }
    // 全局配置文件
    fileNames = config.getProperty("global.config.files");
    if (org.apache.commons.lang3.StringUtils.isNotBlank(fileNames)) {
        String[] appFiles = StringUtils.commaDelimitedListToStringArray(fileNames);
        for (String file : appFiles) {
            result.add(String.format("%s/download?app=global&env=%s&ver=%s&file=%s", apiBaseUrl, env, version, file));
        }
    }
    return result;
}

19 Source : ScriptTemplateView.java
with MIT License
from Vip-Augus

/**
 * See {@link ScriptTemplateConfigurer#setResourceLoaderPath(String)} doreplacedentation.
 */
public void setResourceLoaderPath(String resourceLoaderPath) {
    String[] paths = StringUtils.commaDelimitedListToStringArray(resourceLoaderPath);
    this.resourceLoaderPaths = new String[paths.length + 1];
    this.resourceLoaderPaths[0] = "";
    for (int i = 0; i < paths.length; i++) {
        String path = paths[i];
        if (!path.endsWith("/") && !path.endsWith(":")) {
            path = path + "/";
        }
        this.resourceLoaderPaths[i + 1] = path;
    }
}

19 Source : TxAdviceBeanDefinitionParser.java
with MIT License
from Vip-Augus

private void addRollbackRuleAttributesTo(List<RollbackRuleAttribute> rollbackRules, String rollbackForValue) {
    String[] exceptionTypeNames = StringUtils.commaDelimitedListToStringArray(rollbackForValue);
    for (String typeName : exceptionTypeNames) {
        rollbackRules.add(new RollbackRuleAttribute(StringUtils.trimWhitespace(typeName)));
    }
}

19 Source : TxAdviceBeanDefinitionParser.java
with MIT License
from Vip-Augus

private void addNoRollbackRuleAttributesTo(List<RollbackRuleAttribute> rollbackRules, String noRollbackForValue) {
    String[] exceptionTypeNames = StringUtils.commaDelimitedListToStringArray(noRollbackForValue);
    for (String typeName : exceptionTypeNames) {
        rollbackRules.add(new NoRollbackRuleAttribute(StringUtils.trimWhitespace(typeName)));
    }
}

19 Source : CronSequenceGenerator.java
with MIT License
from Vip-Augus

/**
 * Replace the values in the comma-separated list (case insensitive)
 * with their index in the list.
 * @return a new String with the values from the list replaced
 */
private String replaceOrdinals(String value, String commaSeparatedList) {
    String[] list = StringUtils.commaDelimitedListToStringArray(commaSeparatedList);
    for (int i = 0; i < list.length; i++) {
        String item = list[i].toUpperCase();
        value = StringUtils.replace(value.toUpperCase(), item, "" + i);
    }
    return value;
}

19 Source : AbstractAspectJAdvice.java
with MIT License
from Vip-Augus

/**
 * Set by creator of this advice object if the argument names are known.
 * <p>This could be for example because they have been explicitly specified in XML,
 * or in an advice annotation.
 * @param argNames comma delimited list of arg names
 */
public void setArgumentNames(String argNames) {
    String[] tokens = StringUtils.commaDelimitedListToStringArray(argNames);
    setArgumentNamesFromStringArray(tokens);
}

19 Source : AbstractThinJarSupport.java
with Apache License 2.0
from spring-projects-experimental

private String[] getProfiles(AppDeploymentRequest request) {
    if (request.getDeploymentProperties().containsKey(AppDeployer.PREFIX + ThinJarLauncher.THIN_PROFILE)) {
        return StringUtils.commaDelimitedListToStringArray(request.getDeploymentProperties().get(AppDeployer.PREFIX + ThinJarLauncher.THIN_PROFILE));
    }
    return this.profiles;
}

19 Source : RandomServerPortPropertySource.java
with Apache License 2.0
from open-capacity-platform

private int getNextValueInRange(String range) {
    String[] tokens = StringUtils.commaDelimitedListToStringArray(range);
    int start = Integer.parseInt(tokens[0]);
    if (tokens.length == 1) {
        return getSource().nextValue(start);
    }
    return getSource().nextValue(start, Integer.parseInt(tokens[1]));
}

19 Source : StompHeaders.java
with Apache License 2.0
from langtianya

/**
 * Get the heartbeat header.
 */
public long[] getHeartbeat() {
    String rawValue = getFirst(HEARTBEAT);
    if (!StringUtils.hasText(rawValue)) {
        return null;
    }
    String[] rawValues = StringUtils.commaDelimitedListToStringArray(rawValue);
    return new long[] { Long.valueOf(rawValues[0]), Long.valueOf(rawValues[1]) };
}

19 Source : OsgiHeaderUtils.java
with Apache License 2.0
from eclipse

private static String[] getHeaderAsTrimmedStringArray(Bundle bundle, String header) {
    if (bundle == null || !StringUtils.hasText(header))
        return new String[0];
    String headerContent = (String) bundle.getHeaders().get(header);
    String[] entries = StringUtils.commaDelimitedListToStringArray(headerContent);
    for (int i = 0; i < entries.length; i++) {
        entries[i] = entries[i].trim();
    }
    return entries;
}

19 Source : MultiModuleConfigServicePropertySourceLocator.java
with Apache License 2.0
from baidu

public static List<ModuleConfiguration> loadApplicationNames(ClreplacedLoader clreplacedLoader) {
    try {
        Enumeration<URL> urls = (clreplacedLoader != null ? clreplacedLoader.getResources(SpringFactoriesLoader.FACTORIES_RESOURCE_LOCATION) : ClreplacedLoader.getSystemResources(SpringFactoriesLoader.FACTORIES_RESOURCE_LOCATION));
        return Collections.list(urls).stream().map(MultiModuleConfigServicePropertySourceLocator::loadProperties).filter(properties -> properties.getProperty(APPLICATION_NAME_KEY) != null).flatMap(props -> {
            String applicationName = props.getProperty(APPLICATION_NAME_KEY);
            String order = props.getProperty(APPLICATION_NAME_ORDER);
            return Stream.of(StringUtils.commaDelimitedListToStringArray(applicationName)).map(name -> new ModuleConfiguration(name, order == null ? 0 : Integer.parseInt(order)));
        }).collect(Collectors.toList());
    } catch (IOException ex) {
        throw new IllegalArgumentException("Unable to load multi module configuration " + "from location [" + SpringFactoriesLoader.FACTORIES_RESOURCE_LOCATION + "]", ex);
    }
}

18 Source : RabbitProperties.java
with Apache License 2.0
from yuanmabiji

private List<Address> parseAddresses(String addresses) {
    List<Address> parsedAddresses = new ArrayList<>();
    for (String address : StringUtils.commaDelimitedListToStringArray(addresses)) {
        parsedAddresses.add(new Address(address));
    }
    return parsedAddresses;
}

18 Source : NoUniqueBeanDefinitionFailureAnalyzer.java
with Apache License 2.0
from yuanmabiji

private String[] extractBeanNames(NoUniqueBeanDefinitionException cause) {
    if (cause.getMessage().indexOf("but found") > -1) {
        return StringUtils.commaDelimitedListToStringArray(cause.getMessage().substring(cause.getMessage().lastIndexOf(':') + 1).trim());
    }
    return null;
}

18 Source : HandshakeWebSocketService.java
with MIT License
from Vip-Augus

@Nullable
private String selectProtocol(HttpHeaders headers, WebSocketHandler handler) {
    String protocolHeader = headers.getFirst(SEC_WEBSOCKET_PROTOCOL);
    if (protocolHeader != null) {
        List<String> supportedProtocols = handler.getSubProtocols();
        for (String protocol : StringUtils.commaDelimitedListToStringArray(protocolHeader)) {
            if (supportedProtocols.contains(protocol)) {
                return protocol;
            }
        }
    }
    return null;
}

18 Source : AbstractEnvironment.java
with MIT License
from Vip-Augus

/**
 * Return the set of default profiles explicitly set via
 * {@link #setDefaultProfiles(String...)} or if the current set of default profiles
 * consists only of {@linkplain #getReservedDefaultProfiles() reserved default
 * profiles}, then check for the presence of the
 * {@value #DEFAULT_PROFILES_PROPERTY_NAME} property and replacedign its value (if any)
 * to the set of default profiles.
 * @see #AbstractEnvironment()
 * @see #getDefaultProfiles()
 * @see #DEFAULT_PROFILES_PROPERTY_NAME
 * @see #getReservedDefaultProfiles()
 */
protected Set<String> doGetDefaultProfiles() {
    synchronized (this.defaultProfiles) {
        if (this.defaultProfiles.equals(getReservedDefaultProfiles())) {
            String profiles = getProperty(DEFAULT_PROFILES_PROPERTY_NAME);
            if (StringUtils.hasText(profiles)) {
                setDefaultProfiles(StringUtils.commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(profiles)));
            }
        }
        return this.defaultProfiles;
    }
}

18 Source : AbstractEnvironment.java
with MIT License
from Vip-Augus

/**
 * Return the set of active profiles as explicitly set through
 * {@link #setActiveProfiles} or if the current set of active profiles
 * is empty, check for the presence of the {@value #ACTIVE_PROFILES_PROPERTY_NAME}
 * property and replacedign its value to the set of active profiles.
 * @see #getActiveProfiles()
 * @see #ACTIVE_PROFILES_PROPERTY_NAME
 */
protected Set<String> doGetActiveProfiles() {
    synchronized (this.activeProfiles) {
        if (this.activeProfiles.isEmpty()) {
            String profiles = getProperty(ACTIVE_PROFILES_PROPERTY_NAME);
            if (StringUtils.hasText(profiles)) {
                setActiveProfiles(StringUtils.commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(profiles)));
            }
        }
        return this.activeProfiles;
    }
}

18 Source : ClassArrayEditor.java
with MIT License
from Vip-Augus

@Override
public void setAsText(String text) throws IllegalArgumentException {
    if (StringUtils.hasText(text)) {
        String[] clreplacedNames = StringUtils.commaDelimitedListToStringArray(text);
        Clreplaced<?>[] clreplacedes = new Clreplaced<?>[clreplacedNames.length];
        for (int i = 0; i < clreplacedNames.length; i++) {
            String clreplacedName = clreplacedNames[i].trim();
            clreplacedes[i] = ClreplacedUtils.resolveClreplacedName(clreplacedName, this.clreplacedLoader);
        }
        setValue(clreplacedes);
    } else {
        setValue(null);
    }
}

18 Source : BeanUtils.java
with MIT License
from Vip-Augus

/**
 * Parse a method signature in the form {@code methodName[([arg_list])]},
 * where {@code arg_list} is an optional, comma-separated list of fully-qualified
 * type names, and attempts to resolve that signature against the supplied {@code Clreplaced}.
 * <p>When not supplying an argument list ({@code methodName}) the method whose name
 * matches and has the least number of parameters will be returned. When supplying an
 * argument type list, only the method whose name and argument types match will be returned.
 * <p>Note then that {@code methodName} and {@code methodName()} are <strong>not</strong>
 * resolved in the same way. The signature {@code methodName} means the method called
 * {@code methodName} with the least number of arguments, whereas {@code methodName()}
 * means the method called {@code methodName} with exactly 0 arguments.
 * <p>If no method can be found, then {@code null} is returned.
 * @param signature the method signature as String representation
 * @param clazz the clreplaced to resolve the method signature against
 * @return the resolved Method
 * @see #findMethod
 * @see #findMethodWithMinimalParameters
 */
@Nullable
public static Method resolveSignature(String signature, Clreplaced<?> clazz) {
    replacedert.hasText(signature, "'signature' must not be empty");
    replacedert.notNull(clazz, "Clreplaced must not be null");
    int startParen = signature.indexOf('(');
    int endParen = signature.indexOf(')');
    if (startParen > -1 && endParen == -1) {
        throw new IllegalArgumentException("Invalid method signature '" + signature + "': expected closing ')' for args list");
    } else if (startParen == -1 && endParen > -1) {
        throw new IllegalArgumentException("Invalid method signature '" + signature + "': expected opening '(' for args list");
    } else if (startParen == -1) {
        return findMethodWithMinimalParameters(clazz, signature);
    } else {
        String methodName = signature.substring(0, startParen);
        String[] parameterTypeNames = StringUtils.commaDelimitedListToStringArray(signature.substring(startParen + 1, endParen));
        Clreplaced<?>[] parameterTypes = new Clreplaced<?>[parameterTypeNames.length];
        for (int i = 0; i < parameterTypeNames.length; i++) {
            String parameterTypeName = parameterTypeNames[i].trim();
            try {
                parameterTypes[i] = ClreplacedUtils.forName(parameterTypeName, clazz.getClreplacedLoader());
            } catch (Throwable ex) {
                throw new IllegalArgumentException("Invalid method signature: unable to resolve type [" + parameterTypeName + "] for argument " + i + ". Root cause: " + ex);
            }
        }
        return findMethod(clazz, methodName, parameterTypes);
    }
}

18 Source : RabbitProperties.java
with Apache License 2.0
from spring-avengers

private List<Address> parseAddresses(String addresses) {
    List<Address> parsedAddresses = new ArrayList<Address>();
    for (String address : StringUtils.commaDelimitedListToStringArray(addresses)) {
        parsedAddresses.add(new Address(address));
    }
    return parsedAddresses;
}

18 Source : AbstractEnvironment.java
with Apache License 2.0
from SourceHot

/**
 * Return the set of active profiles as explicitly set through
 * {@link #setActiveProfiles} or if the current set of active profiles
 * is empty, check for the presence of the {@value #ACTIVE_PROFILES_PROPERTY_NAME}
 * property and replacedign its value to the set of active profiles.
 * @see #getActiveProfiles()
 * @see #ACTIVE_PROFILES_PROPERTY_NAME
 */
protected Set<String> doGetActiveProfiles() {
    synchronized (this.activeProfiles) {
        if (this.activeProfiles.isEmpty()) {
            // 通过 PropertySourcesPropertyResolver 获取prfiles
            String profiles = getProperty(ACTIVE_PROFILES_PROPERTY_NAME);
            if (StringUtils.hasText(profiles)) {
                // 设置 profile
                // 1. 按照逗号切分
                // 2. 设置
                setActiveProfiles(StringUtils.commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(profiles)));
            }
        }
        return this.activeProfiles;
    }
}

18 Source : AbstractEnvironment.java
with Apache License 2.0
from SourceHot

/**
 * Return the set of default profiles explicitly set via
 * {@link #setDefaultProfiles(String...)} or if the current set of default profiles
 * consists only of {@linkplain #getReservedDefaultProfiles() reserved default
 * profiles}, then check for the presence of the
 * {@value #DEFAULT_PROFILES_PROPERTY_NAME} property and replacedign its value (if any)
 * to the set of default profiles.
 * @see #AbstractEnvironment()
 * @see #getDefaultProfiles()
 * @see #DEFAULT_PROFILES_PROPERTY_NAME
 * @see #getReservedDefaultProfiles()
 */
protected Set<String> doGetDefaultProfiles() {
    synchronized (this.defaultProfiles) {
        // 1. 获取默认的 profile
        if (this.defaultProfiles.equals(getReservedDefaultProfiles())) {
            String profiles = getProperty(DEFAULT_PROFILES_PROPERTY_NAME);
            if (StringUtils.hasText(profiles)) {
                // 设置默认的 profile
                setDefaultProfiles(StringUtils.commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(profiles)));
            }
        }
        return this.defaultProfiles;
    }
}

18 Source : BeanUtils.java
with Apache License 2.0
from SourceHot

/**
 * Parse a method signature in the form {@code methodName[([arg_list])]}, where {@code arg_list}
 * is an optional, comma-separated list of fully-qualified type names, and attempts to resolve
 * that signature against the supplied {@code Clreplaced}.
 * <p>When not supplying an argument list ({@code methodName}) the method whose name
 * matches and has the least number of parameters will be returned. When supplying an argument
 * type list, only the method whose name and argument types match will be returned.
 * <p>Note then that {@code methodName} and {@code methodName()} are <strong>not</strong>
 * resolved in the same way. The signature {@code methodName} means the method called {@code
 * methodName} with the least number of arguments, whereas {@code methodName()} means the method
 * called {@code methodName} with exactly 0 arguments.
 * <p>If no method can be found, then {@code null} is returned.
 *
 * 函数签名解析
 * @param signature the method signature as String representation
 * @param clazz     the clreplaced to resolve the method signature against
 *
 * @return the resolved Method
 *
 * @see #findMethod
 * @see #findMethodWithMinimalParameters
 */
@Nullable
public static Method resolveSignature(String signature, Clreplaced<?> clazz) {
    replacedert.hasText(signature, "'signature' must not be empty");
    replacedert.notNull(clazz, "Clreplaced must not be null");
    int startParen = signature.indexOf('(');
    int endParen = signature.indexOf(')');
    if (startParen > -1 && endParen == -1) {
        throw new IllegalArgumentException("Invalid method signature '" + signature + "': expected closing ')' for args list");
    } else if (startParen == -1 && endParen > -1) {
        throw new IllegalArgumentException("Invalid method signature '" + signature + "': expected opening '(' for args list");
    } else if (startParen == -1) {
        return findMethodWithMinimalParameters(clazz, signature);
    } else {
        // 函数名
        String methodName = signature.substring(0, startParen);
        // 参数类型列表
        String[] parameterTypeNames = StringUtils.commaDelimitedListToStringArray(signature.substring(startParen + 1, endParen));
        Clreplaced<?>[] parameterTypes = new Clreplaced<?>[parameterTypeNames.length];
        for (int i = 0; i < parameterTypeNames.length; i++) {
            // 参数类型名获取
            String parameterTypeName = parameterTypeNames[i].trim();
            try {
                parameterTypes[i] = ClreplacedUtils.forName(parameterTypeName, clazz.getClreplacedLoader());
            } catch (Throwable ex) {
                throw new IllegalArgumentException("Invalid method signature: unable to resolve type [" + parameterTypeName + "] for argument " + i + ". Root cause: " + ex);
            }
        }
        return findMethod(clazz, methodName, parameterTypes);
    }
}

18 Source : ControlUtils.java
with Apache License 2.0
from muxiangqiu

private static Set<String> getComponentPermissionSupportTypes() {
    if (componentPermissionSupportTypes != null) {
        return componentPermissionSupportTypes;
    }
    String componentPermissionSupportType = Configure.getString("bdf3.componentPermissionSupportType");
    if (!StringUtils.isEmpty(componentPermissionSupportType)) {
        String[] types = StringUtils.commaDelimitedListToStringArray(componentPermissionSupportType);
        componentPermissionSupportTypes = new HashSet<>();
        for (String t : types) {
            componentPermissionSupportTypes.add(t);
        }
    }
    return componentPermissionSupportTypes;
}

18 Source : AbstractTyrusRequestUpgradeStrategy.java
with Apache License 2.0
from langtianya

@Override
public String[] getSupportedVersions() {
    return StringUtils.commaDelimitedListToStringArray(Version.getSupportedWireProtocolVersions());
}

18 Source : ScriptTemplateView.java
with Apache License 2.0
from langtianya

protected ClreplacedLoader createClreplacedLoader() {
    String[] paths = StringUtils.commaDelimitedListToStringArray(this.resourceLoaderPath);
    List<URL> urls = new ArrayList<URL>();
    try {
        for (String path : paths) {
            Resource[] resources = getApplicationContext().getResources(path);
            if (resources.length > 0) {
                for (Resource resource : resources) {
                    if (resource.exists()) {
                        urls.add(resource.getURL());
                    }
                }
            }
        }
    } catch (IOException ex) {
        throw new IllegalStateException("Cannot create clreplaced loader: " + ex.getMessage());
    }
    ClreplacedLoader clreplacedLoader = getApplicationContext().getClreplacedLoader();
    return (urls.size() > 0 ? new URLClreplacedLoader(urls.toArray(new URL[urls.size()]), clreplacedLoader) : clreplacedLoader);
}

18 Source : StompHeaderAccessor.java
with Apache License 2.0
from langtianya

public long[] getHeartbeat() {
    String rawValue = getFirstNativeHeader(STOMP_HEARTBEAT_HEADER);
    if (!StringUtils.hasText(rawValue)) {
        return Arrays.copyOf(DEFAULT_HEARTBEAT, 2);
    }
    String[] rawValues = StringUtils.commaDelimitedListToStringArray(rawValue);
    return new long[] { Long.valueOf(rawValues[0]), Long.valueOf(rawValues[1]) };
}

18 Source : AbstractConfigurableBundleCreatorTests.java
with Apache License 2.0
from eclipse

/**
 * {@inheritDoc}
 * <p/>
 * <p/>Ant-style patterns for identifying the resources added to the jar.The
 * patterns are considered from the root path when performing the search.
 * <p/>
 * <p/> By default, the content pattern is <code>**/*</code> which
 * includes all sources from the root. One can configure the pattern to
 * include specific files by using different patterns. For example, to
 * include just the clreplacedes, XML and properties files one can use the
 * following patterns:
 * <ol>
 * <li><code>**/*.clreplaced</code> for clreplacedes
 * <li><code>**/*.xml</code> for XML files
 * <li><code>**/*.properties</code> for properties files
 * </ol>
 *
 * @return array of Ant-style pattern
 */
protected String[] getBundleContentPattern() {
    return StringUtils.commaDelimitedListToStringArray(jarSettings.getProperty(INCLUDE_PATTERNS));
}

18 Source : KubernetesSettings.java
with Apache License 2.0
from citrusframework

/**
 * Read labels for Kubernetes resources created by the test. The environment setting should be a
 * comma delimited list of key-value pairs.
 * @return
 */
public static Map<String, String> getDefaultLabels() {
    String labelsConfig = System.getProperty(DEFAULT_LABELS_PROPERTY, System.getenv(DEFAULT_LABELS_ENV) != null ? System.getenv(DEFAULT_LABELS_ENV) : DEFAULT_LABELS_DEFAULT);
    return Stream.of(StringUtils.commaDelimitedListToStringArray(labelsConfig)).map(item -> StringUtils.delimitedListToStringArray(item, "=")).filter(keyValue -> keyValue.length == 2).collect(Collectors.toMap(item -> item[0], item -> item[1]));
}

18 Source : KnativeSettings.java
with Apache License 2.0
from citrusframework

/**
 * Read labels for K8s resources created by the test. The environment setting should be a
 * comma delimited list of key-value pairs.
 * @return
 */
public static Map<String, String> getDefaultLabels() {
    String labelsConfig = System.getProperty(DEFAULT_LABELS_PROPERTY, System.getenv(DEFAULT_LABELS_ENV));
    if (labelsConfig == null) {
        return KubernetesSettings.getDefaultLabels();
    }
    return Stream.of(StringUtils.commaDelimitedListToStringArray(labelsConfig)).map(item -> StringUtils.delimitedListToStringArray(item, "=")).filter(keyValue -> keyValue.length == 2).collect(Collectors.toMap(item -> item[0], item -> item[1]));
}

17 Source : WebUtils.java
with MIT License
from Vip-Augus

/**
 * Parse the given string with matrix variables. An example string would look
 * like this {@code "q1=a;q1=b;q2=a,b,c"}. The resulting map would contain
 * keys {@code "q1"} and {@code "q2"} with values {@code ["a","b"]} and
 * {@code ["a","b","c"]} respectively.
 * @param matrixVariables the unparsed matrix variables string
 * @return a map with matrix variable names and values (never {@code null})
 * @since 3.2
 */
public static MultiValueMap<String, String> parseMatrixVariables(String matrixVariables) {
    MultiValueMap<String, String> result = new LinkedMultiValueMap<>();
    if (!StringUtils.hasText(matrixVariables)) {
        return result;
    }
    StringTokenizer pairs = new StringTokenizer(matrixVariables, ";");
    while (pairs.hasMoreTokens()) {
        String pair = pairs.nextToken();
        int index = pair.indexOf('=');
        if (index != -1) {
            String name = pair.substring(0, index);
            String rawValue = pair.substring(index + 1);
            for (String value : StringUtils.commaDelimitedListToStringArray(rawValue)) {
                result.add(name, value);
            }
        } else {
            result.add(pair, "");
        }
    }
    return result;
}

17 Source : StringToArrayConverter.java
with MIT License
from Vip-Augus

@Override
@Nullable
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
    if (source == null) {
        return null;
    }
    String string = (String) source;
    String[] fields = StringUtils.commaDelimitedListToStringArray(string);
    TypeDescriptor targetElementType = targetType.getElementTypeDescriptor();
    replacedert.state(targetElementType != null, "No target element type");
    Object target = Array.newInstance(targetElementType.getType(), fields.length);
    for (int i = 0; i < fields.length; i++) {
        String sourceElement = fields[i];
        Object targetElement = this.conversionService.convert(sourceElement.trim(), sourceType, targetElementType);
        Array.set(target, i, targetElement);
    }
    return target;
}

17 Source : ScriptServiceImpl.java
with Apache License 2.0
from muxiangqiu

private List<Resource> getResources(String locations) {
    List<Resource> resources = new ArrayList<Resource>();
    for (String location : StringUtils.commaDelimitedListToStringArray(locations)) {
        try {
            for (Resource resource : this.applicationContext.getResources(location)) {
                if (resource.exists()) {
                    resources.add(resource);
                }
            }
        } catch (IOException ex) {
            throw new IllegalStateException("Unable to load resource from " + location, ex);
        }
    }
    return resources;
}

17 Source : WebUtils.java
with Apache License 2.0
from langtianya

/**
 * Parse the given string with matrix variables. An example string would look
 * like this {@code "q1=a;q1=b;q2=a,b,c"}. The resulting map would contain
 * keys {@code "q1"} and {@code "q2"} with values {@code ["a","b"]} and
 * {@code ["a","b","c"]} respectively.
 * @param matrixVariables the unparsed matrix variables string
 * @return a map with matrix variable names and values (never {@code null})
 * @since 3.2
 */
public static MultiValueMap<String, String> parseMatrixVariables(String matrixVariables) {
    MultiValueMap<String, String> result = new LinkedMultiValueMap<String, String>();
    if (!StringUtils.hasText(matrixVariables)) {
        return result;
    }
    StringTokenizer pairs = new StringTokenizer(matrixVariables, ";");
    while (pairs.hasMoreTokens()) {
        String pair = pairs.nextToken();
        int index = pair.indexOf('=');
        if (index != -1) {
            String name = pair.substring(0, index);
            String rawValue = pair.substring(index + 1);
            for (String value : StringUtils.commaDelimitedListToStringArray(rawValue)) {
                result.add(name, value);
            }
        } else {
            result.add(pair, "");
        }
    }
    return result;
}

17 Source : StringToArrayConverter.java
with Apache License 2.0
from langtianya

@Override
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
    if (source == null) {
        return null;
    }
    String string = (String) source;
    String[] fields = StringUtils.commaDelimitedListToStringArray(string);
    Object target = Array.newInstance(targetType.getElementTypeDescriptor().getType(), fields.length);
    for (int i = 0; i < fields.length; i++) {
        String sourceElement = fields[i];
        Object targetElement = this.conversionService.convert(sourceElement.trim(), sourceType, targetType.getElementTypeDescriptor());
        Array.set(target, i, targetElement);
    }
    return target;
}

17 Source : BeanUtils.java
with Apache License 2.0
from langtianya

/**
 * Parse a method signature in the form {@code methodName[([arg_list])]},
 * where {@code arg_list} is an optional, comma-separated list of fully-qualified
 * type names, and attempts to resolve that signature against the supplied {@code Clreplaced}.
 * <p>When not supplying an argument list ({@code methodName}) the method whose name
 * matches and has the least number of parameters will be returned. When supplying an
 * argument type list, only the method whose name and argument types match will be returned.
 * <p>Note then that {@code methodName} and {@code methodName()} are <strong>not</strong>
 * resolved in the same way. The signature {@code methodName} means the method called
 * {@code methodName} with the least number of arguments, whereas {@code methodName()}
 * means the method called {@code methodName} with exactly 0 arguments.
 * <p>If no method can be found, then {@code null} is returned.
 * @param signature the method signature as String representation
 * @param clazz the clreplaced to resolve the method signature against
 * @return the resolved Method
 * @see #findMethod
 * @see #findMethodWithMinimalParameters
 */
public static Method resolveSignature(String signature, Clreplaced<?> clazz) {
    replacedert.hasText(signature, "'signature' must not be empty");
    replacedert.notNull(clazz, "Clreplaced must not be null");
    int firstParen = signature.indexOf("(");
    int lastParen = signature.indexOf(")");
    if (firstParen > -1 && lastParen == -1) {
        throw new IllegalArgumentException("Invalid method signature '" + signature + "': expected closing ')' for args list");
    } else if (lastParen > -1 && firstParen == -1) {
        throw new IllegalArgumentException("Invalid method signature '" + signature + "': expected opening '(' for args list");
    } else if (firstParen == -1 && lastParen == -1) {
        return findMethodWithMinimalParameters(clazz, signature);
    } else {
        String methodName = signature.substring(0, firstParen);
        String[] parameterTypeNames = StringUtils.commaDelimitedListToStringArray(signature.substring(firstParen + 1, lastParen));
        Clreplaced<?>[] parameterTypes = new Clreplaced<?>[parameterTypeNames.length];
        for (int i = 0; i < parameterTypeNames.length; i++) {
            String parameterTypeName = parameterTypeNames[i].trim();
            try {
                parameterTypes[i] = ClreplacedUtils.forName(parameterTypeName, clazz.getClreplacedLoader());
            } catch (Throwable ex) {
                throw new IllegalArgumentException("Invalid method signature: unable to resolve type [" + parameterTypeName + "] for argument " + i + ". Root cause: " + ex);
            }
        }
        return findMethod(clazz, methodName, parameterTypes);
    }
}

17 Source : N2oMessagesConfiguration.java
with Apache License 2.0
from i-novus-llc

@Bean("clientMessageSource")
@ConditionalOnMissingBean(name = "clientMessageSource")
public ExposedResourceBundleMessageSource clientMessageSource() {
    ExposedResourceBundleMessageSource messageSource = new ExposedResourceBundleMessageSource();
    messageSource.setDefaultEncoding("UTF-8");
    messageSource.addBasenames(StringUtils.commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(clientBasenames)));
    messageSource.setUseCodeAsDefaultMessage(useCodeAsDefaultMessage);
    return messageSource;
}

17 Source : AbstractDependencyManagerTests.java
with Apache License 2.0
from eclipse

/**
 * Locates (through the {@link ArtifactLocator}) an OSGi bundle given as a
 * String.
 *
 * The default implementation expects the argument to be in Comma Separated
 * Values (CSV) format which indicates an artifact group, id, version and
 * optionally the type.
 *
 * @param bundleId the bundle identifier in CSV format
 * @return a resource pointing to the artifact location
 */
protected Resource locateBundle(String bundleId) {
    replacedert.hasText(bundleId, "bundleId should not be empty");
    // parse the String
    String[] artifactId = StringUtils.commaDelimitedListToStringArray(bundleId);
    replacedert.isTrue(artifactId.length >= 3, "the CSV string " + bundleId + " contains too few values");
    // TODO: add a smarter mechanism which can handle 1 or 2 values CSVs
    for (int i = 0; i < artifactId.length; i++) {
        artifactId[i] = StringUtils.trimWhitespace(artifactId[i]);
    }
    ArtifactLocator aLocator = getLocator();
    return (artifactId.length == 3 ? aLocator.locateArtifact(artifactId[0], artifactId[1], artifactId[2]) : aLocator.locateArtifact(artifactId[0], artifactId[1], artifactId[2], artifactId[3]));
}

16 Source : DefaultPathContainer.java
with MIT License
from Vip-Augus

private static void parsePathParamValues(String input, Charset charset, MultiValueMap<String, String> output) {
    if (StringUtils.hasText(input)) {
        int index = input.indexOf('=');
        if (index != -1) {
            String name = input.substring(0, index);
            String value = input.substring(index + 1);
            for (String v : StringUtils.commaDelimitedListToStringArray(value)) {
                name = StringUtils.uriDecode(name, charset);
                if (StringUtils.hasText(name)) {
                    output.add(name, StringUtils.uriDecode(v, charset));
                }
            }
        } else {
            String name = StringUtils.uriDecode(input, charset);
            if (StringUtils.hasText(name)) {
                output.add(input, "");
            }
        }
    }
}

16 Source : TransactionAttributeEditor.java
with MIT License
from Vip-Augus

/**
 * Format is PROPAGATION_NAME,ISOLATION_NAME,readOnly,timeout_NNNN,+Exception1,-Exception2.
 * Null or the empty string means that the method is non transactional.
 */
@Override
public void setAsText(String text) throws IllegalArgumentException {
    if (StringUtils.hasLength(text)) {
        // tokenize it with ","
        String[] tokens = StringUtils.commaDelimitedListToStringArray(text);
        RuleBasedTransactionAttribute attr = new RuleBasedTransactionAttribute();
        for (String token : tokens) {
            // Trim leading and trailing whitespace.
            String trimmedToken = StringUtils.trimWhitespace(token.trim());
            // Check whether token contains illegal whitespace within text.
            if (StringUtils.containsWhitespace(trimmedToken)) {
                throw new IllegalArgumentException("Transaction attribute token contains illegal whitespace: [" + trimmedToken + "]");
            }
            // Check token type.
            if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_PROPAGATION)) {
                attr.setPropagationBehaviorName(trimmedToken);
            } else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_ISOLATION)) {
                attr.setIsolationLevelName(trimmedToken);
            } else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_TIMEOUT)) {
                String value = trimmedToken.substring(DefaultTransactionAttribute.PREFIX_TIMEOUT.length());
                attr.setTimeout(Integer.parseInt(value));
            } else if (trimmedToken.equals(RuleBasedTransactionAttribute.READ_ONLY_MARKER)) {
                attr.setReadOnly(true);
            } else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_COMMIT_RULE)) {
                attr.getRollbackRules().add(new NoRollbackRuleAttribute(trimmedToken.substring(1)));
            } else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_ROLLBACK_RULE)) {
                attr.getRollbackRules().add(new RollbackRuleAttribute(trimmedToken.substring(1)));
            } else {
                throw new IllegalArgumentException("Invalid transaction attribute token: [" + trimmedToken + "]");
            }
        }
        setValue(attr);
    } else {
        setValue(null);
    }
}

16 Source : StringToCollectionConverter.java
with MIT License
from Vip-Augus

@Override
@Nullable
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
    if (source == null) {
        return null;
    }
    String string = (String) source;
    String[] fields = StringUtils.commaDelimitedListToStringArray(string);
    TypeDescriptor elementDesc = targetType.getElementTypeDescriptor();
    Collection<Object> target = CollectionFactory.createCollection(targetType.getType(), (elementDesc != null ? elementDesc.getType() : null), fields.length);
    if (elementDesc == null) {
        for (String field : fields) {
            target.add(field.trim());
        }
    } else {
        for (String field : fields) {
            Object targetElement = this.conversionService.convert(field.trim(), sourceType, elementDesc);
            target.add(targetElement);
        }
    }
    return target;
}

16 Source : GitHubService.java
with Apache License 2.0
from spring-io

private String getNextUrl(HttpHeaders headers) {
    String links = headers.getFirst("Link");
    for (String link : StringUtils.commaDelimitedListToStringArray(links)) {
        Matcher matcher = LINK_PATTERN.matcher(link.trim());
        if (matcher.matches() && "next".equals(matcher.group(2))) {
            return matcher.group(1);
        }
    }
    return null;
}

16 Source : TransactionAttributeEditor.java
with MIT License
from mindcarver

/**
 * Format is PROPAGATION_NAME,ISOLATION_NAME,readOnly,timeout_NNNN,+Exception1,-Exception2.
 * Null or the empty string means that the method is non transactional.
 * @see java.beans.PropertyEditor#setAsText(java.lang.String)
 */
@Override
public void setAsText(String text) throws IllegalArgumentException {
    if (StringUtils.hasLength(text)) {
        // tokenize it with ","
        String[] tokens = StringUtils.commaDelimitedListToStringArray(text);
        RuleBasedTransactionAttribute attr = new RuleBasedTransactionAttribute();
        for (int i = 0; i < tokens.length; i++) {
            // Trim leading and trailing whitespace.
            String token = StringUtils.trimWhitespace(tokens[i].trim());
            // Check whether token contains illegal whitespace within text.
            if (StringUtils.containsWhitespace(token)) {
                throw new IllegalArgumentException("Transaction attribute token contains illegal whitespace: [" + token + "]");
            }
            // Check token type.
            if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_PROPAGATION)) {
                attr.setPropagationBehaviorName(token);
            } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ISOLATION)) {
                attr.setIsolationLevelName(token);
            } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_TIMEOUT)) {
                String value = token.substring(DefaultTransactionAttribute.PREFIX_TIMEOUT.length());
                attr.setTimeout(Integer.parseInt(value));
            } else if (token.equals(RuleBasedTransactionAttribute.READ_ONLY_MARKER)) {
                attr.setReadOnly(true);
            } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_COMMIT_RULE)) {
                attr.getRollbackRules().add(new NoRollbackRuleAttribute(token.substring(1)));
            } else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ROLLBACK_RULE)) {
                attr.getRollbackRules().add(new RollbackRuleAttribute(token.substring(1)));
            } else {
                throw new IllegalArgumentException("Invalid transaction attribute token: [" + token + "]");
            }
        }
        setValue(attr);
    } else {
        setValue(null);
    }
}

16 Source : GroovyMarkupConfigurer.java
with Apache License 2.0
from langtianya

/**
 * Create a parent ClreplacedLoader for Groovy to use as parent ClreplacedLoader
 * when loading and compiling templates.
 */
protected ClreplacedLoader createTemplateClreplacedLoader() throws IOException {
    String[] paths = StringUtils.commaDelimitedListToStringArray(getResourceLoaderPath());
    List<URL> urls = new ArrayList<URL>();
    for (String path : paths) {
        Resource[] resources = getApplicationContext().getResources(path);
        if (resources.length > 0) {
            for (Resource resource : resources) {
                if (resource.exists()) {
                    urls.add(resource.getURL());
                }
            }
        }
    }
    ClreplacedLoader clreplacedLoader = getApplicationContext().getClreplacedLoader();
    return (urls.size() > 0 ? new URLClreplacedLoader(urls.toArray(new URL[urls.size()]), clreplacedLoader) : clreplacedLoader);
}

16 Source : StringToCollectionConverter.java
with Apache License 2.0
from langtianya

@Override
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
    if (source == null) {
        return null;
    }
    String string = (String) source;
    String[] fields = StringUtils.commaDelimitedListToStringArray(string);
    TypeDescriptor elementDesc = targetType.getElementTypeDescriptor();
    Collection<Object> target = CollectionFactory.createCollection(targetType.getType(), (elementDesc != null ? elementDesc.getType() : null), fields.length);
    if (elementDesc == null) {
        for (String field : fields) {
            target.add(field.trim());
        }
    } else {
        for (String field : fields) {
            Object targetElement = this.conversionService.convert(field.trim(), sourceType, elementDesc);
            target.add(targetElement);
        }
    }
    return target;
}

16 Source : AbstractPropertyLoadingBeanDefinitionParser.java
with Apache License 2.0
from langtianya

@Override
protected void doParse(Element element, BeanDefinitionBuilder builder) {
    String location = element.getAttribute("location");
    if (StringUtils.hasLength(location)) {
        String[] locations = StringUtils.commaDelimitedListToStringArray(location);
        builder.addPropertyValue("locations", locations);
    }
    String propertiesRef = element.getAttribute("properties-ref");
    if (StringUtils.hasLength(propertiesRef)) {
        builder.addPropertyReference("properties", propertiesRef);
    }
    String fileEncoding = element.getAttribute("file-encoding");
    if (StringUtils.hasLength(fileEncoding)) {
        builder.addPropertyValue("fileEncoding", fileEncoding);
    }
    String order = element.getAttribute("order");
    if (StringUtils.hasLength(order)) {
        builder.addPropertyValue("order", Integer.valueOf(order));
    }
    builder.addPropertyValue("ignoreResourceNotFound", Boolean.valueOf(element.getAttribute("ignore-resource-not-found")));
    builder.addPropertyValue("localOverride", Boolean.valueOf(element.getAttribute("local-override")));
    builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
}

16 Source : AbstractEncryptablePropertyLoadingBeanDefinitionParser.java
with Apache License 2.0
from jasypt

@Override
protected void doParse(final Element element, final BeanDefinitionBuilder builder) {
    String location = element.getAttribute("location");
    if (StringUtils.hasLength(location)) {
        String[] locations = StringUtils.commaDelimitedListToStringArray(location);
        builder.addPropertyValue("locations", locations);
    }
    String propertiesRef = element.getAttribute("properties-ref");
    if (StringUtils.hasLength(propertiesRef)) {
        builder.addPropertyReference("properties", propertiesRef);
    }
    String fileEncoding = element.getAttribute("file-encoding");
    if (StringUtils.hasLength(fileEncoding)) {
        builder.addPropertyReference("fileEncoding", fileEncoding);
    }
    String order = element.getAttribute("order");
    if (StringUtils.hasLength(order)) {
        builder.addPropertyValue("order", Integer.valueOf(order));
    }
    builder.addPropertyValue("ignoreResourceNotFound", Boolean.valueOf(element.getAttribute("ignore-resource-not-found")));
    builder.addPropertyValue("localOverride", Boolean.valueOf(element.getAttribute("local-override")));
    builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
}

16 Source : N2oMessagesConfiguration.java
with Apache License 2.0
from i-novus-llc

@Bean("n2oMessageSource")
@ConditionalOnMissingBean(name = "n2oMessageSource")
public MessageSource n2oMessageSource() {
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setDefaultEncoding(encoding.name());
    messageSource.setCacheSeconds(cacheSeconds);
    messageSource.setFallbackToSystemLocale(false);
    messageSource.setBasenames(StringUtils.commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(basename)));
    return messageSource;
}

See More Examples