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:hudson.plugins.sonar.SonarPublisher.java

/**
 * @deprecated since 2.2
 */
@Deprecated
public String getLanguage() {
    return StringUtils.trimToEmpty(language);
}

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

/**
 * {@inheritDoc}/* w ww .j  av a  2s. c om*/
 * 
 * @see java.lang.Object#equals(java.lang.Object)
 */
@Override
public boolean equals(Object obj) {
    if (obj instanceof ResourceContent) {
        ResourceContent c = (ResourceContent) obj;
        if (!StringUtils.trimToEmpty(filename).equals(StringUtils.trimToEmpty(c.getFilename())))
            return false;
        if (!StringUtils.trimToEmpty(author).equals(StringUtils.trimToEmpty(c.getAuthor())))
            return false;
        return language.equals(c.getLanguage());
    }
    return false;
}

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

@Override
public TrackingSearchResultVoPaging searchPagingLabor(String paramJobDateStart, String paramJobDateEnd,
        String id, String paramClaimTypeId, int start, int length) {

    Date jobDateStart = null;//from  ww  w  .ja  v  a  2s.  co  m
    Date jobDateEnd = null;
    SecUser agent = null;
    ClaimType claimType = null;

    if (StringUtils.isNotBlank(paramJobDateStart)) {
        jobDateStart = DateToolsUtil.convertStringToDate(paramJobDateStart, DateToolsUtil.LOCALE_TH);
    }

    if (StringUtils.isNotBlank(paramJobDateEnd)) {
        jobDateEnd = DateToolsUtil.convertStringToDate(paramJobDateEnd, DateToolsUtil.LOCALE_TH);
    }
    System.out.println(">>>>> agenId = " + id);

    if (StringUtils.isNotBlank(id)) {
        agent = userService.findById(Integer.parseInt(id));
    }

    if (StringUtils.isNotBlank(paramClaimTypeId)) {
        claimType = ClaimType.getById(Integer.parseInt(paramClaimTypeId));
    }

    ReportPaging reportPaging = reportDao.searchPaging(jobDateStart, jobDateEnd, agent, claimType, start,
            length);
    TrackingSearchResultVoPaging voPaging = new TrackingSearchResultVoPaging();

    voPaging.setDraw(reportPaging.getDraw());
    voPaging.setRecordsFiltered(reportPaging.getRecordsFiltered());
    voPaging.setRecordsTotal(reportPaging.getRecordsTotal());
    voPaging.setData(new ArrayList<TrackingSearchResultVo>());

    int i = 1;
    if (reportPaging != null && reportPaging.getData() != null) {
        for (TblClaimRecovery claim : reportPaging.getData()) {
            TrackingSearchResultVo vo = new TrackingSearchResultVo();
            vo.setNo(i);
            i++;

            vo.setClaimNumber(StringUtils.trimToEmpty(claim.getClaimNumber()));
            if (claim.getClaimType() != null) {
                vo.setClaimType(claim.getClaimType().getName());
            }
            if (claim.getPartyInsurance() != null) {
                vo.setInsuranceName(claim.getPartyInsurance().getName());
            }
            if (claim.getJobDate() != null) {
                vo.setJobDate(DateToolsUtil.convertToString(claim.getJobDate(), DateToolsUtil.LOCALE_TH));
            }

            if (claim.getMaturityDate() != null) {
                vo.setMaturityDate(
                        DateToolsUtil.convertToString(claim.getMaturityDate(), DateToolsUtil.LOCALE_TH));
            }

            if (claim.getAccidentDate() != null) {
                vo.setAccidentDate(
                        DateToolsUtil.convertToString(claim.getAccidentDate(), DateToolsUtil.LOCALE_TH));
            }

            if (claim.getLicenseNumber() != null) {
                vo.setLicenseNumber(claim.getLicenseNumber());
            }
            if (claim.getClaimAmount() != null) {
                vo.setClaimAmount(String.valueOf(claim.getClaimAmount()));
            }
            if (claim.getPolicyNo() != null) {
                vo.setPolicyNo(claim.getPolicyNo());
            }
            if (claim.getCloseDate() != null) {
                vo.setCloseDate(DateToolsUtil.convertToString(claim.getCloseDate(), DateToolsUtil.LOCALE_TH));

            }
            if (claim.getAgent() != null) {
                vo.setAgentName(claim.getAgent().getName() + " " + claim.getAgent().getLastName());

            }
            if (claim.getId() != null) {
                vo.setClaimId(String.valueOf(claim.getId()));

            }
            voPaging.getData().add(vo);
        }

    }

    return voPaging;
}

