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.edgenius.core.Server.java

/**
 * @param prop/* w w w.j  a  v  a 2  s  . c o  m*/
 */
public void syncFrom(Properties prop) {
    dbType = StringUtils.trimToEmpty(prop.getProperty("server.db.type"));
    dbConnectType = StringUtils.trimToEmpty(prop.getProperty("server.db.connect.type"));
    dbDriverClass = StringUtils.trimToEmpty(prop.getProperty("server.db.driver.class.name"));
    dbUrl = StringUtils.trimToEmpty(prop.getProperty("server.db.url"));
    dbSchema = StringUtils.trimToEmpty(prop.getProperty("server.db.schema"));
    dbUsername = StringUtils.trimToEmpty(prop.getProperty("server.db.username"));
    dbPassword = StringUtils.trimToEmpty(prop.getProperty("server.db.password"));
    dbJNDI = StringUtils.trimToEmpty(prop.getProperty("server.db.jndi"));

    mailHost = StringUtils.trimToEmpty(prop.getProperty("mail.smtp.host"));
    mailHostPort = StringUtils.trimToEmpty(prop.getProperty("mail.smtp.port"));
    mailUsername = StringUtils.trimToEmpty(prop.getProperty("mail.smtp.username"));
    mailPassword = StringUtils.trimToEmpty(prop.getProperty("mail.smtp.password"));
    mailProperties = StringUtils.trimToEmpty(prop.getProperty("mail.smtp.properties"));
    mailJndi = StringUtils.trimToEmpty(prop.getProperty("mail.smtp.jndi"));

    mqServerEmbedded = StringUtils.trimToEmpty(prop.getProperty("mq.server.embedded"));
    mqServerUrl = StringUtils.trimToEmpty(prop.getProperty("mq.server.url"));
    quartzJobstoreDriver = StringUtils.trimToEmpty(prop.getProperty("quartz.jobstore.driver"));

    //set some default values
    if ("".equals(dbConnectType)) {
        dbConnectType = "jdbc";
    }
    if ("".equals(mqServerEmbedded)) {
        mqServerEmbedded = "true";
    }
    if ("".equals(quartzJobstoreDriver)) {
        quartzJobstoreDriver = "org.quartz.impl.jdbcjobstore.StdJDBCDelegate";
    }
}

From source file:gov.va.med.pharmacy.peps.presentation.common.displaytag.DefaultHssfExportView.java

/**
 * escapeColumnValue/*w ww  .ja v  a 2  s  .  c  o  m*/
 * @param rawValue unmodified text
 * @return String with html/xml removed
 */
protected String escapeColumnValue(Object rawValue) {

    if (rawValue == null) {
        return null;
    }

    String returnString = ObjectUtils.toString(rawValue);

    // Extract text
    try {
        returnString = extractText(returnString);
    } catch (IOException e) {
        LOG.warn(e.getLocalizedMessage());
    }

    // escape the String to get the tabs, returns, newline explicit as \t \r \n
    returnString = StringEscapeUtils.escapeJava(StringUtils.trimToEmpty(returnString));

    // remove tabs, insert four whitespaces instead
    returnString = StringUtils.replace(StringUtils.trim(returnString), "\\t", "    ");

    // remove the return, only newline valid in excel
    returnString = StringUtils.replace(StringUtils.trim(returnString), "\\r", " ");

    // unescape so that \n gets back to newline
    returnString = StringEscapeUtils.unescapeJava(returnString);

    return returnString;
}

From source file:com.prowidesoftware.swift.model.field.Field78.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *//*from   w w w. jav  a  2  s.  com*/
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(StringUtils.trimToEmpty(getComponent1()));
    appendInLines(result, 2, 13);
    return result.toString();
}

From source file:com.prowidesoftware.swift.model.field.Field77H.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *///from ww  w  .jav a  2s .c om
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(StringUtils.trimToEmpty(getComponent1()));
    if (StringUtils.isNotEmpty(getComponent2())) {
        result.append("/");
        result.append(StringUtils.trimToEmpty(getComponent2()));
    }
    if (StringUtils.isNotEmpty(getComponent3())) {
        result.append("//");
        result.append(StringUtils.trimToEmpty(getComponent3()));
    }
    return result.toString();
}

