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:net.bulletin.pdi.xero.step.XeroGetStepDialog.java

private void populateDialog() {
    wStepname.selectAll();/*from   ww  w .j av  a 2 s .  c o  m*/
    wUrl.setText(StringUtils.trimToEmpty(meta.getUrl()));
    wAuthenticationConsumerKey.setText(StringUtils.trimToEmpty(meta.getAuthenticationConsumerKey()));
    wAuthenticationKeyFile.setText(StringUtils.trimToEmpty(meta.getAuthenticationKeyFile()));
    wContainerElements.setText(StringUtils.trimToEmpty(meta.getContainerElements()));
    wIfModifiedSince.setText(StringUtils.trimToEmpty(meta.getIfModifiedSince()));
    wXmlFieldName.setText(StringUtils.trimToEmpty(meta.getXmlFieldName()));
    wWhere.setText(StringUtils.trimToEmpty(meta.getWhere()));
}

From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.composite.MongoDBLoginComposite.java

@Override
public boolean makeUserDBDao(boolean isTest) {
    if (!isValidateInput(isTest))
        return false;

    String dbUrl = String.format(getSelectDB().getDB_URL_INFO(), StringUtils.trimToEmpty(textHost.getText()),
            StringUtils.trimToEmpty(textPort.getText()), StringUtils.trimToEmpty(textDatabase.getText()));
    if (!"".equals(textJDBCOptions.getText())) {
        dbUrl += "/?" + textJDBCOptions.getText();
    }//from  w w  w . ja  v  a 2  s.  com

    userDB = new UserDBDAO();
    userDB.setDbms_type(getSelectDB().getDBToString());
    userDB.setUrl(dbUrl);
    userDB.setUrl_user_parameter(textJDBCOptions.getText());
    userDB.setDb(textDatabase.getText());
    userDB.setGroup_name(StringUtils.trimToEmpty(preDBInfo.getComboGroup().getText()));
    userDB.setDisplay_name(StringUtils.trimToEmpty(preDBInfo.getTextDisplayName().getText()));
    userDB.setOperation_type(PublicTadpoleDefine.DBOperationType
            .getNameToType(preDBInfo.getComboOperationType().getText()).toString());
    userDB.setHost(StringUtils.trimToEmpty(textHost.getText()));
    userDB.setPort(StringUtils.trimToEmpty(textPort.getText()));
    userDB.setUsers(StringUtils.trimToEmpty(textUser.getText()));
    userDB.setPasswd(StringUtils.trimToEmpty(textPassword.getText()));
    userDB.setLocale(StringUtils.trimToEmpty(comboLocale.getText()));
    userDB.setExt1(StringUtils.trimToEmpty(textReplicaSet.getText()));

    // others connection  .
    OthersConnectionInfoDAO otherConnectionDAO = othersConnectionInfo.getOthersConnectionInfo();
    userDB.setIs_readOnlyConnect(
            otherConnectionDAO.isReadOnlyConnection() ? PublicTadpoleDefine.YES_NO.YES.name()
                    : PublicTadpoleDefine.YES_NO.NO.name());
    userDB.setIs_autocommit(otherConnectionDAO.isAutoCommit() ? PublicTadpoleDefine.YES_NO.YES.name()
            : PublicTadpoleDefine.YES_NO.NO.name());
    userDB.setIs_showtables(otherConnectionDAO.isShowTables() ? PublicTadpoleDefine.YES_NO.YES.name()
            : PublicTadpoleDefine.YES_NO.NO.name());

    //      userDB.setIs_table_filter(otherConnectionDAO.isTableFilter()?PublicTadpoleDefine.YES_NO.YES.name():PublicTadpoleDefine.YES_NO.NO.name());
    //      userDB.setTable_filter_include(otherConnectionDAO.getStrTableFilterInclude());
    //      userDB.setTable_filter_exclude(otherConnectionDAO.getStrTableFilterExclude());

    userDB.setIs_profile(otherConnectionDAO.isProfiling() ? PublicTadpoleDefine.YES_NO.YES.name()
            : PublicTadpoleDefine.YES_NO.NO.name());
    userDB.setQuestion_dml(otherConnectionDAO.isDMLStatement() ? PublicTadpoleDefine.YES_NO.YES.name()
            : PublicTadpoleDefine.YES_NO.NO.name());

    userDB.setIs_external_browser(otherConnectionDAO.isExterBrowser() ? PublicTadpoleDefine.YES_NO.YES.name()
            : PublicTadpoleDefine.YES_NO.NO.name());
    userDB.setListExternalBrowserdao(otherConnectionDAO.getListExterBroswer());

    //      userDB.setIs_visible(otherConnectionDAO.isVisible()?PublicTadpoleDefine.YES_NO.YES.name():PublicTadpoleDefine.YES_NO.NO.name());
    userDB.setIs_summary_report(otherConnectionDAO.isSummaryReport() ? PublicTadpoleDefine.YES_NO.YES.name()
            : PublicTadpoleDefine.YES_NO.NO.name());

    // ? ?? ? .
    userDB.setRole_id(PublicTadpoleDefine.USER_ROLE_TYPE.ADMIN.toString());

    return true;
}