From source file:daveayan.gherkinsalad.components.core.BaseBrowserElement.java

/**
 * Default Implementation. Asserts that the unexpected texts do not exist in the result of getText() Throws
 * single assertion error with all the texts that were not expected but were present. Takes Screenshot if
 * unexpected texts were found and assertion error was thrown
 *///from w ww .  j  a v  a2 s  .  com
public void should_not_have_text(String... unexpected_texts) {
    if (unexpected_texts != null) {
        String element_text = StringUtils.trimToEmpty(getText());
        for (String unexpected_text : unexpected_texts) {
            String trimmed_unexpected_text = StringUtils.trimToEmpty(unexpected_text);
            if (element_text.contains(trimmed_unexpected_text)) {
                error("Component '" + this + "' has unexpected text(s) '" + element_text + "'It has '"
                        + element_text + "'");
            } else {
                action("Verified component '" + this + "' does not have text '" + element_text + ".");
            }
        }
    }
}

From source file:adalid.core.Report.java

@Override
public int compareTo(Report that) {
    if (that != null) {
        String thisName = StringUtils.trimToEmpty(this.getName());
        String thatName = StringUtils.trimToEmpty(that.getName());
        return thisName.compareTo(thatName);
    }/*from   w  w  w  . j  av  a 2  s  .  co m*/
    return 0;
}

From source file:com.hangum.tadpole.rdb.core.dialog.table.mysql.MySQLTableColumnDialog.java

/**
 * initialize ui//  w w  w .  j ava 2s . co m
 */
private void initUI() {
    if (COMP_STATUS == DATA_STATUS.MODIFY) {
        textColumnName.setText(tableColumnDAO.getField());
        comboType.setText(tableColumnDAO.getType());
        textDefault.setText(StringUtils.trimToEmpty(tableColumnDAO.getDefault()));

        boolean isPK = false;
        for (String strPK : PublicTadpoleDefine.DB_PRIMARY_KEY) {
            if (strPK.equals(tableColumnDAO.getPk()))
                isPK = true;
        }
        btnPrimaryKey.setSelection(isPK);
        btnNotNull.setSelection("YES".equals(tableColumnDAO.getNull())); //$NON-NLS-1$
        btnAutoIncrement.setSelection("auto_increment".equals(tableColumnDAO.getExtra())); //$NON-NLS-1$
        comboCollation.setText(StringUtils.trimToEmpty(tableColumnDAO.getCollation_name()));
        textComment.setText(StringUtils.trimToEmpty(tableColumnDAO.getComment()));
    }
}

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

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

From source file:com.egt.core.util.Utils.java

public static String[] getStringArray(String variable) {
    String str = StringUtils.trimToEmpty(variable);
    String quote = getQuote();/*w w  w  .java  2  s. c o  m*/
    if (str.startsWith(quote) && str.endsWith(quote)) {
        str = str.substring(1, str.length() - 1);
    }
    if (StringUtils.isBlank(str)) {
        return null;
    }
    str = StringUtils.trimToEmpty(str);
    String[] args = new String[0];
    boolean split = true;
    for (int i = 0, j = str.indexOf(quote); i < str.length();) {
        if (j < 0) {
            j = str.length();
        }
        args = split ? add(args, StringUtils.split(str.substring(i, j))) : add(args, str.substring(i, j));
        if (j < str.length()) {
            i = j + 1;
            j = str.indexOf(quote, i);
        } else {
            i = str.length();
        }
        split = !split;
    }
    printObjectArray(args);
    return args;
}

From source file:hudson.plugins.sonar.SonarPublisher.java

/**
 * Root POM. Should be applied only for free-style projects.
 *
 * @return Root POM
 */
public String getRootPom() {
    return StringUtils.trimToEmpty(rootPom);
}

From source file:net.paoding.rose.scanner.ModuleResourceProviderImpl.java

