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

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

Introduction

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

Prototype

public static String trimToEmpty(final 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.thruzero.common.core.utils.StringUtilsExt.java

/**
 * Converts the given token stream of keyValuePairs, using the given separator, into a StringMap. Leading and trailing spaces of the keys and values are
 * trimmed./*from   w w w  . j  a v a 2  s .c o m*/
 * <p>
 * Example input: "booleanTrue=true ,booleanFalse=false, integerOne=1,longOne=1234567890"
 */
public static StringMap tokensToMap(final String keyValuePairs, final String separator) {
    StringMap result = new StringMap();

    if (StringUtils.isNotEmpty(keyValuePairs)) {
        StringTokenizer st = new StringTokenizer(keyValuePairs, separator);

        while (st.hasMoreTokens()) {
            String token = st.nextToken();
            StringTokenizer st2 = new StringTokenizer(token, "=");

            result.put(StringUtils.trimToEmpty(st2.nextToken()),
                    st2.hasMoreTokens() ? StringUtils.trimToNull(st2.nextToken()) : null);
        }
    }

    return result;
}

From source file:com.threewks.thundr.route.redirect.Redirect.java

public String getRedirectTo(Map<String, String> pathVars) {
    String finalRedirect = redirectTo;

    Matcher matcher = Route.PathParameterPattern.matcher(redirectTo);
    while (matcher.find()) {
        String token = matcher.group(1);
        finalRedirect = finalRedirect.replaceAll(Pattern.quote("{" + token + "}"),
                Matcher.quoteReplacement(StringUtils.trimToEmpty(pathVars.get(token))));
    }/*www.j a  v  a2  s.c  o  m*/
    return finalRedirect;
}

From source file:ke.co.tawi.babblesms.server.beans.geolocation.Country.java

/**
 * @param codefips
 */
public void setCodefips(String codefips) {
    this.codefips = StringUtils.trimToEmpty(codefips);
}

From source file:ke.co.tawi.babblesms.server.beans.contact.Group.java

public void setStatusuuid(String statusuuid) {
    this.statusuuid = StringUtils.trimToEmpty(statusuuid);
}

From source file:ke.co.tawi.babblesms.server.beans.log.OutgoingLog.java

public void setSender(String sender) {
    this.sender = StringUtils.trimToEmpty(sender);
}

From source file:com.creditcloud.payment.model.chinapnr.FssTransResponse.java

@Override
public String chkString() {
    StringBuilder sb = new StringBuilder();
    sb.append(super.baseChkString()).append(StringUtils.trimToEmpty(getOrdId()))
            .append(StringUtils.trimToEmpty(getOrdDate())).append(StringUtils.trimToEmpty(getTransType()))
            .append(StringUtils.trimToEmpty(getTransAmt())).append(StringUtils.trimToEmpty(getRetUrl()))
            .append(StringUtils.trimToEmpty(getBgRetUrl())).append(StringUtils.trimToEmpty(getMerPriv()))
            .append(StringUtils.trimToEmpty(getRespExt()));
    return sb.toString();
}

From source file:com.norconex.commons.wicket.bootstrap.form.BootstrapSelect.java

public BootstrapSelect(String options, String onChangeJavascript) {
    super();//from   w ww .  ja v  a2s .c  om
    this.options = StringUtils.trimToEmpty(options);
    this.onChangeJavascript = onChangeJavascript;
}

From source file:ke.co.tawi.babblesms.server.beans.notification.NotificationStatus.java

/**
 * @param notificationUuid - the notificationUuid to set
 *///  ww  w  . j av a 2 s  .c  om
public void setNotificationUuid(String notificationUuid) {
    this.notificationUuid = StringUtils.trimToEmpty(notificationUuid);
}

From source file:kenh.xscript.database.elements.Datasource.java

public void process(@Attribute(ATTRIBUTE_VARIABLE) String var) throws UnsupportedScriptException {
    var = StringUtils.trimToEmpty(var);

    if (StringUtils.isBlank(var)) {
        UnsupportedScriptException ex = new UnsupportedScriptException(this, "Variable name is empty.");
        throw ex;
    }/* ww  w.  ja v  a  2s .c om*/

    Properties properties = new Properties();

    this.invokeChildren();
    Vector<Element> children = this.getChildren();

    for (Element child : children) {
        if (child instanceof Param) {
            Param c = (Param) child;
            String name = c.getName();
            Object value = Param.getParsedValue(c);
            if (c.isLink()) {
                String linkName = c.getLinkName();
                if (!properties.containsKey(linkName))
                    new UnsupportedScriptException(this,
                            "Could not find the parameter to link. [" + name + ", " + linkName + "]");
                value = properties.get(linkName);
            }

            properties.put(name, value);
        }
    }

    try {
        DataSource datasource = BasicDataSourceFactory.createDataSource(properties);
        this.saveVariable(var, datasource, null);

    } catch (Exception e) {
        throw new UnsupportedScriptException(this, e);
    }
}

From source file:com.esri.geoportal.harvester.folder.FolderBrokerDefinitionAdaptor.java

/**
 * Creates instance of the adaptor./*from   ww  w  .j  av a 2s  . c o  m*/
 * @param entityDefinition broker definition
 * @throws InvalidDefinitionException if invalid definition
 */
public FolderBrokerDefinitionAdaptor(EntityDefinition entityDefinition) throws InvalidDefinitionException {
    super(entityDefinition);
    if (StringUtils.trimToEmpty(entityDefinition.getType()).isEmpty()) {
        entityDefinition.setType(FolderConnector.TYPE);
    } else if (!FolderConnector.TYPE.equals(entityDefinition.getType())) {
        throw new InvalidDefinitionException("Broker definition doesn't match");
    } else {
        try {
            this.rootFolder = new File(get(P_ROOT_FOLDER));
        } catch (NullPointerException ex) {
            throw new InvalidDefinitionException(
                    String.format("Invalid %s: %s", P_ROOT_FOLDER, get(P_ROOT_FOLDER)), ex);
        }
        cleanup = Boolean.parseBoolean(get(P_FOLDER_CLEANUP));
    }
}