From source file:com.metasoft.claim.service.impl.claim.ClaimServiceImpl.java

@Override
public ClaimSaveVo findById(Integer id, SecUser user) {
    TblClaimRecovery entity = super.findById(id);
    ClaimSaveVo claimSaveVo = new ClaimSaveVo();

    claimSaveVo.setTxtClaimNumber(StringUtils.trimToEmpty(entity.getClaimNumber()));
    claimSaveVo.setTxtPolicyNo(StringUtils.trimToEmpty(entity.getPolicyNo()));
    claimSaveVo.setTxtlicenseNumber(StringUtils.trimToEmpty(entity.getLicenseNumber()));

    if (entity.getAccidentDate() != null) {
        claimSaveVo.setTxtAccidentDate(//w  w w . j av  a 2  s. co m
                DateToolsUtil.convertToString(entity.getAccidentDate(), DateToolsUtil.LOCALE_TH));
    }
    if (entity.getMaturityDate() != null) {
        claimSaveVo.setTxtMaturityDate(
                DateToolsUtil.convertToString(entity.getMaturityDate(), DateToolsUtil.LOCALE_TH));
    }

    if (entity.getClaimType() != null) {
        claimSaveVo.setSelClaimType(String.valueOf(entity.getClaimType().getId()));
    }

    claimSaveVo.setTxtClaimInsuranceAmount(NumberToolsUtil.decimalFormat(entity.getClaimInsuranceAmount()));
    claimSaveVo.setTxtRequestAmount(NumberToolsUtil.decimalFormat(entity.getRequestAmount()));
    claimSaveVo.setTxtClaimAmount(NumberToolsUtil.decimalFormat(entity.getClaimAmount()));

    if (entity.getPartyInsurance() != null) {
        claimSaveVo.setSelPartyInsurance(String.valueOf(entity.getPartyInsurance().getId()));
    }
    claimSaveVo.setTxtPartyLicenseNumber(StringUtils.trimToEmpty(entity.getPartyLicenseNumber()));
    claimSaveVo.setTxtPartyClaimNumber(StringUtils.trimToEmpty(entity.getPartyClaimNumber()));
    claimSaveVo.setTxtPartyPolicyNo(StringUtils.trimToEmpty(entity.getPartyPolicyNo()));
    claimSaveVo.setTxtInvoiceNumber(StringUtils.trimToEmpty(entity.getInvoiceNumber()));

    if (entity.getAgent() != null) {
        claimSaveVo.setSelAgent(String.valueOf(entity.getAgent().getId()));
    }

    claimSaveVo.setTxtJobDate(DateToolsUtil.convertToString(entity.getJobDate(), DateToolsUtil.LOCALE_TH));
    claimSaveVo.setSelJobStatus(String.valueOf(entity.getJobStatus().getId()));
    claimSaveVo.setTxtReceiveRemark(StringUtils.trimToEmpty(entity.getReceiveRemark()));
    claimSaveVo.setTxtJobNo(StringUtils.trimToEmpty(entity.getJobNo()));

    claimSaveVo.setTxtFollowRemark(StringUtils.trimToEmpty(entity.getFollowRemark()));
    if (entity.getFollowDate() != null) {
        claimSaveVo.setTxtFollowDate(
                DateToolsUtil.convertToString(entity.getFollowDate(), DateToolsUtil.LOCALE_TH));
    }

    claimSaveVo.setTxtCloseRemark(StringUtils.trimToEmpty(entity.getCloseRemark()));
    if (entity.getCloseDate() != null) {
        claimSaveVo
                .setTxtCloseDate(DateToolsUtil.convertToString(entity.getCloseDate(), DateToolsUtil.LOCALE_TH));
    }

    claimSaveVo.setTxtCancelRemark(StringUtils.trimToEmpty(entity.getCancelRemark()));
    if (entity.getCancelDate() != null) {
        claimSaveVo.setTxtCancelDate(
                DateToolsUtil.convertToString(entity.getCancelDate(), DateToolsUtil.LOCALE_TH));
    }

    if (entity.getReceiveMoneyType() != null) {
        claimSaveVo.setSelReceiveMoneyType(String.valueOf(entity.getReceiveMoneyType().getId()));
    }

    claimSaveVo.setTxtClaimId(String.valueOf(entity.getId()));

    return claimSaveVo;
}