From source file:com.hangum.tadpole.erd.core.relation.RelationUtil.java

private static String moveSpec(String val) {
    return StringUtils.trimToEmpty(val.replaceAll("\\[", "").replaceAll("\\]", ""));
}

From source file:com.prowidesoftware.swift.model.field.Field422.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 */// ww  w.j a  v a2 s.c o m
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(StringUtils.trimToEmpty(getComponent1()));
    result.append(StringUtils.trimToEmpty(getComponent2()));
    result.append(StringUtils.trimToEmpty(getComponent3()));
    result.append(StringUtils.trimToEmpty(getComponent4()));
    result.append(StringUtils.trimToEmpty(getComponent5()));
    result.append(StringUtils.trimToEmpty(getComponent6()));
    result.append(StringUtils.trimToEmpty(getComponent7()));
    result.append(StringUtils.trimToEmpty(getComponent8()));
    result.append(StringUtils.trimToEmpty(getComponent9()));
    result.append(StringUtils.trimToEmpty(getComponent10()));
    result.append(StringUtils.trimToEmpty(getComponent11()));
    result.append(StringUtils.trimToEmpty(getComponent12()));
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent13()));
    return result.toString();
}

From source file:com.prowidesoftware.swift.model.field.Field94B.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *//*from w  ww  . j  a  v a2 s . com*/
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(":");
    result.append(StringUtils.trimToEmpty(getComponent1()));
    result.append("/");
    if (StringUtils.isNotEmpty(getComponent2())) {
        result.append(StringUtils.trimToEmpty(getComponent2()));
    }
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent3()));
    if (StringUtils.isNotEmpty(getComponent4())) {
        result.append("/");
        result.append(StringUtils.trimToEmpty(getComponent4()));
    }
    return result.toString();
}

From source file:com.prowidesoftware.swift.model.field.Field134.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *//*from   w  w  w .  j  a v  a2 s .com*/
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(StringUtils.trimToEmpty(getComponent1()));
    result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL);
    result.append(StringUtils.trimToEmpty(getComponent2()));
    result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL);
    result.append(StringUtils.trimToEmpty(getComponent3()));
    return result.toString();
}

From source file:com.prowidesoftware.swift.model.field.Field97B.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *//*from   w w  w  . j a  va 2  s. c o m*/
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(":");
    result.append(StringUtils.trimToEmpty(getComponent1()));
    result.append("/");
    if (StringUtils.isNotEmpty(getComponent2())) {
        result.append(StringUtils.trimToEmpty(getComponent2()));
    }
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent3()));
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent4()));
    return result.toString();
}

From source file:com.hangum.tadpole.application.initialize.wizard.SystemAdminWizardDefaultUserPage.java

/**
 * validate //from   ww w.j ava  2  s  .  c  om
 * 
 * @param strEmail
 * @param strPass
 * @param strRePass
 */
private void validateValue(String strEmail, String strPass, String strRePass) {
    strEmail = StringUtils.trimToEmpty(strEmail);
    strPass = StringUtils.trimToEmpty(strPass);
    strRePass = StringUtils.trimToEmpty(strRePass);

    strPass = StringUtils.removeEnd(strPass, "\t");
    strPass = StringUtils.removeEnd(strPass, "\n");

    strRePass = StringUtils.removeEnd(strRePass, "\t");
    strRePass = StringUtils.removeEnd(strRePass, "\n");

    isComplete = false;
    if ("".equals(strEmail)) { //$NON-NLS-1$
        errorSet(textEmail, Messages.get().SystemAdminWizardPage_35);
        return;
    } else if (!ValidChecker.isValidEmailAddress(strEmail)) {
        errorSet(textEmail, Messages.get().SystemAdminWizardPage_48);
        return;
    } else if (!ValidChecker.isSimplePasswordChecker(strPass)) { //$NON-NLS-1$
        errorSet(textPasswd, Messages.get().SystemAdminWizardPage_37);
        return;
    } else if (!strPass.equals(strRePass)) { //$NON-NLS-1$
        errorSet(textRePasswd, Messages.get().SystemAdminWizardPage_39);
        return;
    }

    isComplete = true;
    setErrorMessage(null);
    setPageComplete(true);
}