Example usage for org.springframework.util StringUtils tokenizeToStringArray

List of usage examples for org.springframework.util StringUtils tokenizeToStringArray

Introduction

In this page you can find the example usage for org.springframework.util StringUtils tokenizeToStringArray.

Prototype

public static String[] tokenizeToStringArray(@Nullable String str, String delimiters) 

Source Link

Document

Tokenize the given String into a String array via a StringTokenizer .

Usage

From source file:de.itsvs.cwtrpc.controller.config.AutowiredRemoteServiceGroupConfigBeanDefinitionParser.java

@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    final String[] basePackages;
    ManagedList<BeanDefinition> filters;

    getBaseServiceConfigParser().update(element, parserContext, builder);

    if (element.hasAttribute(XmlNames.BASE_PACKAGES_ATTR)) {
        basePackages = StringUtils.tokenizeToStringArray(element.getAttribute(XmlNames.BASE_PACKAGES_ATTR),
                ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
        builder.addPropertyValue("basePackages", basePackages);
    }/* www  .j a va  2 s  . c  o m*/

    filters = new ManagedList<BeanDefinition>();
    for (Element child : DomUtils.getChildElementsByTagName(element, XmlNames.INCLUDE_FILTER_ELEMENT)) {
        filters.add(parseFilter(child, parserContext));
    }
    if (!filters.isEmpty()) {
        builder.addPropertyValue("includeFilters", filters);
    }

    filters = new ManagedList<BeanDefinition>();
    for (Element child : DomUtils.getChildElementsByTagName(element, XmlNames.EXCLUDE_FILTER_ELEMENT)) {
        filters.add(parseFilter(child, parserContext));
    }
    if (!filters.isEmpty()) {
        builder.addPropertyValue("excludeFilters", filters);
    }
}

From source file:com.stormpath.spring.security.authz.permission.DomainPermission.java

public DomainPermission(String actions, String targets) {
    this.domain = getDomain(getClass());
    this.actions = CollectionUtils.asSet(StringUtils.tokenizeToStringArray(actions, SUBPART_DIVIDER_TOKEN));
    this.targets = CollectionUtils.asSet(StringUtils.tokenizeToStringArray(targets, SUBPART_DIVIDER_TOKEN));
    encodeParts(this.domain, actions, targets);
}

From source file:com.ewcms.common.query.mongo.EasyQueryInit.java

private void insertCertificate() throws IOException {
    DataOperator<Certificate> operator = new DataOperator<Certificate>("certificate.csv");
    operator.insert(new MapperCallback<Certificate>() {
        @Override//w  ww  .  j  av a2 s .  c  o m
        public Certificate mapping(String line) {
            String[] array = line.split(",");
            Certificate c = new Certificate();
            c.setCerId(array[0]);
            c.setName(array[1]);
            try {
                c.setLimitLogs(findLimitLog(array[0]));
            } catch (IOException e1) {
                e1.printStackTrace();
            }
            try {
                c.setBrithdate(format.parse(array[3]));
            } catch (ParseException e) {
                new RuntimeException(e);
            }
            c.setLimit(Float.valueOf(array[4]).intValue());
            if (array.length > 5 && StringUtils.hasText(array[5])) {
                c.setPhones(StringUtils.tokenizeToStringArray(array[5], "|"));
            }

            return c;
        }
    }, operations);
}

From source file:com.github.persapiens.jsfboot.security.AuthorizeFaceletsTag.java

void setIfAllGranted(String ifAllGranted) {
    String[] roles = StringUtils.tokenizeToStringArray(ifAllGranted, ",");
    if (!ObjectUtils.isEmpty(roles)) {
        String expression = toHasRoleExpression(roles);
        setAccess(getAccess() != null ? getAccess() + AND + expression : expression);
    }//from  w ww  . j a  v  a2s .c o m
}

From source file:com.googlecode.flyway.core.dbsupport.oracle.OracleSqlScript.java

@Override
protected boolean endsWithOpenMultilineStringLiteral(String statement) {
    String filteredStatementForParensQQuotes = com.googlecode.flyway.core.util.StringUtils.replaceAll(statement,
            "q'(", "q'[");
    filteredStatementForParensQQuotes = com.googlecode.flyway.core.util.StringUtils
            .replaceAll(filteredStatementForParensQQuotes, ")'", "]'");

    //Ignore all special characters that naturally occur in SQL, but are not opening or closing string literals
    String[] tokens = StringUtils.tokenizeToStringArray(filteredStatementForParensQQuotes, " ;=|(),");

    List<Token> delimitingTokens = extractStringLiteralDelimitingTokens(tokens);

    boolean insideQuoteStringLiteral = false;
    boolean insideQStringLiteral = false;

    for (Token delimitingToken : delimitingTokens) {
        boolean moreTokensApplicable = true;
        for (TokenType tokenType : delimitingToken.tokenTypes) {
            if (!moreTokensApplicable) {
                continue;
            }//from w ww . j av a2 s  .  co m

            if (!insideQStringLiteral && !insideQuoteStringLiteral && (tokenType == TokenType.QUOTE_OPEN)) {
                insideQuoteStringLiteral = true;
                if (delimitingToken.singleTypeApplicable) {
                    moreTokensApplicable = false;
                }
                continue;
            }
            if (insideQuoteStringLiteral && (tokenType == TokenType.QUOTE_CLOSE)) {
                insideQuoteStringLiteral = false;
                moreTokensApplicable = false;
                continue;
            }
            if (!insideQStringLiteral && !insideQuoteStringLiteral && (tokenType == TokenType.Q_OPEN)) {
                insideQStringLiteral = true;
                continue;
            }
            if (insideQStringLiteral && (tokenType == TokenType.Q_CLOSE)) {
                insideQStringLiteral = false;
                moreTokensApplicable = false;
            }
        }
    }

    return insideQuoteStringLiteral || insideQStringLiteral;
}