From source file:ch.entwine.weblounge.common.impl.content.image.ImageContentImpl.java

/**
 * {@inheritDoc}/* w ww.  j  a va 2  s  . com*/
 * 
 * @see ch.entwine.weblounge.common.impl.content.ResourceContentImpl#equals(java.lang.Object)
 */
@Override
public boolean equals(Object obj) {
    if (obj instanceof ImageContent) {
        ImageContent content = (ImageContent) obj;
        if (width != content.getWidth())
            return false;
        if (height != content.getHeight())
            return false;
        if (dateTaken != null) {
            if (!dateTaken.equals(content.getDateTaken()))
                return false;
        } else {
            if (content.getDateTaken() != null)
                return false;
        }
        if (!StringUtils.trimToEmpty(location).equals(StringUtils.trimToEmpty(content.getLocation())))
            return false;
        if (gpsLat != content.getGpsLat())
            return false;
        if (gpsLong != content.getGpsLong())
            return false;
        if (filmspeed != content.getFilmspeed())
            return false;
        if (fnumber != content.getFNumber())
            return false;
        if (focalWidth != content.getFocalWidth())
            return false;
        if (exposureTime != content.getExposureTime())
            return false;
        return super.equals(content);
    }
    return false;
}

From source file:ch.entwine.weblounge.common.impl.request.RequestUtils.java

/**
 * Ensures parameter values potentially containing the <code>%</code>
 * character are decoded properly using the <code>utf-8</code> encoding.
 * /*from w ww.j av a2s  . c  o m*/
 * @param s
 *          the parameter value
 * @param encoding
 *          the character encoding to be used
 * @return the properly decoded value
 * @throws UnsupportedEncodingException
 *           if <code>encoding</code> is not supported by the plattform
 */
static String decode(String s, String encoding) throws UnsupportedEncodingException {
    s = StringUtils.trimToEmpty(s);
    while (true) {
        try {
            return URLDecoder.decode(s, encoding);
        } catch (IllegalArgumentException e) {
            // Illegal hex characters in escape (%) pattern - For input string: "si"
            String m = e.getMessage();
            String illegalSequence = m.substring(m.length() - 3, m.length() - 1);
            s = s.replaceAll("%" + illegalSequence, "%25" + illegalSequence);
        }
    }
}

From source file:com.edgenius.wiki.webapp.admin.action.GeneralAdminAction.java

