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.esri.geoportal.harvester.api.base.DataReferenceSerializer.java

/**
 * Serializes data reference/*from w  ww .  j a va2  s .com*/
 *
 * @param out output print stream
 * @param ref data reference
 * @throws IOException if serialization fails
 */
public void serialize(PrintStream out, DataReference ref) throws IOException {

    byte[] bBrokerUri = ENCODER.encode(ref.getBrokerUri().toASCIIString().getBytes("UTF-8"));
    byte[] bBrokerName = ENCODER.encode(StringUtils.trimToEmpty(ref.getBrokerName()).getBytes("UTF-8"));
    byte[] bId = ENCODER.encode(ref.getId().getBytes("UTF-8"));
    byte[] bLastModifiedDate = ENCODER
            .encode((ref.getLastModifiedDate() != null ? formatIsoDate(ref.getLastModifiedDate()) : "")
                    .getBytes("UTF-8"));
    byte[] bSourceUri = ENCODER.encode(ref.getSourceUri().toASCIIString().getBytes("UTF-8"));
    byte[] bContent = ENCODER.encode(ref.getContent());
    byte[] bContentType = ENCODER.encode(
            ref.getContentType() != null ? ref.getContentType().toString().getBytes("UTF-8") : new byte[0]);

    out.write(bBrokerUri);
    out.write(',');
    out.write(bBrokerName);
    out.write(',');
    out.write(bId);
    out.write(',');
    out.write(bLastModifiedDate);
    out.write(',');
    out.write(bSourceUri);
    out.write(',');
    out.write(bContentType);
    out.write(',');
    out.write(bContent);
    out.write('\r');
    out.write('\n');
    out.flush();
}

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

@Override
public String chkString() {
    StringBuilder sb = new StringBuilder(baseChkString());
    sb.append(StringUtils.trimToEmpty(getOrdId())).append(StringUtils.trimToEmpty(getUsrCustId()))
            .append(StringUtils.trimToEmpty(getTransAmt())).append(StringUtils.trimToEmpty(getOpenAcctId()))
            .append(StringUtils.trimToEmpty(getOpenBankId())).append(StringUtils.trimToEmpty(getServFee()))
            .append(StringUtils.trimToEmpty(getServFeeAcctId())).append(StringUtils.trimToEmpty(getRetUrl()))
            .append(StringUtils.trimToEmpty(getBgRetUrl())).append(StringUtils.trimToEmpty(getMerPriv()))
            .append(StringUtils.trimToEmpty(getRespExt()));
    return sb.toString();
}

From source file:com.mirth.connect.plugins.httpauth.AuthenticationResult.java

public static AuthenticationResult Challenged(String authenticateHeader) {
    AuthenticationResult result = new AuthenticationResult(AuthStatus.CHALLENGED);
    result.addResponseHeader(HttpHeader.WWW_AUTHENTICATE.asString(),
            StringUtils.trimToEmpty(authenticateHeader));
    return result;
}

From source file:com.webbfontaine.valuewebb.model.validators.tt.TTServiceDataValidator.java

public void validate() {
    String currentKey = ttGen.getIdfNum();

    if (StringUtils.isEmpty(currentKey) || ErrorHandling.getInstance().hasScopedErrors("idfNum")) {
        return;//from   ww w. j ava2  s.  c o m
    }

    LOGGER.trace("Started for {0}", currentKey);

    TtGen serviceTt = null;

    try {
        serviceTt = new TTDataImporter().resolveServiceAndLoad(ttGen);
    } catch (Exception e) {
        LOGGER.warn("Unable to validate DAI/FDI number, warning message will be shown");
        addError(Utils.translate("IDF Num.") + ": " + Utils.translate(Messages.IMPOSSIBLE_TO_PROCESS));
    }

    if (serviceTt == null) {
        ErrorHandling.addFacesMessageError("idfNum", Utils.translate(Messages.IDF_NUMBER_INEXISTENT));
    } else {
        String serviceTIN = StringUtils.trimToEmpty(serviceTt.getImpTin());
        String currentTIN = StringUtils.trimToEmpty(ttGen.getImpTin());

        if (!currentTIN.equals(serviceTIN)) {
            ErrorHandling.addFacesMessageError("impTin",
                    Utils.translate(Messages.ALLOWED_VALUE) + ": " + serviceTIN);
        }

        String serviceDate = serviceTt.getIdfDate() == null ? ""
                : DateUtils.dateToString(serviceTt.getIdfDate(), "dd/MM/yyyy");
        String currentDate = ttGen.getIdfDate() == null ? ""
                : DateUtils.dateToString(ttGen.getIdfDate(), "dd/MM/yyyy");

        if (!serviceDate.equals(currentDate)) {
            ErrorHandling.addFacesMessageError("idfDate",
                    Utils.translate(Messages.ALLOWED_VALUE) + ": " + serviceDate);
        }

        LOGGER.debug("TT key: {0}, date: {1}, TIN: {2}. Service data key: {3}, date: {4}, TIN: {5}", currentKey,
                currentDate, currentTIN, serviceTt.getIdfNum(), serviceDate, serviceTIN);
    }
}

From source file:com.creditcloud.payment.model.chinapnr.NetSaveResponse.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(getTransAmt()))
            .append(StringUtils.trimToEmpty(getTrxId())).append(StringUtils.trimToEmpty(getRetUrl()))
            .append(StringUtils.trimToEmpty(getBgRetUrl())).append(StringUtils.trimToEmpty(getMerPriv()));
    return sb.toString();
}

From source file:me.mayo.telnetkek.player.PlayerCommandEntry.java

public String buildOutput(PlayerInfo player, boolean useReasonPrompt) {
    String output = StringUtils.replaceEach(getFormat(),
            new String[] { "$TARGET_NAME", "$TARGET_IP", "$TARGET_UUID", },
            new String[] { player.getName(), player.getIp(), player.getUuid() });

    if (useReasonPrompt && output.contains("$REASON")) {
        final String reason = StringUtils.trimToEmpty(JOptionPane.showInputDialog(null,
                "Input reason:\n" + output, "Input Reason", JOptionPane.PLAIN_MESSAGE));
        output = StringUtils.replace(output, "$REASON", reason);
    }/*from ww  w. j a  v a  2  s  .  co m*/

    return StringUtils.trimToEmpty(output);
}

From source file:com.omertron.themoviedbapi.model.PersonCast.java

public void setCharacter(String character) {
    this.character = StringUtils.trimToEmpty(character);
}

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

public void setNetworkuuid(String networkuuid) {
    this.networkUuid = StringUtils.trimToEmpty(networkuuid);
}

From source file:com.nesscomputing.syslog4j.impl.log4j.Syslog4jAppenderSkeleton.java

protected static boolean isTrueOrOn(String inputValue) {
    boolean trueOrOn = false;
    final String value = StringUtils.trimToEmpty(inputValue);

    if ("true".equalsIgnoreCase(value) || "on".equalsIgnoreCase(value)) {
        trueOrOn = true;/*  w w w  .j  ava  2 s  . c  om*/

    } else if ("false".equalsIgnoreCase(value) || "off".equalsIgnoreCase(value)) {
        trueOrOn = false;
    } else {
        LogLog.error("Value \"" + value + "\" not true, on, false, or off -- assuming false");
    }

    return trueOrOn;
}

From source file:com.mirth.connect.plugins.httpauth.AuthenticationResult.java

public void setRealm(String realm) {
    this.realm = StringUtils.trimToEmpty(realm);
}