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:edu.northwestern.bioinformatics.studycalendar.core.editors.EditorUtils.java

public static String[] splitValue(String str) {
    return StringUtils.split(str, SEPARATOR);
}

From source file:com.intel.cosbench.config.common.KVConfigParser.java

public static Config parse(String str) {
    BaseConfiguration config = new BaseConfiguration();
    config.setDelimiterParsingDisabled(true);
    str = StringUtils.trimToEmpty(str);/* w w  w  .  ja va  2  s . c om*/
    String[] entries = StringUtils.split(str, ';');
    for (String entry : entries) {
        addConfigEntry(entry, config);
    }
    return new COSBConfigApator(config);
}

From source file:com.bstek.dorado.data.entity.PropertyPathUtils.java

public static Object getValueByPath(EntityDataType dataType, Object object, String propertyPath)
        throws Exception {
    String[] paths = StringUtils.split(propertyPath, '.');
    Object value = object;/*from w  ww .  j  a  v  a2s  .  c  o  m*/
    for (int i = 0; i < paths.length; i++) {
        String path = paths[i];
        if (EntityUtils.isEntity(value)) {
            value = EntityUtils.getValue(value, path);
        } else if (value instanceof Map<?, ?>) {
            value = ((Map<?, ?>) value).get(path);
        } else {
            value = PropertyUtils.getSimpleProperty(value, path);
        }

        if (value == null) {
            break;
        }
    }
    return value;
}

From source file:cn.cuizuoli.gotour.utils.HtmlHelper.java

/**
 * toTable//from  w  ww.  ja v  a 2 s.c om
 * @param text
 * @return
 */
public static String toTable(String text) {
    String[] lines = StringUtils.split(text, "\r\n");
    StringBuffer tableBuffer = new StringBuffer();
    for (String line : lines) {
        Matcher tileMatcher = TITLE_PATTERN.matcher(line);
        if (tileMatcher.matches()) {
            String h4 = new StringBuffer().append("<h4>").append(tileMatcher.group(1)).append("</h4>")
                    .append("\n").append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">")
                    .append("\n").toString();
            tableBuffer.append(h4);
        }
        Matcher tableMatcher = TABLE_PATTERN.matcher(line);
        if (tableMatcher.matches()) {
            String tr = new StringBuffer().append("<tr>").append("\n").append("<th>")
                    .append(tableMatcher.group(1)).append("</th>").append("\n").append("<td>")
                    .append(tableMatcher.group(2)).append("</td>").append("\n").append("</tr>").append("\n")
                    .toString();
            tableBuffer.append(tr);
        }
    }
    tableBuffer.append("</table>\n");
    String table = tableBuffer.toString();
    table = StringUtils.replace(table, "<h4>", "</table>\n<h4>");
    table = StringUtils.replaceOnce(table, "</table>\n<h4>", "<h4>");
    if (!StringUtils.contains(table, "<table")) {
        table = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n" + table;
    }
    return table;
}

From source file:com.hangum.tadpole.rdb.core.dialog.export.application.SQLToJavaConvert.java

/**
 * sql to string/*from w w w  .j  av  a2  s.  co  m*/
 * 
 * @param name
 * @param sql
 * @return
 */
public static String sqlToString(String name, String sql) {
    StringBuffer sbSQL = new StringBuffer(
            "StringBuffer " + name + " = new StringBuffer();" + PublicTadpoleDefine.LINE_SEPARATOR);

    sql = StringUtils.remove(sql, ";");
    String[] splists = StringUtils.split(sql, PublicTadpoleDefine.LINE_SEPARATOR);
    for (String part : splists) {

        if (!"".equals(StringUtils.trimToEmpty(part))) {
            // https://github.com/hangum/TadpoleForDBTools/issues/181 fix
            sbSQL.append(name + ".append(\" " + SQLTextUtil.delLineChar(part) + " \"); "
                    + PublicTadpoleDefine.LINE_SEPARATOR);
        }
    }

    return sbSQL.toString();
}

From source file:iddb.core.util.PasswordUtils.java

public static boolean checkPassword(String raw_password, String encoded_password) {
    if (StringUtils.isEmpty(encoded_password) || StringUtils.isEmpty(raw_password))
        return false;
    if (!encoded_password.contains("$"))
        return false;
    // get the salt from the encoded password
    String[] part = StringUtils.split(encoded_password, "$");
    String hashPassword = HashUtils.getSHA1Hash(part[0] + raw_password);
    return (hashPassword.equals(part[1]));
}

From source file:com.common.poi.excel.util.Reflections.java

/**
 * Getter.// ww w.j a  v  a  2 s  .  c om
 * ???.??.
 */
public static Object invokeGetter(Object obj, String propertyName) {
    Object object = obj;
    for (String name : StringUtils.split(propertyName, ".")) {
        String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name);
        object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
    }
    return object;
}

From source file:com.ansorgit.plugins.bash.util.SystemPathUtil.java

@Nullable
public static String findBestExecutable(@NotNull String commandName) {
    List<String> paths = Arrays.asList(StringUtils.split(System.getenv("PATH"), File.pathSeparatorChar));

    return findBestExecutable(commandName, paths);
}

From source file:edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.ConstructedModelTracker.java

public static ConstructedModel parseModelIdentifier(String modelIdentifier)
        throws IllegalConstructedModelIdentifierException {

    String[] parts = StringUtils.split(modelIdentifier, '$');

    if (parts.length == 0) {
        throw new IllegalConstructedModelIdentifierException(modelIdentifier + " provided.");
    } else if (parts.length == 1) {
        return new ConstructedModel(parts[0], null);
    } else {//w  w  w  .j a  v a  2  s.co  m
        return new ConstructedModel(parts[0], parts[1]);
    }
}

From source file:com.hangum.tadpole.rdb.core.editors.main.SQLTextUtil.java

/**
 * ? //from   w  ww  .  j  a  va2 s.c  om
 * 
 * 1. (Define.SQL_DILIMITER(;)) ? ??   ? ?  =>   ? .
 * 2.  ? ??  ? ?? ?. 
 *   
 * @param query
 * @param cursorPosition
 * @return
 */
public static String executeQuery(String query, int cursorPosition) {//throws Exception {
    if (query.split(Define.SQL_DILIMITER).length == 1 || query.indexOf(Define.SQL_DILIMITER) == -1) {
        return StringUtils.trimToEmpty(query);
    }

    String[] querys = StringUtils.split(query, Define.SQL_DILIMITER);
    //      if(logger.isDebugEnabled()) {
    //         logger.debug("=====[query]" + query + " =====[mouse point]" + cursorPoint);
    //      }

    int queryBeforeCount = 0;
    for (int i = 0; i < querys.length; i++) {
        // dilimiter ?  +1 .
        int firstSearch = querys[i].length() + 1;

        queryBeforeCount += firstSearch;
        if (cursorPosition <= queryBeforeCount) {
            if (logger.isDebugEnabled())
                logger.debug("[cursorPosition]" + cursorPosition + "[find postion]" + queryBeforeCount
                        + "[execute query]" + StringUtils.trim(querys[i]));
            return StringUtils.trim(querys[i]);
        }
    }

    if (logger.isDebugEnabled())
        logger.debug("[last find execute query]" + StringUtils.trim(querys[querys.length - 1]));
    return StringUtils.trim(querys[querys.length - 1]);
}