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.etcc.csc.presentation.action.ContactUsSubmitAction.java

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    DynaValidatorForm dynaForm = (DynaValidatorForm) form;
    String driversLicense = null;
    String licensePlate = null;/*from w ww.  j av a  2 s. c o  m*/
    String accountNumber = null;
    String replyAddress = dynaForm.getString("replyAddress");
    String topic = StringUtils.trimToEmpty(dynaForm.getString("topic"));
    Boolean is121Comment = (Boolean) dynaForm.get("is121Comment");
    Boolean updateEmail = (Boolean) dynaForm.get("updateEmail");
    String localeStr = SessionUtil.getStrutsLocaleLang(request);
    if (StringUtils.isBlank(topic)) {
        topic = "General";
    }
    String comment = dynaForm.getString("comment");
    if (topic.equals("Account") || topic.equals("Violation") || topic.equals("ZipCash")) {
        driversLicense = dynaForm.getString("driversLicense");
        licensePlate = dynaForm.getString("licensePlate");
        accountNumber = dynaForm.getString("accountNumber");
        if (driversLicense != null && driversLicense.length() > 0) {
            comment = comment + "   Drivers License:" + driversLicense;
        } else {
            comment = comment + "   Drivers License:Not Provided.";
        }
        if (licensePlate != null && licensePlate.length() > 0) {
            comment = comment + "  License Plate:" + licensePlate;
        } else {
            comment = comment + "  License Plate:Not Provided.";
        }
        if (accountNumber != null && accountNumber.length() > 0) {
            comment = comment + "  Account Number:" + accountNumber;
        } else {
            comment = comment + "  Account Number:Not Provided.";
        }
    }

    AccountLoginDTO accountLogin = SessionUtil.getSessionAccountLogin(request.getSession());
    long docId = -1;
    String docType = null;
    String licState = null;
    String licPlate = null;
    String dbSessionId = null;
    if (accountLogin != null) {
        docType = accountLogin.getLoginType();
        if (docType != null) {
            if (docType.equalsIgnoreCase(Constants.LOGIN_TYPE_INVOICE)) {
                docId = accountLogin.getInvoiceId();
            } else if ((docType.equalsIgnoreCase(Constants.LOGIN_TYPE_ACCOUNT) || docType == null)
                    && accountLogin.getAcctId() > 0) {
                docId = accountLogin.getAcctId();
                docType = Constants.LOGIN_TYPE_ACCOUNT;
            }
            licState = accountLogin.getLicState();
            if (topic.equals("Account") || topic.equals("Violation") || topic.equals("ZipCash")) {
                if (licensePlate != null && licensePlate.length() > 0) {
                    licPlate = licensePlate;
                }
            } else {
                if (accountLogin.getLicPlate() != null && accountLogin.getLicPlate().length() > 0)
                    licPlate = accountLogin.getLicPlate();
            }
        }

        dbSessionId = accountLogin.getDbSessionId();
    }
    AppInterface ai = (AppInterface) DelegateFactory.create(DelegateEnum.APP_DELEGATE);
    boolean submitted = ai.contactUs(docId, docType, licState, licPlate, replyAddress, topic, comment,
            dbSessionId, is121Comment, updateEmail, localeStr);

    if (submitted) {
        request.setAttribute("contactUsResult", "true");
        return mapping.findForward("success");
    } else

        return mapping.findForward("failure");
}

From source file:ml.shifu.shifu.util.ExprAnalyzer.java

public String[] getVarsInExpr() {
    char[] processed = expr.toCharArray();
    removeQuota(processed, '\'');
    removeQuota(processed, '\"');
    removeNonValueChar(processed);/* w ww  . ja  va2 s. c  om*/
    removeObjMethod(processed);

    String formatStr = new String(processed);
    String[] vars = formatStr.split("[ ]");
    List<String> result = new ArrayList<String>();

    for (String var : vars) {
        String fvar = StringUtils.trimToEmpty(var);
        if (StringUtils.isNotBlank(fvar) && !"and".equals(fvar) && !"or".equals(fvar)
                && !StringUtils.isNumeric(fvar)) {
            result.add(fvar);
        }
    }
    return result.toArray(new String[0]);
}

From source file:gate.termraider.util.Utilities.java

public static String cleanAndCamelCase(String input) {
    // remove leading & trailing whitespace then camelCase
    return WordUtils.capitalize(StringUtils.trimToEmpty(input)).replaceAll("\\s+", "");
}

From source file:com.dattack.naming.DefaultNameParser.java

@Override
public Name parse(final String name) throws InvalidNameException, NamingException {

    return new CompoundName(StringUtils.trimToEmpty(name), properties);
}

From source file:hello.console.EchoCommand.java

@Override
protected void doExecute() throws Exception {
    printf(StringUtils.trimToEmpty(text));
}

From source file:com.hangum.tadpole.engine.sql.util.tables.SQLResultFilter.java

public void setFilter(String val) {
    this.filter = StringUtils.trimToEmpty(val);
}

From source file:ml.shifu.shifu.core.binning.NativeBinning.java

@Override
public void addData(String val) {
    String fval = StringUtils.trimToEmpty(val);
    if (!isMissingVal(fval)) {
        double dval = 0;

        try {//from   www.j a  va 2  s  .  co m
            dval = Double.parseDouble(fval);
        } catch (NumberFormatException e) {
            super.incInvalidValCnt();
            return;
        }
        array.add(dval);
    } else {
        super.incMissingValCnt();
    }
}

From source file:com.haulmont.cuba.gui.components.filter.UserSetHelper.java

public static Set<String> parseSet(String text) {
    Set<String> set = new HashSet<>();
    if ("NULL".equals(StringUtils.trimToEmpty(text)))
        return set;
    String[] ids = text.split(",");
    for (String id : ids) {
        String s = StringUtils.trimToNull(id);
        if (s != null)
            set.add(s);//from ww w  .  jav  a 2s  .  c  o  m
    }
    return set;
}

From source file:com.haulmont.cuba.core.sys.persistence.DbmsSpecificFactory.java

public static <T> T create(Class<T> intf, String storeName) {
    return create(intf, DbmsType.getType(storeName), StringUtils.trimToEmpty(DbmsType.getVersion(storeName)));
}

From source file:com.hangum.tadpole.engine.sql.util.export.JsonExpoter.java

public static JsonArray makeContentArray(String tableName, QueryExecuteResultDTO rsDAO, int intLimitCnt) {
    List<Map<Integer, Object>> dataList = rsDAO.getDataList().getData();
    Map<Integer, String> mapLabelName = rsDAO.getColumnLabelName();
    JsonArray jsonArry = new JsonArray();
    for (int i = 0; i < dataList.size(); i++) {
        Map<Integer, Object> mapColumns = dataList.get(i);

        JsonObject jsonObj = new JsonObject();
        for (int j = 1; j < mapLabelName.size(); j++) {
            String columnName = mapLabelName.get(j);

            jsonObj.addProperty(StringUtils.trimToEmpty(columnName), "" + mapColumns.get(j));
        }/* w  w w .  j ava 2 s .co  m*/
        jsonArry.add(jsonObj);
        if (i == intLimitCnt)
            break;
    }
    return jsonArry;
}