Example usage for org.apache.commons.lang StringUtils split

List of usage examples for org.apache.commons.lang StringUtils split

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils split.

Prototype

public static String[] split(String str, String separatorChars) 

Source Link

Document

Splits the provided text into an array, separators specified.

Usage

From source file:com.ewcms.publication.freemarker.directive.UriFormat.java

/**
 * ??????/*from w  w  w  .j  a v a 2 s  . com*/
 * 
 * @param path
 * @return
 */
public static String formatChannelPath(String path) {
    String[] s = StringUtils.split(path, "/");
    return StringUtils.join(s, "/");
}

From source file:com.ms.commons.log.LoggerHelper.java

private static String leftpad(int level, String msg) {
    String prefix = StringUtils.repeat("\t", level);
    String[] lines = StringUtils.split(msg, newline);
    for (int i = 0; i < lines.length; i++) {
        lines[i] = prefix + lines[i];//w w w .  jav a 2s  .c  o  m
    }
    return StringUtils.join(lines, newline);
}

From source file:com.ms.commons.test.tool.util.StrUtil.java

public static List<String> splitStringToList(String str, char splitC) {
    List<String> list = new ArrayList<String>();
    if (str != null) {
        for (String s : StringUtils.split(str, splitC)) {
            String ts = s.trim();
            if (ts.length() > 0) {
                list.add(ts);//from   ww  w  .jav a  2  s  .  c om
            }
        }
    }
    return list;
}

From source file:net.sf.zekr.common.util.CommonUtils.java

/**
 * The two parameters should be exactly of type x.y.z, in which all x and y and z are integer numbers: 0-9.
 * /*w  ww. j a  v  a 2 s. co m*/
 * @param ver1
 * @param ver2
 * @return
 */
public static int compareVersions(String ver1, String ver2) {
    String[] v1 = StringUtils.split(ver1, ".");
    String[] v2 = StringUtils.split(ver2, ".");
    int k = Integer.parseInt(v1[0]) - Integer.parseInt(v2[0]);
    if (k != 0) {
        return k;
    }
    k = Integer.parseInt(v1[1]) - Integer.parseInt(v2[1]);
    if (k != 0) {
        return k;
    }
    k = Integer.parseInt(v1[2]) - Integer.parseInt(v2[2]);
    return k;
}

From source file:desi.juan.internal.util.MethodGeneratorUtils.java

public static String uriToCammelCase(String uri) {
    uri = uri.replace("{", "/").replace("}", "/");
    StringBuilder result = new StringBuilder();
    for (String word : StringUtils.split(uri, "/")) {
        if (word.contains("_")) {
            word = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, word);
        }//ww  w. java2 s  .  co  m
        result.append(StringUtils.capitalize(word));
    }
    return StringUtils.uncapitalize(result.toString());
}

From source file:com.microsoft.alm.plugin.external.models.ServerStatusType.java

/**
 * Figure out server status type from string
 *
 * @param statusString//from   w w  w  .j a  v  a 2  s .c  o  m
 * @return
 */
public static List<ServerStatusType> getServerStatusTypes(final String statusString) {
    final String[] args = StringUtils.split(statusString, ",");
    final List<ServerStatusType> types = new ArrayList<ServerStatusType>(args.length);

    for (int i = 0; i < args.length; i++) {
        if (StringUtils.equalsIgnoreCase(args[i].trim(), ADD.name())) {
            types.add(ADD);
        } else if (StringUtils.equalsIgnoreCase(args[i].trim(), DELETE.name())) {
            types.add(DELETE);
        } else if (StringUtils.equalsIgnoreCase(args[i].trim(), EDIT.name())) {
            types.add(EDIT);
        } else if (StringUtils.equalsIgnoreCase(args[i].trim(), RENAME.name())
                || StringUtils.equalsIgnoreCase(args[i].trim(), SOURCE_RENAME)) {
            types.add(RENAME);
        } else if (StringUtils.equalsIgnoreCase(args[i].trim(), UNDELETE.name())) {
            types.add(UNDELETE);
        } else if (StringUtils.containsIgnoreCase(args[i].trim(), LOCK.name())) {
            types.add(LOCK);
        } else if (StringUtils.containsIgnoreCase(args[i].trim(), BRANCH.name())) {
            types.add(BRANCH);
        } else {
            logger.error("Undocumented status from server: " + args[i]);
            types.add(UNKNOWN);
        }
    }
    return types;
}

From source file:jp.co.tis.gsp.tools.dba.dialect.DialectFactory.java

public static Dialect getDialect(String url, String driver) {
    String[] urlTokens = StringUtils.split(url, ':');
    if (urlTokens.length < 3) {
        throw new IllegalArgumentException("url isn't jdbc url format.");
    }/*from  w ww  .j a  v  a 2  s  .  co m*/
    Dialect dialect;
    try {
        Class<?> dialectClass;
        if (classMap.containsKey(urlTokens[1])) {
            dialectClass = classMap.get(urlTokens[1]);

        } else {
            String dialectClassName;
            dialectClassName = "jp.co.tis.gsp.tools.dba.dialect." + StringUtils.capitalize(urlTokens[1])
                    + "Dialect";
            dialectClass = Class.forName(dialectClassName);
        }
        dialect = (Dialect) dialectClass.newInstance();
        dialect.setUrl(url);
        dialect.setDriver(driver);
    } catch (Exception e) {
        throw new IllegalArgumentException("Unsupported Database product:" + urlTokens[1], e);
    }

    return dialect;
}

From source file:dk.dma.epd.common.text.TextUtils.java

/**
 * Return class name without package/*from ww w.ja v a  2  s  .c  o m*/
 * @param cls
 * @return
 */
public static String className(Class<?> cls) {
    String[] nameParts = StringUtils.split(cls.getName(), '.');
    return nameParts[nameParts.length - 1];
}

From source file:net.sf.zekr.engine.search.SearchScopeItem.java

public static SearchScopeItem parse(String ssi) {
    if (StringUtils.isBlank(ssi)) {
        return null;
    }//from  w w  w.j a  v a  2s  .  co m

    String[] s = StringUtils.split(ssi, "-");
    if (s.length < 4) {
        return null;
    } else {
        boolean exclusive = false;
        if (s.length >= 5) {
            exclusive = Boolean.parseBoolean(s[4]);
        }
        return new SearchScopeItem(Integer.parseInt(s[0]), Integer.parseInt(s[1]), Integer.parseInt(s[2]),
                Integer.parseInt(s[3]), exclusive);
    }
}

From source file:AIR.Common.Sql.DbHelper.java

public static String getDbCsvFromString(String csvString, Character delimiter) {
    String[] contexts = StringUtils.split(csvString, delimiter == null ? ',' : delimiter);
    StringBuilder strnBuilder = new StringBuilder();
    for (int counter1 = 0; counter1 < contexts.length; ++counter1) {
        if (counter1 != 0)
            strnBuilder.append(",");
        strnBuilder.append(String.format("'%1$s'", contexts[counter1].trim()));
    }/*w w w.ja va  2  s  . co  m*/

    return strnBuilder.toString();
}