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:org.zenoss.zep.index.impl.solr.SolrQueryBuilder.java

private void useIpAddressSubstring(String fieldName, Set<String> values) {
    if (values == null || values.isEmpty())
        return;/* w w w  .  j  a  va 2 s . c o m*/
    for (String value : values) {
        if (value.indexOf('.') >= 0) {
            StringBuilder sb = new StringBuilder();
            sb.append("(+");
            sb.append(escape(fieldName + IndexConstants.IP_ADDRESS_TYPE_SUFFIX));
            sb.append(':');
            sb.append(escape(IndexConstants.IP_ADDRESS_TYPE_4));
            sb.append(" +");
            String[] tokens = StringUtils.tokenizeToStringArray(value, ".");
            if (tokens.length > 0) {
                sb.append(ipAddressComplexPhraseQuery(fieldName, tokens));
            } else {
                sb.append(termQuery(fieldName, value));
            }
            sb.append(")");
            clauses.add(sb.toString());
        } else if (value.indexOf(':') >= 0) {
            StringBuilder sb = new StringBuilder();
            sb.append("(+");
            sb.append(escape(fieldName + IndexConstants.IP_ADDRESS_TYPE_SUFFIX));
            sb.append(':');
            sb.append(escape(IndexConstants.IP_ADDRESS_TYPE_6));
            sb.append(" +");
            String[] tokens = StringUtils.tokenizeToStringArray(value, ":");
            if (tokens.length > 0) {
                sb.append(ipAddressComplexPhraseQuery(fieldName, tokens));
            } else {
                sb.append(termQuery(fieldName, value));
            }
            sb.append(")");
            clauses.add(sb.toString());
        } else {
            useWildcard(fieldName, Collections.singleton(removeLeadingZeros(value)));
        }
    }
}

From source file:com.apporiented.spring.override.AbstractGenericBeanDefinitionParser.java

