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.github.arnabk.BlockingChecker.java

public void execute(int frequencyInMins, String... hostsToCheck) {

    while (true) {

        for (int index = 1; index < hostsToCheck.length; index++) {
            StringBuilder sb = new StringBuilder();
            sb.append("Timestamp : ").append(new Date()).append(", ").append("Server : ")
                    .append(hostsToCheck[index]).append(", ").append("Status code : ");
            try {
                sb.append(Request.Head(prepareURL(StringUtils.trimToEmpty(hostsToCheck[index]))).execute()
                        .returnResponse().getStatusLine().getStatusCode());
            } catch (Exception e) {
                sb.append(" Request failed!");
            }/*  w ww .ja va  2s.c o  m*/
            System.out.println(sb);
        }

        try {
            synchronized (this) {
                wait(frequencyInMins * 60 * 1000);
            }
        } catch (InterruptedException ex) {
            Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

}

From source file:kenh.xscript.database.elements.Sql.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;
    }/*from  w  ww. ja  va2s  .  com*/

    Object sql_ = this.getParsedText();
    String sql = null;
    if (sql_ instanceof String) {
        sql = (String) sql_;
    }

    if (StringUtils.isBlank(sql)) {
        UnsupportedScriptException ex = new UnsupportedScriptException(this, "Can't find the sql.");
        throw ex;
    }

    SQLBean bean = new SQLBean();
    bean.setSql(sql);

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

    for (Element child : children) {
        if (child instanceof Param) {
            Param c = (Param) child;
            ParamBean b = c.getParamBean();
            bean.setParameter(b);
        }
    }

    this.saveVariable(var, bean, null);
}

From source file:com.webbfontaine.valuewebb.bpm.DocumentHistory.java

private void loadUserDetails() {
    UserInfoJosso userInfoJosso = new UserInfoJosso();
    userInfoJosso.setUseCache(true);//w  w w  . ja v  a 2s.co m

    if (history != null) {
        for (Object[] details : history) {

            String userName = (String) details[5];

            if (!userName.equals(DaemonUser.DAEMON_USER_ID)) {
                userInfoJosso.initRemoteUserInfo(userName);

                String firstName = StringUtils.trimToEmpty(userInfoJosso.getProperty(UserConstants.GIVEN_NAME));
                String lastName = StringUtils.trimToEmpty(userInfoJosso.getProperty(UserConstants.SURNAME));
                String firstAndLastName = (firstName + lastName).length() == 0 ? ""
                        : " (" + firstName + ' ' + lastName + ')';

                details[5] = details[5].toString() + firstAndLastName;
            }
        }
    }
}

From source file:com.esri.geoportal.harvester.gptsrc.GptBrokerDefinitionAdaptor.java

/**
 * Creates instance of the adaptor.//  w  w w  .j  a v  a  2s  .co m
 * @param def broker definition
 */
public GptBrokerDefinitionAdaptor(EntityDefinition def) throws InvalidDefinitionException {
    super(def);
    this.credAdaptor = new CredentialsDefinitionAdaptor(def);
    if (StringUtils.trimToEmpty(def.getType()).isEmpty()) {
        def.setType(GptConnector.TYPE);
    } else if (!GptConnector.TYPE.equals(def.getType())) {
        throw new InvalidDefinitionException("Broker definition doesn't match");
    } else {
        try {
            String sHostUrl = get(P_HOST_URL);
            if (sHostUrl != null) {
                sHostUrl = sHostUrl.replaceAll("/*$", "/");
            }
            hostUrl = new URL(sHostUrl);
        } catch (MalformedURLException ex) {
            throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL, get(P_HOST_URL)),
                    ex);
        }
    }
}

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

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

From source file:com.omertron.subbabaapi.model.SubBabaContent.java

public void setType(String type) {
    this.type = StringUtils.trimToEmpty(type);
}

From source file:kenh.xscript.elements.Accum.java

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

    if (StringUtils.isBlank(var)) {
        UnsupportedScriptException ex = new UnsupportedScriptException(this, "Variable name is empty.");
        throw ex;
    }//from  w  w w  .  j av  a2 s.  c o  m

    String thisVar = var;
    if (StringUtils.contains(var, " ")) {
        thisVar = StringUtils.substringAfterLast(var, " ");
    }

    int defaultValue = 0;
    if (this.getEnvironment().containsVariable(thisVar)) {
        Object obj = this.getEnvironment().getVariable(thisVar);
        if (obj instanceof Integer) {
            defaultValue = ((Integer) obj).intValue();
        } else if (obj instanceof String) {
            if (StringUtils.isNumeric((String) obj)) {
                defaultValue = Integer.parseInt((String) obj);
            }

        } else {
            UnsupportedScriptException ex = new UnsupportedScriptException(this,
                    "Only support integer variable.");
            throw ex;
        }
    }
    defaultValue += step;

    saveVariable(var, defaultValue, defaultValue);
}

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

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

From source file:com.omertron.subbabaapi.wrapper.SubBabaWrapper.java

public void setSearchTerm(String searchTerm) {
    this.searchTerm = StringUtils.trimToEmpty(searchTerm);
}

From source file:com.omertron.subbabaapi.model.SubBabaMovie.java

public void setOriginalName(String originalName) {
    this.originalName = StringUtils.trimToEmpty(originalName);
}