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

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

Introduction

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

Prototype

public static String trimToEmpty(String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null.

Usage

From source file:com.bluexml.xforms.controller.mapping.MappingToolAlfrescoToClassForms.java

/**
 * Fill x forms element non inline./*from w  ww.  j  ava2  s  .c  o  m*/
 * 
 * @param xformsDocument
 *            the xforms document
 * @param targetClassType
 *            the target class type
 * @param id
 *            the id
 * @param label
 *            the label
 * @param targetTypeStr
 * 
 * @return the node
 */
private Node fillXFormsElementNonInline(Document xformsDocument, String targetClassType, String id,
        String label, String targetTypeStr) {
    Element subNode;

    subNode = xformsDocument.createElement(MsgId.INT_INSTANCE_ASSOCIATION_ITEM.getText());
    subNode.setAttribute("type", targetClassType); // #1665

    Element eltLabel = xformsDocument.createElement(MsgId.INT_INSTANCE_SIDELABEL.getText());
    eltLabel.setTextContent(StringUtils.trimToEmpty(label));
    subNode.appendChild(eltLabel);

    Element eltId = xformsDocument.createElement(MsgId.INT_INSTANCE_SIDEID.getText());
    eltId.setTextContent(id);
    subNode.appendChild(eltId);

    Element eltEdit = xformsDocument.createElement(MsgId.INT_INSTANCE_SIDEEDIT.getText());
    eltEdit.setTextContent("");
    subNode.appendChild(eltEdit);

    // ** #1485
    Element eltType = xformsDocument.createElement(MsgId.INT_INSTANCE_SIDETYPE.getText());
    eltType.setTextContent(targetTypeStr);
    subNode.appendChild(eltType);
    // ** #1485

    return subNode;
}

From source file:nc.noumea.mairie.appock.core.utility.AppockUtil.java

/**
 * @param listeString liste de chanes//from w w w  .j a v  a 2s . co m
 * @param separateur separateur de liste
 * @param tronquerApresIndex index de la liste aprs lequel la liste sera tronque et affichera "..." (les index de valeur invalide sont ignors)
 * @return chaine reprsentant la liste spare par le sparateur et tronque aprs l'index dfinit
 */
public static String joinListeStringNotBlank(List<String> listeString, String separateur,
        Integer tronquerApresIndex) {
    if (listeString == null) {
        return null;
    }
    List<String> listeStringRetenu = new ArrayList<>();
    for (String ligne : listeString) {
        if (!StringUtils.isBlank(ligne)) {
            listeStringRetenu.add(StringUtils.trimToEmpty(ligne));
        }
    }
    if (tronquerApresIndex != null && tronquerApresIndex > 0 && tronquerApresIndex < listeStringRetenu.size()) {
        return StringUtils.join(listeStringRetenu.toArray(), separateur, 0, tronquerApresIndex) + separateur
                + "...";
    } else {
        return StringUtils.join(listeStringRetenu, separateur);
    }
}

From source file:adalid.commons.util.StrUtils.java

public static String getNullStringWhenBlankOrEqualsToKey(String string, String key, String left, String right) {
    String s = StringUtils.trimToEmpty(string);
    String k = StringUtils.trimToEmpty(key);
    String l = StringUtils.trimToEmpty(left);
    String r = StringUtils.trimToEmpty(right);
    return StringUtils.isBlank(s) || s.equals(k) ? null : l + s + r;
}

From source file:com.egt.core.util.Utils.java

public static String getDelimitedParameterString(Object[] args, String delimiter) {
    String str = StringUtils.EMPTY;
    String dlm = StringUtils.isBlank(delimiter) ? PIPE_STRING : StringUtils.trimToEmpty(delimiter);
    if (args != null && args.length > 0) {
        for (int i = 0; i < args.length; i++) {
            str += dlm + StringUtils.trimToEmpty(STP.getString(args[i]));
        }/*from  w w  w . jav a 2 s . c  o  m*/
        str = str.substring(dlm.length());
    }
    return StringUtils.trimToEmpty(str);
}

From source file:com.iyonger.apm.web.controller.PerfTestController.java

/**
 * Filter out please_modify_this.com from hosts string.
 *
 * @param originalString original string
 * @return filtered string// w  w w.  j av  a 2 s  . c o m
 */
private String filterHostString(String originalString) {
    List<String> hosts = newArrayList();
    for (String each : StringUtils.split(StringUtils.trimToEmpty(originalString), ",")) {
        if (!each.contains("please_modify_this.com")) {
            hosts.add(each);
        }
    }
    return StringUtils.join(hosts, ",");
}

From source file:com.edgenius.wiki.installation.DBLoader.java

public void resetDB(String type, ConnectionProxy con, String dbname, String username, String password)
        throws SQLException, IOException {
    Statement stat = null;//from  w ww. j  a  va  2s  . com
    try {
        log.info("Reset database " + dbname + " starting...");
        dbname = StringUtils.trimToEmpty(dbname);
        username = StringUtils.trimToEmpty(username);
        password = StringUtils.trimToEmpty(password);
        stat = con.createStatement();

        List<String> lines = loadSQLFile(type, type + "-create-db.sql");
        for (String sql : lines) {
            sql = sql.replaceAll("@TOKEN.DATABASE.NAME@", dbname);
            sql = sql.replaceAll("@TOKEN.DATABASE.USERNAME@", username);
            sql = sql.replaceAll("@TOKEN.DATABASE.PASSWORD@", password);
            stat.addBatch(sql);
        }
        stat.executeBatch();

        log.info("Database " + dbname + " reset success");
    } finally {
        if (stat != null)
            stat.close();
    }

}

From source file:adalid.core.Display.java

@Override
public int compareTo(Display o) {
    Display that;/*w w w.j a v a2s.c  o  m*/
    if (o != null) {
        that = o;
        String thisName = StringUtils.trimToEmpty(this.getName());
        String thatName = StringUtils.trimToEmpty(that.getName());
        return thisName.compareTo(thatName);
    }
    return 0;
}

From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.MySQLLoginComposite.java

/**
 * ? ?  .// w  w  w .  ja v  a  2s .co m
 * 
 * @return
 */
public boolean isValidate() {
    if (!message(comboGroup, "Group"))
        return false;
    if (!message(textHost, "Host")) //$NON-NLS-1$
        return false;
    if (!message(textPort, "Port")) //$NON-NLS-1$
        return false;
    if (!message(textDatabase, "Database")) //$NON-NLS-1$
        return false;
    if (!message(textUser, "User")) //$NON-NLS-1$
        return false;
    //      if(!message(textPassword, "Password")) return false; //$NON-NLS-1$
    if (!message(textDisplayName, "Display Name")) //$NON-NLS-1$
        return false;

    String host = StringUtils.trimToEmpty(textHost.getText());
    String port = StringUtils.trimToEmpty(textPort.getText());

    try {
        if (!isPing(host, port)) {
            MessageDialog.openError(null, Messages.DBLoginDialog_14, Messages.MySQLLoginComposite_8);
            return false;
        }
    } catch (NumberFormatException nfe) {
        MessageDialog.openError(null, Messages.MySQLLoginComposite_3, Messages.MySQLLoginComposite_4);
        return false;
    }

    return true;
}

From source file:com.prowidesoftware.swift.model.field.Field42D.java

/**
 * Get the Name And Address as a concatenation of component3 to component6.
 * @return the Name And Address from components
 *///www .  j a va2s  . c  o m
public String getNameAndAddress() {
    StringBuilder result = new StringBuilder();
    for (int i = 3; i < 7; i++) {
        if (StringUtils.isNotBlank(getComponent(i))) {
            if (result.length() > 0) {
                result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL);
            }
            result.append(StringUtils.trimToEmpty(getComponent(i)));
        }
    }
    return result.toString();
}

From source file:com.alibaba.otter.manager.biz.autokeeper.impl.AutoKeeperCollector.java

/**
 * <pre>/*w  w w  .  jav  a 2 s .  c om*/
 * key=sessionId
 * value=pathList
 * </pre>
 */
private Map<String, List<String>> groupSessionPath(String cmdresult) {
    String[] result = cmdresult.split(WRAP);

    Map<String, List<String>> pathMap = new HashMap<String, List<String>>();
    String sessionId = StringUtils.EMPTY;
    for (String line : result) {
        line = StringUtils.trimToEmpty(line);
        if (StringUtils.isBlank(line)) {
            continue;
        }
        if (line.startsWith("0x")) {
            sessionId = line.replace(COLON, StringUtils.EMPTY);
            pathMap.put(sessionId, new ArrayList<String>());
        } else if (line.startsWith("/")) {
            List<String> paths = pathMap.get(sessionId);
            paths.add(line);
        }
    }
    return pathMap;
}