public String update() {
    try {/* w  w w.ja  v  a2  s .c o  m*/

        GlobalSetting global = settingService.getGlobalSetting();
        //this just for confirm Global and GlobalSetting has consistent value
        Global.syncFrom(global);
        Global.resetURLInfo(baseURL);
        //copy back base URL information to global setting.
        Global.syncTo(global);

        //other global setting 
        global.setDefaultNotifyMail(notifyEmail);
        global.setDefaultReceiverMailAddress(receiverEmail);
        global.setCcToSystemAdmin(ccSysAdmins);

        global.setDelayRemoveSpaceHours(removeDelay);
        global.setSpaceQuota(spaceQuota * MB);
        if (allowPublic)
            global.removeSuppress(SUPPRESS.SIGNUP.name());
        else
            global.addSuppress(SUPPRESS.SIGNUP.name());

        global.setRegisterMethod(
                signupNeedApproval ? REGISTER_METHOD.approval.name() : REGISTER_METHOD.signup.name());
        global.setDelayOfflineSyncMinutes(syncFeq);
        global.setPublicSearchEngineAllow(allowSE);
        global.setDetectLocaleFromRequest(detectLocale);
        String[] cl = sysLang.split("_");
        if (cl.length == 2) {
            if (!StringUtils.equalsIgnoreCase(global.getDefaultLanguage(), cl[0])) {
                //language changed, so try to reload analyzer for different language.
                Global.DefaultLanguage = cl[0];
                analyzerProvider.loadAnalyzer();
                themeService.cleanThemeCache();
            }
            global.setDefaultLanguage(cl[0]);
            global.setDefaultCountry(cl[1].toUpperCase());
        }
        //for display - only accept lower case
        sysLang = sysLang.toLowerCase();
        //Widget load title and desc from i18n file, here reset widget, then it will reload i18n again before next render.
        widgetService.resetWidgets();

        global.setSystemTitle(systemTitle);
        boolean oldVc = global.isVersionCheck();
        global.setVersionCheck(versionCheck);

        global.setWebservice(Global.enable(soap));
        global.setRestservice(Global.enable(rest));
        settingService.saveOrUpdateGlobalSetting(global);

        if (oldVc != versionCheck) {
            try {
                if (versionCheck)
                    versionCheckJobInvoker.invokeJob();
                else
                    versionCheckJobInvoker.cancelJob();
            } catch (QuartzException e) {
                getRequest().setAttribute("error", "Unable to reset version check job status.");
                log.error("Unable to reset version check job status", e);
            }
        }

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        // Shell
        Shell.enabled = shell;
        if (!Shell.enabled) {
            Shell.key = null;
        } else {
            //acquire shell key now
            if (!Shell.requestInstanceShellKey()) {
                Shell.enabled = false;
                shell = false;
                getRequest().setAttribute("error", "Failed to connect Shell website " + Shell.rootUrl
                        + ". Please ensure Shell website is running and try again.");
            }
        }
        Shell.save();

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        // Mail SMTP
        Server server = settingService.getServerSetting();
        //reset SMTP host values
        server.setMailHost("");
        server.setMailHostPort("-1");
        server.setMailUsername("");
        server.setMailPassword("");
        server.setMailProperties("");
        server.setMailJndi("");
        if (mailType == 0) {
            //Smtp host mode
            smtpHost = StringUtils.trimToEmpty(smtpHost);
            //parse smtpHost - remove protocol prefix and slip port and host
            if (smtpHost.indexOf("://") > 0) {
                //remove stmp://
                smtpHost = smtpHost.substring(smtpHost.indexOf("://") + 3);
            }
            server.setMailHost(smtpHost);
            server.setMailHostPort(smtpPort);
            if (smtpAuth) {
                server.setMailUsername(mailUsername);
                server.setMailPassword(mailPassword);
                if (smtpConnectType == 2) { //SSL
                    server.setMailProperties(
                            "mail.smtp.auth:true;;mail.smtp.socketFactory.class:javax.net.ssl.SSLSocketFactory");
                } else if (smtpConnectType == 1) { //TLS
                    server.setMailProperties("mail.smtp.auth:true;;mail.smtp.starttls.enable:true");
                } else {
                    server.setMailProperties("mail.smtp.auth:true");
                }
            }

            //reload mail session
            try {
                mailSender.setHost(smtpHost);
                mailSender.setPort(NumberUtils.toInt(smtpPort));
                mailSender.setUsername(mailUsername);
                mailSender.setPassword(mailPassword);
                mailSender.setMailProperties(server.getMailProperties());
                mailSender.resetMailSessionByProperties();
            } catch (Exception e) {
                log.error("Reset mail by properties with error", e);
                getRequest().setAttribute("error", "Reset mail by properties with error: " + e.getMessage());
            }
        } else if (mailType == 1) {
            if (!StringUtils.equals(server.getMailJndi(), smtpJNDI)) {
                //reload mail session bean
                try {
                    mailSender.resetMailSessionByJNDI(smtpJNDI);
                } catch (Exception e) {
                    log.error("Reset mail JNDI with error", e);
                    getRequest().setAttribute("error", "Reset mail JNDI with error: " + e.getMessage());
                }
            }

            //JNDI mode
            server.setMailJndi(smtpJNDI);
        } //not set
        settingService.saveOrUpdateServerSetting(server);

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        // Space Quota
        if (allSpacesQuota) {
            int update = repositoryService.updateExistWorkspacesQuota(spaceQuota * MB);
            log.info(update + " workspaces update quota to " + spaceQuota + "MB");
        }
    } catch (SettingServiceException e) {
        log.error("Update server.properties failed", e);
    }
    return SUCCESS;
}

