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.haulmont.timesheets.entity.Tag.java

public String getCaption() {
    String pattern;/*from  w w  w. j av a 2  s  .  co m*/
    Object[] params;
    if (tagType != null) {
        pattern = "{0} [{1}]";
        params = new Object[] { StringUtils.trimToEmpty(name), StringUtils.trimToEmpty(tagType.getName()) };
    } else {
        pattern = "{0}";
        params = new Object[] { StringUtils.trimToEmpty(name) };
    }
    MessageFormat fmt = new MessageFormat(pattern);
    return StringUtils.trimToEmpty(fmt.format(params));
}

From source file:gov.nih.nci.calims2.ui.report.query.QueryForm.java

/**
 * Gets the clause rows from the request.
 * // ww  w  .  ja v a  2s. c o m
 * @return The list of clause rows
 */
public List<ClauseRow> getClauseRows() {
    List<ClauseRow> rows = new ArrayList<ClauseRow>();
    if (property != null) {
        for (int i = 0; i < property.size(); i++) {
            String propertyName = StringUtils.trimToEmpty(property.get(i));
            if (StringUtils.isNotEmpty(propertyName)) {
                ClauseRow row = new ClauseRow();
                row.setPropertyName(propertyName);
                row.setPropertyType(StringUtils.stripToEmpty(propertyType.get(i)));
                row.setOperator(Operator.valueOf(operator.get(i)));
                row.setValue(StringUtils.stripToEmpty(value.get(i)));
                if (connector != null && i < connector.size()) {
                    String connectorName = StringUtils.stripToNull(connector.get(i));
                    if (connectorName != null) {
                        row.setConnector(LogicalConnector.valueOf(connectorName));
                    }
                }
                row.setClauseIndex(i);
                rows.add(row);
            }
        }
    }
    return rows;
}

From source file:com.alibaba.cobar.client.router.rules.ibatis.AbstractIBatisOrientedRule.java

public synchronized List<String> action() {
    if (CollectionUtils.isEmpty(dataSourceIds)) {
        List<String> ids = new ArrayList<String>();
        for (String id : StringUtils.split(getAction(), getActionPatternSeparator())) {
            ids.add(StringUtils.trimToEmpty(id));
        }//from w  w w  .ja v  a  2s .  c o  m
        setDataSourceIds(ids);
    }
    return dataSourceIds;
}

From source file:com.egt.core.jsf.component.Etiqueta.java

/**
 * {@inheritDoc}//from   w  w w  .  ja  v  a2s.  c o m
 */
@Override
public Object getValue() {
    Object superobj = super.getValue();
    String superstr = superobj == null ? null : superobj.toString();
    if (StringUtils.isBlank(superstr)) {
        return superobj;
    } else if (getValueExpression("value") != null) {
        return superobj;
    }
    String supertip = super.getToolTip();
    if (supertip != null && getValueExpression("toolTip") == null && supertip.startsWith("BundleParametros.")) {
        int i = supertip.indexOf('.');
        String key = supertip.substring(i + 1);
        String str = BundleParametros.getString(key, BundleParametros.TOOLTIP, true);
        if (str != null) {
            return str;
        }
    }
    String webuistr = JSF.getWebuiString(this, "text");
    if (webuistr == null) {
        String prefix = "label";
        String thisid = StringUtils.trimToEmpty(this.getId());
        String altkey = thisid.startsWith(prefix) ? thisid.substring(prefix.length()) : null;
        String styles = StringUtils.trimToEmpty(this.getStyleClass());
        //          boolean b = super.getFor() == null;
        webuistr = StringUtils.lowerCase(JSF.getWebuiString(superstr, altkey, styles));
    }
    return webuistr == null ? superobj : webuistr;
}

From source file:com.hangum.tadpole.engine.sql.parser.BasicTDBSQLParser.java

@Override
public QueryInfoDTO parser(String sql) {
    String strCheckSQL = SQLUtil.removeComment(sql);
    strCheckSQL = StringUtils.trimToEmpty(strCheckSQL);
    QueryInfoDTO queryInfoDTO = new QueryInfoDTO();

    // if isStatement
    Pattern PATTERN_DML_BASIC = Pattern.compile(
            REGEXP_STATEMENT + MSSQL_PATTERN_STATEMENT + ORACLE_PATTERN_STATEMENT + MYSQL_PATTERN_STATEMENT
                    + PGSQL_PATTERN_STATEMENT + SQLITE_PATTERN_STATEMENT + CUBRID_PATTERN_STATEMENT,
            ParserDefine.PATTERN_FLAG);//from   w  ww.  j  av  a2s .c  o  m

    if (PATTERN_DML_BASIC.matcher(strCheckSQL).matches()) {
        queryInfoDTO.setStatement(true);
        queryInfoDTO.setSqlType(SQL_TYPE.DML);

        parseDML(sql, queryInfoDTO);
    } else {
        queryInfoDTO.setStatement(false);
        queryInfoDTO.setSqlType(SQL_TYPE.DDL);

        parseDDL(sql, queryInfoDTO);
    }

    return queryInfoDTO;
}

From source file:com.gemstone.gemfire.management.internal.cli.parser.GfshMethodTarget.java

/**
 * Constructor that allows all fields to be set
 * //from  w ww. j ava 2 s.co  m
 * @param method
 *          the method to invoke (required)
 * @param target
 *          the object on which the method is to be invoked (required)
 * @param remainingBuffer
 *          can be blank
 * @param key
 *          can be blank
 */
public GfshMethodTarget(final Method method, final Object target, final String remainingBuffer,
        final String key) {
    Assert.notNull(method, "Method is required");
    Assert.notNull(target, "Target is required");
    this.key = StringUtils.trimToEmpty(key);
    this.method = method;
    this.remainingBuffer = remainingBuffer;
    this.target = target;
}

From source file:hudson.plugins.sonar.utils.ExtendedArgumentListBuilder.java

/**
 * Appends specified key/value pair, if value not empty.
 * Also value will be trimmed (see <a href="http://jira.codehaus.org/browse/MNG-3529">MNG-3529</a>).
 *
 * @param key   key// w w w .  j  a v a2  s .  c  o  m
 * @param value value
 * @see #append(String)
 */
public void append(String key, String value) {
    String v = StringUtils.trimToEmpty(value);
    if (StringUtils.isNotEmpty(v)) {
        append("-D" + key + "=" + v);
    }
}

From source file:mitm.common.extractor.impl.TextExtractorFactoryRegistryImpl.java

private String normalizeMimeType(String mimeType) {
    return StringUtils.trimToEmpty(StringUtils.lowerCase(mimeType));
}

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

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

        try {//from   w w w.j ava2 s. c o  m
            dval = Double.parseDouble(fval);
        } catch (NumberFormatException e) {
            // not a number? just ignore
            super.incInvalidValCnt();
            return;
        }

        process(dval);
    } else {
        super.incMissingValCnt();
    }
}

From source file:adalid.core.DisplaySet.java

@Override
public int compareTo(DisplaySet o) {
    DisplaySet that;//w  ww.  j a  v a  2s . co m
    if (o != null) {
        that = o;
        String thisName = StringUtils.trimToEmpty(this.getName());
        String thatName = StringUtils.trimToEmpty(that.getName());
        return thisName.compareTo(thatName);
    }
    return 0;
}