本文整理匯總了Java中org.springframework.util.StringUtils.tokenizeToStringArray方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.tokenizeToStringArray方法的具體用法?Java StringUtils.tokenizeToStringArray怎麽用?Java StringUtils.tokenizeToStringArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.tokenizeToStringArray方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: decorate
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
// 設置bean scope為version-refresh
definition.getBeanDefinition().setScope(VersionRefreshScope.SCOPE_NAME);
String[] dependsOn = null;
if (node instanceof Element) {
Element ele = (Element) node;
if (ele.hasAttribute(DEPENDS_ON)) {
dependsOn = StringUtils.tokenizeToStringArray(ele.getAttribute(DEPENDS_ON), ",");
}
}
// 注冊屬性依賴
DependencyConfigUtils.registerDependency(parserContext.getRegistry(), definition.getBeanName(), dependsOn);
return definition;
}
示例2: doParse
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
protected void doParse(Element element, BeanDefinitionBuilder bean) {
boolean fallbackToSystemLocale = false;
String[] basenames = null;
if (element.hasAttribute(FALLBACK_TO_SYSTEM_LOCALE)) {
fallbackToSystemLocale = Boolean.valueOf(element.getAttribute(FALLBACK_TO_SYSTEM_LOCALE));
}
if (element.hasAttribute(BASENAMES)) {
basenames = StringUtils.tokenizeToStringArray(element.getAttribute(BASENAMES), ",");
}
bean.addPropertyValue("fallbackToSystemLocale", fallbackToSystemLocale);
bean.addPropertyValue("basenames", basenames);
}
示例3: getLocationsFromHeader
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
/**
* Similar to {@link #getHeaderLocations(Dictionary)} but looks at a
* specified header directly.
*
* @param header header to look at
* @param defaultValue default locations if none is specified
* @return
*/
public static String[] getLocationsFromHeader(String header, String defaultValue) {
String[] ctxEntries;
if (StringUtils.hasText(header) && !(';' == header.charAt(0))) {
// get the config locations
String locations = StringUtils.tokenizeToStringArray(header, DIRECTIVE_SEPARATOR)[0];
// parse it into individual token
ctxEntries = StringUtils.tokenizeToStringArray(locations, CONTEXT_LOCATION_SEPARATOR);
// replace * with a 'digestable' location
for (int i = 0; i < ctxEntries.length; i++) {
if (CONFIG_WILDCARD.equals(ctxEntries[i]))
ctxEntries[i] = defaultValue;
}
}
else {
ctxEntries = new String[0];
}
return ctxEntries;
}
示例4: parse
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
/**
* Parse the given pattern expression.
*/
private void parse(String expression) throws IllegalArgumentException {
String[] fields = StringUtils.tokenizeToStringArray(expression, " ");
if (fields.length != 6) {
throw new IllegalArgumentException(String.format(
"Cron expression must consist of 6 fields (found %d in \"%s\")", fields.length, expression));
}
setNumberHits(this.seconds, fields[0], 0, 60);
setNumberHits(this.minutes, fields[1], 0, 60);
setNumberHits(this.hours, fields[2], 0, 24);
setDaysOfMonth(this.daysOfMonth, fields[3]);
setMonths(this.months, fields[4]);
setDays(this.daysOfWeek, replaceOrdinals(fields[5], "SUN,MON,TUE,WED,THU,FRI,SAT"), 8);
if (this.daysOfWeek.get(7)) {
// Sunday can be represented as 0 or 7
this.daysOfWeek.set(0);
this.daysOfWeek.clear(7);
}
}
示例5: postProcessConfigItems
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
@Override
public void postProcessConfigItems(long version, ConfigPropertySource propertySource) {
if (propertySource == null) { // 當前版本無屬性
return;
}
// 初始化propertySourceName
if (propertySourceName == null) {
if (environment.containsProperty(SPRING_PROPERTY_SOURCES)) {
propertySourceName = environment.getProperty(SPRING_PROPERTY_SOURCES);
} else {
propertySourceName = DEFAULT_PROPERTY_SOURCES;
}
}
// 從配置中心動態更新propertySourceName
if (propertySource.containsProperty(SPRING_PROPERTY_SOURCES)) {
propertySourceName = (String) propertySource.getProperty(SPRING_PROPERTY_SOURCES);
}
String[] propertySourceNames = StringUtils.tokenizeToStringArray(propertySourceName, DELIMITERS);
if (propertySourceNames != null) {
for (String name : propertySourceNames) {
if (StringUtils.isEmpty(name)) {
continue;
}
name = name.trim();
if (propertySource.containsProperty(name)) {
processPropertySource(propertySource, name);
}
}
}
}
示例6: getStringsFromLastExists
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
/**
* Converts content of last existing file in files to string array
*
* @throws IOException
*/
public static String[] getStringsFromLastExists(String delimiter, File... files) throws IOException {
String[] ret = new String[0];
for (File f : files) {
if (!f.exists())
continue;
String str = new String(FileCopyUtils.copyToByteArray(f), "UTF-8");
ret = StringUtils.tokenizeToStringArray(str, delimiter);
}
return ret;
}
示例7: getDirectiveValue
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
/**
* Return the directive value as a String. If the directive does not exist
* or is invalid (wrong format) a null string will be returned.
*
* @param header
* @param directive
* @return
*/
public static String getDirectiveValue(String header, String directive) {
Assert.notNull(header, "not-null header required");
Assert.notNull(directive, "not-null directive required");
String[] directives = StringUtils.tokenizeToStringArray(header, DIRECTIVE_SEPARATOR);
for (int i = 0; i < directives.length; i++) {
String[] splittedDirective = StringUtils.delimitedListToStringArray(directives[i].trim(), EQUALS);
if (splittedDirective.length == 2 && splittedDirective[0].equals(directive))
return splittedDirective[1];
}
return null;
}
示例8: parse
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
public BeanDefinition parse(Element element, ParserContext parserContext)
{
BeanDefinitionBuilder dwrController = BeanDefinitionBuilder.rootBeanDefinition(DwrController.class);
List configurators = new ManagedList();
configurators.add(new RuntimeBeanReference(DEFAULT_SPRING_CONFIGURATOR_ID));
dwrController.addPropertyValue("configurators", configurators);
String debug = element.getAttribute("debug");
if (StringUtils.hasText(debug))
{
dwrController.addPropertyValue("debug", debug);
}
String beanName = element.getAttribute(BeanDefinitionParserDelegate.ID_ATTRIBUTE);
String nameAttr = element.getAttribute(BeanDefinitionParserDelegate.NAME_ATTRIBUTE);
String[] aliases = null;
if (!StringUtils.hasText(beanName))
{
beanName = element.getAttribute("name");
}
else
{
String aliasName = element.getAttribute("name");
if (StringUtils.hasText(aliasName))
{
aliases = StringUtils.tokenizeToStringArray(nameAttr, BeanDefinitionParserDelegate.BEAN_NAME_DELIMITERS);
}
}
parseControllerParameters(dwrController, element);
BeanDefinitionHolder holder = new BeanDefinitionHolder(dwrController.getBeanDefinition(), beanName, aliases);
BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
return dwrController.getBeanDefinition();
}
示例9: doParse
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
private synchronized void doParse(Element element, ParserContext parserContext) {
String[] basePackages = StringUtils.tokenizeToStringArray(element.getAttribute("base-package"), ",; \t\n");
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);
if (!parserContext.getRegistry().containsBeanDefinition(CacheAdvisor.CACHE_ADVISOR_BEAN_NAME)) {
Object eleSource = parserContext.extractSource(element);
RootBeanDefinition configMapDef = new RootBeanDefinition(ConcurrentHashMap.class);
configMapDef.setSource(eleSource);
configMapDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
String configMapName = parserContext.getReaderContext().registerWithGeneratedName(configMapDef);
RootBeanDefinition interceptorDef = new RootBeanDefinition(JetCacheInterceptor.class);
interceptorDef.setSource(eleSource);
interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
interceptorDef.getPropertyValues().addPropertyValue(new PropertyValue("cacheConfigMap", new RuntimeBeanReference(configMapName)));
String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef);
RootBeanDefinition advisorDef = new RootBeanDefinition(CacheAdvisor.class);
advisorDef.setSource(eleSource);
advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("adviceBeanName", interceptorName));
advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("cacheConfigMap", new RuntimeBeanReference(configMapName)));
advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("basePackages", basePackages));
parserContext.getRegistry().registerBeanDefinition(CacheAdvisor.CACHE_ADVISOR_BEAN_NAME, advisorDef);
CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(),
eleSource);
compositeDef.addNestedComponent(new BeanComponentDefinition(configMapDef, configMapName));
compositeDef.addNestedComponent(new BeanComponentDefinition(interceptorDef, interceptorName));
compositeDef.addNestedComponent(new BeanComponentDefinition(advisorDef, CacheAdvisor.CACHE_ADVISOR_BEAN_NAME));
parserContext.registerComponent(compositeDef);
}
}
示例10: setInterceptorHandlers
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
public void setInterceptorHandlers(String interceptorHandlers) {
String[] handlerNames = StringUtils.tokenizeToStringArray(interceptorHandlers,
ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
for (String name : handlerNames) {
if (CacheHandler.NAME.equals(name)) {
this.interceptorHandlers.add(new CacheHandler());
cacheEnabled = true;
} else if (RwRouteHandler.NAME.equals(name)) {
this.interceptorHandlers.add(new RwRouteHandler());
rwRouteEnabled = true;
} else if (DatabaseRouteHandler.NAME.equals(name)) {
this.interceptorHandlers.add(new DatabaseRouteHandler());
dbShardEnabled = true;
} else if (PaginationHandler.NAME.equals(name)) {
this.interceptorHandlers.add(new PaginationHandler());
}
}
//排序
Collections.sort(this.interceptorHandlers, new Comparator<InterceptorHandler>() {
@Override
public int compare(InterceptorHandler o1, InterceptorHandler o2) {
return Integer.compare(o1.interceptorOrder(), o2.interceptorOrder());
}
});
}
示例11: maybeExtractVariableNamesFromArgs
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
/**
* Given an args pointcut body (could be {@code args} or {@code at_args}),
* add any candidate variable names to the given list.
*/
private void maybeExtractVariableNamesFromArgs(String argsSpec, List<String> varNames) {
if (argsSpec == null) {
return;
}
String[] tokens = StringUtils.tokenizeToStringArray(argsSpec, ",");
for (int i = 0; i < tokens.length; i++) {
tokens[i] = StringUtils.trimWhitespace(tokens[i]);
String varName = maybeExtractVariableName(tokens[i]);
if (varName != null) {
varNames.add(varName);
}
}
}
示例12: maybeBindPrimitiveArgsFromPointcutExpression
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
/**
* Match up args against unbound arguments of primitive types
*/
private void maybeBindPrimitiveArgsFromPointcutExpression() {
int numUnboundPrimitives = countNumberOfUnboundPrimitiveArguments();
if (numUnboundPrimitives > 1) {
throw new AmbiguousBindingException("Found '" + numUnboundPrimitives +
"' unbound primitive arguments with no way to distinguish between them.");
}
if (numUnboundPrimitives == 1) {
// Look for arg variable and bind it if we find exactly one...
List<String> varNames = new ArrayList<String>();
String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " ");
for (int i = 0; i < tokens.length; i++) {
if (tokens[i].equals("args") || tokens[i].startsWith("args(")) {
PointcutBody body = getPointcutBody(tokens, i);
i += body.numTokensConsumed;
maybeExtractVariableNamesFromArgs(body.text, varNames);
}
}
if (varNames.size() > 1) {
throw new AmbiguousBindingException("Found " + varNames.size() +
" candidate variable names but only one candidate binding slot when matching primitive args");
}
else if (varNames.size() == 1) {
// 1 primitive arg, and one candidate...
for (int i = 0; i < this.argumentTypes.length; i++) {
if (isUnbound(i) && this.argumentTypes[i].isPrimitive()) {
bindParameterName(i, varNames.get(0));
break;
}
}
}
}
}
示例13: setCacheNames
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
public void setCacheNames(String cacheNames) {
if (org.apache.commons.lang3.StringUtils.isBlank(cacheNames)) {
return;
}
String[] tmpcacheNames = StringUtils.tokenizeToStringArray(cacheNames,
ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
this.cacheNames = new ArrayList<>(Arrays.asList(tmpcacheNames));
}
示例14: setIgnoreUripattern
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
@Value("${web.token.ignore.uri.pattern}")
public void setIgnoreUripattern(String ignoreUripattern) {
if (!StringUtils.isEmpty(ignoreUripattern))
ignoreUriPatterns = StringUtils.tokenizeToStringArray(ignoreUripattern, ",");
}
示例15: parseComponentDefinitionElement
import org.springframework.util.StringUtils; //導入方法依賴的package包/類
/**
* Parses the supplied <code><bean></code> element. May return <code>null</code> if there were errors during
* parse. Errors are reported to the {@link org.springframework.beans.factory.parsing.ProblemReporter}.
*/
private BeanDefinitionHolder parseComponentDefinitionElement(Element ele, BeanDefinition containingBean) {
// extract bean name
String id = ele.getAttribute(BeanDefinitionParserDelegate.ID_ATTRIBUTE);
String nameAttr = ele.getAttribute(BeanDefinitionParserDelegate.NAME_ATTRIBUTE);
List<String> aliases = new ArrayList<String>(4);
if (StringUtils.hasLength(nameAttr)) {
String[] nameArr =
StringUtils.tokenizeToStringArray(nameAttr, BeanDefinitionParserDelegate.MULTI_VALUE_ATTRIBUTE_DELIMITERS);
aliases.addAll(Arrays.asList(nameArr));
}
String beanName = id;
if (!StringUtils.hasText(beanName) && !aliases.isEmpty()) {
beanName = (String) aliases.remove(0);
if (log.isDebugEnabled()) {
log.debug("No XML 'id' specified - using '" + beanName + "' as bean name and " + aliases
+ " as aliases");
}
}
if (containingBean == null) {
if (checkNameUniqueness(beanName, aliases, usedNames)) {
error("Bean name '" + beanName + "' is already used in this file", ele);
}
if (ParsingUtils.isReservedName(beanName, ele, parserContext)) {
error("Blueprint reserved name '" + beanName + "' cannot be used", ele);
}
}
AbstractBeanDefinition beanDefinition = parseBeanDefinitionElement(ele, beanName, containingBean);
if (beanDefinition != null) {
if (!StringUtils.hasText(beanName)) {
try {
if (containingBean != null) {
beanName =
ParsingUtils.generateBlueprintBeanName(beanDefinition, parserContext.getRegistry(),
true);
} else {
beanName =
ParsingUtils.generateBlueprintBeanName(beanDefinition, parserContext.getRegistry(),
false);
// TODO: should we support 2.0 behaviour (see below):
//
// Register an alias for the plain bean class name, if still possible,
// if the generator returned the class name plus a suffix.
// This is expected for Spring 1.2/2.0 backwards compatibility.
}
if (log.isDebugEnabled()) {
log.debug("Neither XML 'id' nor 'name' specified - " + "using generated bean name [" + beanName
+ "]");
}
} catch (Exception ex) {
error(ex.getMessage(), ele, ex);
return null;
}
}
return new BeanDefinitionHolder(beanDefinition, beanName);
}
return null;
}