/**
 * Resolve the aliases for the supplied {@link org.springframework.beans.factory.config.BeanDefinition}. The default
 * implementation delegates the call to/*from w w  w .  j a  v  a  2s  .c om*/
 * {@link #resolveAlias(org.w3c.dom.Element, org.springframework.beans.factory.support.AbstractBeanDefinition, org.springframework.beans.factory.xml.ParserContext)}
 * and tokenizes the returned String.
  * @param definition The bean definition.
  * @param element  The XML element.
  * @param parserContext The parser context.
  * @return List of bean aliases.
 */
protected String[] resolveAliases(Element element, AbstractBeanDefinition definition,
        ParserContext parserContext) {

    String alias = resolveAlias(element, definition, parserContext);
    return StringUtils.tokenizeToStringArray(alias, ",; ");
}

From source file:com.productone.spring.ServerOsgiBundleXmlWebApplicationContext.java

/**
 * Set the config locations for this application context in init-param
 * style, i.e. with distinct locations separated by commas, semicolons or
 * whitespace. <p> If not set, the implementation may use a default as
 * appropriate.// w ww . j a  va2s .  com
 */
public void setConfigLocation(String location) {
    setConfigLocations(StringUtils.tokenizeToStringArray(location, CONFIG_LOCATION_DELIMITERS));
}

From source file:net.solarnetwork.web.gemini.ServerOsgiBundleXmlWebApplicationContext.java

/**
 * Set the config locations for this application context in init-param
 * style, i.e. with distinct locations separated by commas, semicolons or
 * whitespace./*  w  ww  .j  ava2 s .  c  o  m*/
 * <p>
 * If not set, the implementation may use a default as appropriate.
 */
@Override
public void setConfigLocation(String location) {
    setConfigLocations(StringUtils.tokenizeToStringArray(location, CONFIG_LOCATION_DELIMITERS));
}

From source file:org.springmodules.validation.bean.conf.loader.xml.handler.AbstractPropertyValidationElementHandler.java

/**
 * Extracts the validation rule error arguments from the given element. Expects an "args" attribute to indicate the
 * error arguments. If no such attribute exisits, returns an empty array.
 *
 * @param element The element that represents the validation rule.
 * @return The validation rule error arguments.
 *///from ww  w.j a v a  2  s  .co m
protected ErrorArgumentsResolver extractArgumentsResolver(Element element) {
    String argsString = element.getAttribute(ARGS_ATTR);
    String[] expressions = (argsString == null) ? new String[0]
            : StringUtils.tokenizeToStringArray(argsString, ", ");
    if (expressions.length == 0) {
        return null;
    }
    return new FunctionErrorArgumentsResolver(expressions, functionExpressionParser);
}

From source file:com.riptide.plugins.jenkins.cloudfront.utils.AntPathMatcher.java

/**
 * Given a pattern and a full path, determine the pattern-mapped part. <p>For example: <ul>
 * <li>'<code>/docs/cvs/commit.html</code>' and '<code>/docs/cvs/commit.html</code> -> ''</li>
 * <li>'<code>/docs/*</code>' and '<code>/docs/cvs/commit</code> -> '<code>cvs/commit</code>'</li>
 * <li>'<code>/docs/cvs/*.html</code>' and '<code>/docs/cvs/commit.html</code> -> '<code>commit.html</code>'</li>
 * <li>'<code>/docs/**</code>' and '<code>/docs/cvs/commit</code> -> '<code>cvs/commit</code>'</li>
 * <li>'<code>/docs/**\/*.html</code>' and '<code>/docs/cvs/commit.html</code> -> '<code>cvs/commit.html</code>'</li>
 * <li>'<code>/*.html</code>' and '<code>/docs/cvs/commit.html</code> -> '<code>docs/cvs/commit.html</code>'</li>
 * <li>'<code>*.html</code>' and '<code>/docs/cvs/commit.html</code> -> '<code>/docs/cvs/commit.html</code>'</li>
 * <li>'<code>*</code>' and '<code>/docs/cvs/commit.html</code> -> '<code>/docs/cvs/commit.html</code>'</li> </ul>
 * <p>Assumes that {@link #match} returns <code>true</code> for '<code>pattern</code>' and '<code>path</code>', but
 * does <strong>not</strong> enforce this.
 *//*from w  ww  . jav a 2  s.  c om*/
public String extractPathWithinPattern(String pattern, String path) {
    String[] patternParts = StringUtils.tokenizeToStringArray(pattern, this.pathSeparator);
    String[] pathParts = StringUtils.tokenizeToStringArray(path, this.pathSeparator);

    StringBuilder builder = new StringBuilder();

    // Add any path parts that have a wildcarded pattern part.
    int puts = 0;
    for (int i = 0; i < patternParts.length; i++) {
        String patternPart = patternParts[i];
        if ((patternPart.indexOf('*') > -1 || patternPart.indexOf('?') > -1) && pathParts.length >= i + 1) {
            if (puts > 0 || (i == 0 && !pattern.startsWith(this.pathSeparator))) {
                builder.append(this.pathSeparator);
            }
            builder.append(pathParts[i]);
            puts++;
        }
    }

    // Append any trailing path parts.
    for (int i = patternParts.length; i < pathParts.length; i++) {
        if (puts > 0 || i > 0) {
            builder.append(this.pathSeparator);
        }
        builder.append(pathParts[i]);
    }

    return builder.toString();
}

From source file:cn.guoyukun.spring.jpa.plugin.serivce.BaseTreeableService.java

public Set<ID> findAncestorIds(ID currentId) {
    Set ids = Sets.newHashSet();//from   w  w  w . j a  va  2  s  . c om
    M m = findOne(currentId);
    if (m == null) {
        return ids;
    }
    for (String idStr : StringUtils.tokenizeToStringArray(m.getParentIds(), "/")) {
        if (!StringUtils.isEmpty(idStr)) {
            ids.add(Long.valueOf(idStr));
        }
    }
    return ids;
}

From source file:cn.guoyukun.spring.jpa.plugin.serivce.BaseTreeableService.java

/**
 * //  w ww  .  ja  va 2 s  .  com
 *
 * @param parentIds
 * @return
 */
public List<M> findAncestor(String parentIds) {
    if (StringUtils.isEmpty(parentIds)) {
        return Collections.EMPTY_LIST;
    }
    String[] ids = StringUtils.tokenizeToStringArray(parentIds, "/");

    return Lists.reverse(
            findAllWithNoPageNoSort(Searchable.newSearchable().addSearchFilter("id", SearchOperator.in, ids)));
}

From source file:net.okjsp.common.MapperScannerConfigurer.java

/**
 * {@inheritDoc}/* w w w .j  av  a  2  s.  c om*/
 */
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry)
        throws BeansException {
    if (this.processPropertyPlaceHolders) {
        processPropertyPlaceHolders();
    }

    Scanner scanner = new Scanner(beanDefinitionRegistry);
    scanner.setResourcePattern(this.pattern); //2012. 12. 11. by lsj
    scanner.setResourceLoader(this.applicationContext);
    scanner.scan(StringUtils.tokenizeToStringArray(this.basePackage,
            ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS));
}