From source file:adalid.commons.util.StrUtils.java

public static String getString(String equals, String separator, String open, String close, Object object) {
    if (ObjUtils.isBlank(object)) {
        return StringUtils.EMPTY;
    }/*from w ww  .  j  a va2  s  . com*/
    if (object.getClass().isArray()) {
        Object[] array = (Object[]) object;
        return getString(equals, separator, open, close, array);
    }
    if (object instanceof KVP) {
        KVP value = (KVP) object;
        return value.toString(equals, separator, open, close);
    }
    if (object instanceof String) {
        String value = (String) object;
        return StringUtils.trimToEmpty(value);
    }
    return StringUtils.trimToEmpty(object.toString());
}

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

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *///from   ww w. j ava2  s  . c  om
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(StringUtils.trimToEmpty(getComponent1()));
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent2()));
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent3()));
    if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent4())) {
        result.append(StringUtils.trimToEmpty(getComponent4()));
    }
    result.append(StringUtils.trimToEmpty(getComponent5()));
    result.append(StringUtils.trimToEmpty(getComponent6()));
    result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL);
    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()));
    return result.toString();
}

From source file:be.fedict.eid.pkira.blm.model.contracthandler.ContractHandlerBean.java

private void checkLegalNotice(RequestType request, Registration registration)
        throws ContractHandlerBeanException {
    String incomingLegalNotice = StringUtils.trimToEmpty(request.getLegalNotice());
    String expectedLegalNotice = StringUtils
            .trimToEmpty(registration.getCertificateDomain().getCertificateAuthority().getLegalNotice());

    if (!StringUtils.equals(expectedLegalNotice, incomingLegalNotice)) {
        throw new ContractHandlerBeanException(ResultType.INVALID_MESSAGE, "Invalid legal notice");
    }/*from w  w w  . j  av a 2  s.c o m*/
}

From source file:com.hmsinc.epicenter.webapp.remoting.GeographyService.java

private String stripCountyFromQuery(String query) {
    String suffix = "county";
    String rtn = query.toLowerCase();
    while (suffix.length() > 0) {
        if (rtn.endsWith(suffix)) {
            rtn = StringUtils.trimToEmpty(query.substring(0, query.length() - suffix.length()));
            break;
        }// www  . ja va2  s.c om
        suffix = suffix.substring(0, suffix.length() - 1);
    }
    return rtn;
}