protected void checkModuleResourceCandidate(Local local, FileObject root, FileObject topModuleFile,
        FileObject candidate) throws IOException {

    String relative = topModuleFile.getName().getRelativeName(candidate.getName());
    String mappingPath = null;//from ww w  .j  ava  2 s .  c o m
    String[] interceptedAllow = null;
    String[] interceptedDeny = null;

    ModuleResource parentModule = local.moduleResourceMap.get(candidate.getParent());
    // rose.propertiescontrollersmodule.path?
    FileObject rosePropertiesFile = candidate.getChild("rose.properties");
    if (rosePropertiesFile != null && rosePropertiesFile.exists()) {
        Properties p = new Properties();
        InputStream in = rosePropertiesFile.getContent().getInputStream();
        p.load(in);
        in.close();

        // controllers=ignored...
        String ignored = p.getProperty(CONF_MODULE_IGNORED, "false").trim();
        if ("true".equalsIgnoreCase(ignored) || "1".equalsIgnoreCase(ignored)) {
            if (logger.isInfoEnabled()) {
                logger.info("Ignored module(include submodules) by rose.properties[ignored=" + ignored + "]: "
                        + candidate);
            }
            return;
        }

        mappingPath = p.getProperty(CONF_MODULE_PATH);
        if (mappingPath != null) {
            mappingPath = mappingPath.trim();
            String parentModulePlaceHolder = "${" + CONF_PARENT_MODULE_PATH + "}";
            if (mappingPath.indexOf(parentModulePlaceHolder) != -1) {
                String parentModulePath = "";
                if (candidate.getParent() != null) {
                    parentModulePath = (parentModule == null) ? "" : parentModule.getMappingPath();
                }
                mappingPath = mappingPath.replace(parentModulePlaceHolder, parentModulePath);
            }
            if (mappingPath.length() != 0 && !mappingPath.startsWith("/")) {
                if (parentModule != null) {
                    mappingPath = parentModule.getMappingPath() + "/" + mappingPath;
                } else if (StringUtils.isNotEmpty(relative)) {
                    mappingPath = relative + "/" + mappingPath;
                } else {
                    mappingPath = "/" + mappingPath;
                }
            }
            mappingPath = RoseStringUtil.mappingPath(mappingPath);
        }

        //interceptedAllow?interceptedDeny
        String interceptedAllowStrings = p.getProperty(CONF_INTERCEPTED_ALLOW);
        interceptedAllowStrings = StringUtils.trimToEmpty(interceptedAllowStrings);
        if (interceptedAllowStrings.length() > 0) {
            interceptedAllow = StringUtils.split(interceptedAllowStrings, ",");
        }

        String interceptedDenyStrings = p.getProperty(CONF_INTERCEPTED_DENY);
        interceptedDenyStrings = StringUtils.trimToEmpty(interceptedDenyStrings);
        if (interceptedDenyStrings.length() > 0) {
            interceptedDeny = StringUtils.split(interceptedDenyStrings, ",");
        }

    }
    // 
    if (mappingPath == null) {
        if (parentModule != null) {
            mappingPath = parentModule.getMappingPath() + "/" + candidate.getName().getBaseName();
        } else {
            mappingPath = "";
        }
    }
    ModuleResource moduleResource = new ModuleResource();
    moduleResource.setMappingPath(mappingPath);
    moduleResource.setModuleUrl(candidate.getURL());
    moduleResource.setRelativePath(RoseStringUtil.relativePathToModulePath(relative));
    moduleResource.setParent(parentModule);
    if (interceptedAllow != null) {
        moduleResource.setInterceptedAllow(interceptedAllow);
    }
    if (interceptedDeny != null) {
        moduleResource.setInterceptedDeny(interceptedDeny);
    }
    local.moduleResourceMap.put(candidate, moduleResource);
    local.moduleResourceList.add(moduleResource);
    if (logger.isDebugEnabled()) {
        logger.debug("found module '" + mappingPath + "' in " + candidate.getURL());
    }

    FileObject[] children = candidate.getChildren();
    for (FileObject child : children) {
        if (child.getType().hasContent() && !child.getType().hasChildren()) {
            handlerModuleResource(local, root, candidate, child);
        }
    }
    for (FileObject child : children) {
        if (child.getType().hasChildren()) {
            checkModuleResourceCandidate(local, root, topModuleFile, child);
        }
    }
}