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.reizes.shiva.net.mail.EmailSender.java

public static String sendMail(String host, int port, String from, String to, String subject, String text)
        throws IOException, EmailException {

    if (to != null && host != null) {
        String[] emailTo = StringUtils.split(to, ';');

        Email email = new SimpleEmail();
        email.setHostName(host);//from   w  w w .  jav  a  2  s  . c  om
        email.setSmtpPort(port);
        email.setFrom(from);

        for (String recv : emailTo) {
            email.addTo(recv);
        }

        email.setSubject(subject);
        email.setMsg(text);
        return email.send();
    }

    return null;
}

From source file:com.qualogy.qafe.util.StyleDomUtil.java

/**
 * Convert for example background-color to backgroundColor
 * @param style/*from   w w w  . java  2  s  .c o  m*/
 * @return
 */
public static String initCapitalize(String style) {
    String newValue = "";
    if (style != null) {
        String[] parts = StringUtils.split(style, '-');
        if (parts.length > 1) {
            for (int j = 0; j < parts.length; j++) {
                if (j > 0) {
                    if (parts[j].length() > 0) {
                        String capString = parts[j].substring(0, 1);
                        capString = capString.toUpperCase();
                        capString += parts[j].substring(1);
                        newValue += capString;
                    }
                } else {
                    newValue += parts[j];
                }
            }
        } else {
            newValue = style;
        }
    }
    return newValue;
}

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

public static String sqlToString(String name, String sql) {
    StringBuffer sbSQL = new StringBuffer("");

    sql = StringUtils.remove(sql, ";");
    String[] splists = StringUtils.split(sql, PublicTadpoleDefine.LINE_SEPARATOR);
    for (int i = 0; i < splists.length; i++) {
        if (!"".equals(StringUtils.trimToEmpty(splists[i]))) {

            if (i == 0)
                sbSQL.append("$" + name + " = \"" + SQLTextUtil.delLineChar(splists[i]) + "\"; \r\n");
            else//from  www  .  java2 s.co  m
                sbSQL.append("$" + name + " .= \"" + SQLTextUtil.delLineChar(splists[i]) + "\"; \r\n");
        }
    }

    return sbSQL.toString();
}

From source file:com.aistor.common.utils.excel.fieldtype.RoleListType.java

/**
 * ?//from   w  ww .ja  va 2 s. c  o m
 */
public static Object getValue(String val) {
    List<Role> roleList = Lists.newArrayList();
    List<Role> allRoleList = systemService.findAllRole();
    for (String s : StringUtils.split(val, ",")) {
        for (Role e : allRoleList) {
            if (e.getName().equals(s)) {
                roleList.add(e);
            }
        }
    }
    return roleList.size() > 0 ? roleList : null;
}

From source file:com.thinkgem.jeesite.common.utils.excel.fieldtype.UserListType.java

/**
 * ?/*from  w w w  . j  a va  2s. co m*/
 */
public static Object getValue(String val) {
    List<User> userList = Lists.newArrayList();
    List<User> allUserList = systemService.findAllUser();
    for (String s : StringUtils.split(val, ",")) {
        for (User e : allUserList) {
            if (e.getName().equals(s)) {
                userList.add(e);
            }
        }
    }
    return userList.size() > 0 ? userList : null;
}

From source file:com.liferay.maven.plugins.util.StringUtil.java

public static String[] split(String s, String delimiter) {
    return StringUtils.split(s, delimiter);
}

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

public static String sqlToString(String name, String sql) {
    StringBuffer sbSQL = new StringBuffer("");

    sql = StringUtils.remove(sql, ";");
    String[] splists = StringUtils.split(sql, PublicTadpoleDefine.LINE_SEPARATOR);
    for (int i = 0; i < splists.length; i++) {
        if (!"".equals(StringUtils.trimToEmpty(splists[i]))) {

            if (i == 0)
                sbSQL.append(name + " = \"" + SQLTextUtil.delLineChar(splists[i]) + " \" \r\n");
            else//  w  ww .  j  av  a 2 s  .co  m
                sbSQL.append(name + " = " + name + " & \"" + SQLTextUtil.delLineChar(splists[i]) + " \" \r\n");
        }
    }

    return sbSQL.toString();
}

From source file:com.activecq.api.utils.OsgiPropertyUtil.java

/**
 * Util for parsing Service properties in the form &gt;value&lt;&gt;separator&lt;&gt;value&lt;
 *
 * @param value//from w ww .  j a v a2  s. c o m
 * @param separator
 * @return
 */
public static AbstractMap.SimpleEntry toSimpleEntry(String value, String separator) {
    String[] tmp = StringUtils.split(value, separator);

    if (tmp == null) {
        return null;
    }

    if (tmp.length == 2) {
        return new AbstractMap.SimpleEntry(tmp[0], tmp[1]);
    } else {
        return null;
    }
}

From source file:net.kamhon.ieagle.util.TimeUtil.java

public static int[] parseTime(String time) {
    String[] ss = StringUtils.split(time, ":");
    if (ss == null || ss.length != 3) {
        throw new ValidatorException("Invalid time format");
    }//ww  w  . ja v a 2 s. c  om

    return new int[] { Integer.parseInt(ss[0]), Integer.parseInt(ss[1]), Integer.parseInt(ss[2]) };
}

From source file:com.microsoft.alm.plugin.idea.tfvc.core.tfs.TfsRevisionNumber.java

public static TfsRevisionNumber tryParse(final String s) {
    try {// www  . jav  a 2s .co m
        final String[] sections = StringUtils.split(s, SEPARATOR);
        if (sections == null || sections.length != 3) {
            return null;
        }
        return new TfsRevisionNumber(Integer.parseInt(sections[0]), sections[1], sections[2]);
    } catch (NumberFormatException e) {
        logger.error("Could not parse revision number: " + s, e);
        return null;
    }
}