本文整理汇总了Java中org.springframework.util.StringUtils.commaDelimitedListToStringArray方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.commaDelimitedListToStringArray方法的具体用法?Java StringUtils.commaDelimitedListToStringArray怎么用?Java StringUtils.commaDelimitedListToStringArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.commaDelimitedListToStringArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: commaSeparatedStringToThrowablesCollection
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@ConfigurationPropertiesBinding
@Bean
public Converter<String, List<Class<? extends Throwable>>> commaSeparatedStringToThrowablesCollection() {
return new Converter<String, List<Class<? extends Throwable>>>() {
@Override
public List<Class<? extends Throwable>> convert(final String source) {
try {
final List<Class<? extends Throwable>> classes = new ArrayList<>();
for (final String className : StringUtils.commaDelimitedListToStringArray(source)) {
classes.add((Class<? extends Throwable>) ClassUtils.forName(className.trim(), getClass().getClassLoader()));
}
return classes;
} catch (final Exception e) {
throw new IllegalStateException(e);
}
}
};
}
示例2: locateBundle
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
* 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) {
Assert.hasText(bundleId, "bundleId should not be empty");
// parse the String
String[] artifactId = StringUtils.commaDelimitedListToStringArray(bundleId);
Assert.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]));
}
示例3: parseMatrixVariables
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
* 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}
*/
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;
}
示例4: init
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
public void init(ExtendedProperties configuration) {
this.resourceLoader = (org.springframework.core.io.ResourceLoader)
this.rsvc.getApplicationAttribute(SPRING_RESOURCE_LOADER);
String resourceLoaderPath = (String) this.rsvc.getApplicationAttribute(SPRING_RESOURCE_LOADER_PATH);
if (this.resourceLoader == null) {
throw new IllegalArgumentException(
"'resourceLoader' application attribute must be present for SpringResourceLoader");
}
if (resourceLoaderPath == null) {
throw new IllegalArgumentException(
"'resourceLoaderPath' application attribute must be present for SpringResourceLoader");
}
this.resourceLoaderPaths = StringUtils.commaDelimitedListToStringArray(resourceLoaderPath);
for (int i = 0; i < this.resourceLoaderPaths.length; i++) {
String path = this.resourceLoaderPaths[i];
if (!path.endsWith("/")) {
this.resourceLoaderPaths[i] = path + "/";
}
}
if (logger.isInfoEnabled()) {
logger.info("SpringResourceLoader for Velocity: using resource loader [" + this.resourceLoader +
"] and resource loader paths " + Arrays.asList(this.resourceLoaderPaths));
}
}
示例5: merge
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
<T extends CacheOperation> T merge(Element element, ReaderContext readerCtx, T op) {
String cache = element.getAttribute("cache");
// sanity check
String[] localCaches = caches;
if (StringUtils.hasText(cache)) {
localCaches = StringUtils.commaDelimitedListToStringArray(cache.trim());
} else {
if (caches == null) {
readerCtx.error("No cache specified specified for " + element.getNodeName(), element);
}
}
op.setCacheNames(localCaches);
op.setKey(getAttributeValue(element, "key", this.key));
op.setCondition(getAttributeValue(element, "condition", this.condition));
return op;
}
示例6: findOne
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
public Environment findOne(String application, String profile, String label) {
String[] profilesArray = StringUtils.commaDelimitedListToStringArray(profile);
List<String> profilesList = createProfiles(profilesArray);
List<String> labelsList = createLabels(label);
try {
List<DataPropertySource> dataPropertySourceList = sortJdbcPropertySourceBy(
sortJdbcPropertySourceBy(
dataRepository.loadPropertySources(application, profilesList, labelsList),
Comparator.comparingInt(source -> labelsList.indexOf(source.getLabel()))
),
Comparator.comparingInt(source -> profilesList.indexOf(source.getProfile()))
);
Environment environment = new Environment(application, profilesArray, label, null, null);
environment.addAll(dataPropertySourceList.stream().
map(jdbcPropertySource -> new PropertySource(
createSourceName(application, jdbcPropertySource),
internalYamlProcessor.flattenMap(jdbcPropertySource.getSource())
)
).
collect(Collectors.toList())
);
return environment;
} catch (Exception e) {
throw new IllegalStateException("Unable to load environment configuration", e);
}
}
示例7: getHeaderAsTrimmedStringArray
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
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;
}
示例8: Props
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
Props(Element root) {
String defaultCache = root.getAttribute("cache");
key = root.getAttribute("key");
condition = root.getAttribute("condition");
method = root.getAttribute(METHOD_ATTRIBUTE);
if (StringUtils.hasText(defaultCache)) {
caches = StringUtils.commaDelimitedListToStringArray(defaultCache.trim());
}
}
示例9: setIgnoredMethodMappings
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
* Set the mappings of bean keys to a comma-separated list of method names.
* <p>These method names are <b>ignored</b> when creating the management interface.
* <p>The property key must match the bean key and the property value must match
* the list of method names. When searching for method names to ignore for a bean,
* Spring will check these mappings first.
*/
public void setIgnoredMethodMappings(Properties mappings) {
this.ignoredMethodMappings = new HashMap<String, Set<String>>();
for (Enumeration<?> en = mappings.keys(); en.hasMoreElements();) {
String beanKey = (String) en.nextElement();
String[] methodNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey));
this.ignoredMethodMappings.put(beanKey, new HashSet<String>(Arrays.asList(methodNames)));
}
}
示例10: setMethodMappings
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
* Set the mappings of bean keys to a comma-separated list of method names.
* The property key should match the bean key and the property value should match
* the list of method names. When searching for method names for a bean, Spring
* will check these mappings first.
* @param mappings the mappins of bean keys to method names
*/
public void setMethodMappings(Properties mappings) {
this.methodMappings = new HashMap<String, Set<String>>();
for (Enumeration<?> en = mappings.keys(); en.hasMoreElements();) {
String beanKey = (String) en.nextElement();
String[] methodNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey));
this.methodMappings.put(beanKey, new HashSet<String>(Arrays.asList(methodNames)));
}
}
示例11: resolveSignature
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
* 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 Class}.
* <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 class to resolve the method signature against
* @return the resolved Method
* @see #findMethod
* @see #findMethodWithMinimalParameters
*/
public static Method resolveSignature(String signature, Class<?> clazz) {
Assert.hasText(signature, "'signature' must not be empty");
Assert.notNull(clazz, "Class 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));
Class<?>[] parameterTypes = new Class<?>[parameterTypeNames.length];
for (int i = 0; i < parameterTypeNames.length; i++) {
String parameterTypeName = parameterTypeNames[i].trim();
try {
parameterTypes[i] = ClassUtils.forName(parameterTypeName, clazz.getClassLoader());
}
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);
}
}
示例12: initVelocityResourceLoader
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
* Initialize a Velocity resource loader for the given VelocityEngine:
* either a standard Velocity FileResourceLoader or a SpringResourceLoader.
* <p>Called by {@code createVelocityEngine()}.
* @param velocityEngine the VelocityEngine to configure
* @param resourceLoaderPath the path to load Velocity resources from
* @see org.apache.velocity.runtime.resource.loader.FileResourceLoader
* @see SpringResourceLoader
* @see #initSpringResourceLoader
* @see #createVelocityEngine()
*/
protected void initVelocityResourceLoader(VelocityEngine velocityEngine, String resourceLoaderPath) {
if (isPreferFileSystemAccess()) {
// Try to load via the file system, fall back to SpringResourceLoader
// (for hot detection of template changes, if possible).
try {
StringBuilder resolvedPath = new StringBuilder();
String[] paths = StringUtils.commaDelimitedListToStringArray(resourceLoaderPath);
for (int i = 0; i < paths.length; i++) {
String path = paths[i];
Resource resource = getResourceLoader().getResource(path);
File file = resource.getFile(); // will fail if not resolvable in the file system
if (logger.isDebugEnabled()) {
logger.debug("Resource loader path [" + path + "] resolved to file [" + file.getAbsolutePath() + "]");
}
resolvedPath.append(file.getAbsolutePath());
if (i < paths.length - 1) {
resolvedPath.append(',');
}
}
velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "file");
velocityEngine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, "true");
velocityEngine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, resolvedPath.toString());
}
catch (IOException ex) {
if (logger.isDebugEnabled()) {
logger.debug("Cannot resolve resource loader path [" + resourceLoaderPath +
"] to [java.io.File]: using SpringResourceLoader", ex);
}
initSpringResourceLoader(velocityEngine, resourceLoaderPath);
}
}
else {
// Always load via SpringResourceLoader
// (without hot detection of template changes).
if (logger.isDebugEnabled()) {
logger.debug("File system access not preferred: using SpringResourceLoader");
}
initSpringResourceLoader(velocityEngine, resourceLoaderPath);
}
}
示例13: setAsText
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
* 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);
}
}
示例14: addRollbackRuleAttributesTo
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private void addRollbackRuleAttributesTo(List<RollbackRuleAttribute> rollbackRules, String rollbackForValue) {
String[] exceptionTypeNames = StringUtils.commaDelimitedListToStringArray(rollbackForValue);
for (String typeName : exceptionTypeNames) {
rollbackRules.add(new RollbackRuleAttribute(StringUtils.trimWhitespace(typeName)));
}
}
示例15: addNoRollbackRuleAttributesTo
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private void addNoRollbackRuleAttributesTo(List<RollbackRuleAttribute> rollbackRules, String noRollbackForValue) {
String[] exceptionTypeNames = StringUtils.commaDelimitedListToStringArray(noRollbackForValue);
for (String typeName : exceptionTypeNames) {
rollbackRules.add(new NoRollbackRuleAttribute(StringUtils.trimWhitespace(typeName)));
}
}