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.creditcloud.payment.model.chinapnr.UserUnFreezeRequest.java

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

From source file:com.haulmont.cuba.web.gui.components.converters.StringToDatatypeConverter.java

@Override
public Object convertToModel(String value, Class<?> targetType, Locale locale) throws ConversionException {
    try {//  w w w . j  a  va  2s  .  c  o  m
        if (locale == null) {
            locale = VaadinSession.getCurrent().getLocale();
        }

        if (isTrimming()) {
            value = StringUtils.trimToEmpty(value);
        }

        if (locale != null) {
            return datatype.parse(value, locale);
        }

        return datatype.parse(value);
    } catch (ParseException e) {
        throw new ConversionException(e);
    }
}

From source file:com.mirth.connect.plugins.httpauth.basic.BasicAuthenticator.java

@Override
public AuthenticationResult authenticate(RequestInfo request) {
    BasicHttpAuthProperties properties = getReplacedProperties(request);
    List<String> authHeaderList = request.getHeaders().get(HttpHeader.AUTHORIZATION.asString());

    if (CollectionUtils.isNotEmpty(authHeaderList)) {
        String authHeader = StringUtils.trimToEmpty(authHeaderList.iterator().next());

        int index = authHeader.indexOf(' ');
        if (index > 0) {
            String method = authHeader.substring(0, index);
            if (StringUtils.equalsIgnoreCase(method, "Basic")) {
                // Get Base64-encoded credentials
                String credentials = StringUtils.trim(authHeader.substring(index));
                // Get the raw, colon-separated credentials
                credentials = new String(Base64.decodeBase64(credentials), StandardCharsets.ISO_8859_1);

                // Split on ':' to get the username and password
                index = credentials.indexOf(':');
                if (index > 0) {
                    String username = credentials.substring(0, index);
                    String password = credentials.substring(index + 1);

                    // Return successful result if the passwords match
                    if (StringUtils.equals(password, properties.getCredentials().get(username))) {
                        return AuthenticationResult.Success(username, properties.getRealm());
                    }/*w ww. j av  a2 s  .  co  m*/
                }
            }
        }
    }

    // Return authentication challenge
    return AuthenticationResult.Challenged("Basic realm=\"" + properties.getRealm() + "\"");
}

From source file:ke.co.tawi.babblesms.server.beans.creditmgmt.SMSPurchase.java

/**
 * @param accountuuid
 */
public void setAccountUuid(String accountuuid) {
    this.accountUuid = StringUtils.trimToEmpty(accountuuid);
}

From source file:com.creditcloud.payment.model.chinapnr.query.QueryTransDetailResponse.java

@Override
public String chkString() {
    StringBuilder sb = new StringBuilder(super.baseChkString());
    sb.append(StringUtils.trimToEmpty(getOrdId())).append(StringUtils.trimToEmpty(getOrdDate()))
            .append(StringUtils.trimToEmpty(getQueryTransType())).append(StringUtils.trimToEmpty(getTransAmt()))
            .append(StringUtils.trimToEmpty(getTransStat())).append(StringUtils.trimToEmpty(getFeeAmt()))
            .append(StringUtils.trimToEmpty(getFeeCustId())).append(StringUtils.trimToEmpty(getFeeAcctId()))
            .append(StringUtils.trimToEmpty(getGateBusiId())).append(StringUtils.trimToEmpty(getRespExt()));
    return sb.toString();
}

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

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

From source file:com.threewks.thundr.http.service.ning.NingTransformers.java

private static List<Integer> ports(String portString) {
    List<Integer> ports = new ArrayList<Integer>();
    if (portString != null) {
        for (String string : StringUtil.split(portString, ",")) {
            ports.add(Integer.parseInt(StringUtils.trimToEmpty(string)));
        }/* w  ww.ja v  a 2  s  . c  o  m*/
    }
    return ports.isEmpty() ? null : ports;
}

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

@Override
public String chkString() {
    StringBuilder sb = new StringBuilder();
    sb.append(super.baseChkString()).append(StringUtils.trimToEmpty(getUsrId()))
            .append(StringUtils.trimToEmpty(getUsrCustId())).append(StringUtils.trimToEmpty(getBgRetUrl()))
            .append(StringUtils.trimToEmpty(getTrxId())).append(StringUtils.trimToEmpty(getRetUrl()))
            .append(StringUtils.trimToEmpty(getMerPriv()));
    return sb.toString();
}

From source file:com.esri.geoportal.harvester.migration.MigrationBrokerDefinitionAdaptor.java

/**
 * Creates instance of the adaptor.//w  w  w  .  j a  v  a  2  s. co m
 *
 * @param def broker definition
 * @throws InvalidDefinitionException if invalid definition
 */
public MigrationBrokerDefinitionAdaptor(EntityDefinition def) throws InvalidDefinitionException {
    super(def);
    if (StringUtils.trimToEmpty(def.getType()).isEmpty()) {
        def.setType(MigrationConnector.TYPE);
    } else if (!MigrationConnector.TYPE.equals(def.getType())) {
        throw new InvalidDefinitionException("Broker definition doesn't match");
    } else {
        jndi = get(P_JNDI_NAME);
        preserveUuids = BooleanUtils.toBoolean(get(P_PRESERVE_UUIDS));
    }
}

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

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