From source file:example.hibernatetool.SpringComponentConfiguration.java

protected void initializeAppContext() throws MojoExecutionException {
    if (applicationContext != null) {
        return;//from w w  w  .  j av  a 2s  .c o m
    }
    try {
        String[] appContextResources = StringUtils.tokenizeToStringArray(getAppContextLocation(), ",");
        applicationContext = constructContext(appContextResources);
    } catch (Exception e) {
        throw new MojoExecutionException("Error in initializing Spring", e);
    }
}

From source file:org.sakaiproject.component.impl.ContextLoader.java

/**
 * Initialize the local ApplicationContext, link it to the shared context, and load shared definitions into the shared context.
 * /*from   w  w w  .j a v a 2 s.c  o m*/
 * @param servletContext
 *        current servlet context
 * @return the new WebApplicationContext
 * @throws BeansException
 *         if the context couldn't be initialized
 */
public WebApplicationContext initWebApplicationContext(ServletContext servletContext) throws BeansException {
    WebApplicationContext rv = super.initWebApplicationContext(servletContext);

    // if we have a parent and any shared bean definitions, load them into the parent
    ConfigurableApplicationContext parent = (ConfigurableApplicationContext) rv.getParent();
    if (parent != null) {
        String sharedConfig = servletContext.getInitParameter(SHARED_LOCATION_PARAM);
        if (sharedConfig != null) {
            String[] locations = StringUtils.tokenizeToStringArray(sharedConfig,
                    ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS);
            if (locations != null) {
                XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(
                        (BeanDefinitionRegistry) parent.getBeanFactory());

                for (int i = 0; i < locations.length; i++) {
                    try {
                        reader.loadBeanDefinitions(rv.getResources(locations[i]));
                    } catch (IOException e) {
                        M_log.warn("exception loading into parent: " + e);
                    }
                }
            }
        }
    }

    return rv;
}

From source file:com.googlecode.spring.appengine.objectify.OfyServiceFactoryBean.java

@Override
public void afterPropertiesSet() throws Exception {
    OfyServiceBuilder builder = new OfyServiceBuilder();
    if (StringUtils.hasText(basePackage)) {
        String[] basePackages = StringUtils.tokenizeToStringArray(this.basePackage,
                ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
        for (String basePackage : basePackages) {
            builder.addBasePackage(basePackage);
        }//from w  ww .j  a  va 2 s  .com
    }
    if (entityClasses != null) {
        for (Class<?> clazz : entityClasses) {
            builder.registerEntity(clazz);
        }
    }
    if (translatorFactories != null) {
        for (TranslatorFactory<?> translatorFactory : translatorFactories) {
            builder.registerTranslatorFactory(translatorFactory);
        }
    }
    this.ofyService = builder.build();
}

From source file:in.edu.dsu.cit15.lms.appengine.objectify.OfyServiceFactoryBean.java

@Override
public void afterPropertiesSet() throws Exception {
    OfyServiceBuilder builder = new OfyServiceBuilder();
    if (StringUtils.hasText(basePackage)) {
        String[] basePackages = StringUtils.tokenizeToStringArray(this.basePackage,
                ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
        for (String basePackage : basePackages) {
            builder.addBasePackage(basePackage);
        }//from  w  ww. j  a  va 2s.  com
    }
    if (entityClasses != null) {
        for (Class<?> clazz : entityClasses) {
            builder.registerEntity(clazz);
        }
    }
    if (translatorFactories != null) {
        for (TranslatorFactory<?, ?> translatorFactory : translatorFactories) {
            builder.registerTranslatorFactory(translatorFactory);
        }
    }
    this.ofyService = builder.build();
}

From source file:com.github.persapiens.jsfboot.security.AuthorizeFaceletsTag.java

void setIfAnyGranted(String ifAnyGranted) {
    String[] roles = StringUtils.tokenizeToStringArray(ifAnyGranted, ",");
    if (!ObjectUtils.isEmpty(roles)) {
        String expression = toHasAnyRoleExpression(roles, false);
        setAccess(getAccess() != null ? getAccess() + AND + expression : expression);
    }/*from  w  w w .  j  a va  2s  .c om*/
}