Example usage for org.apache.commons.lang3.text StrBuilder isEmpty

List of usage examples for org.apache.commons.lang3.text StrBuilder isEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang3.text StrBuilder isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Checks is the string builder is empty (convenience Collections API style method).

Usage

From source file:com.marand.thinkmed.api.demographics.PersonNameForm.java

private static String combineName(final String name1, final String name2, final String delimiter) {
    final StrBuilder builder = new StrBuilder();
    if (StringUtils.isNotBlank(name1)) {
        builder.append(name1);/*from  w w w .j  a v a 2s .co  m*/
    }
    if (StringUtils.isNotBlank(name2)) {
        if (!builder.isEmpty()) {
            builder.append(delimiter);
        }
        builder.append(name2);
    }

    return builder.toString();
}

From source file:com.mgmtp.jfunk.core.reporting.CsvReporter.java

@Override
public void addResult(final ReportContext context) {
    if (!(TestModule.class.isAssignableFrom(context.getTestObjectType()))) {
        // we are only interested in the data for each module
        return;/*from ww  w  .j a  v  a  2  s.com*/
    }

    log.debug("Adding result to reporter '{}'", getName());

    synchronized (this) {
        if (columns == null) {
            initColumns();
        }

        Map<String, DataSet> dataSets = currentDataSetsProvider.get();
        StrBuilder sb = new StrBuilder(256);
        for (Column column : columns) {
            String dsKey = column.dataSetKey;
            String value;

            if (StringUtils.isNotBlank(dsKey)) {
                // get value from data set
                DataSet ds = dataSets.get(dsKey);
                checkNotNull(ds, "No data set available for key: " + dsKey);
                value = ds.getValue(column.key);
            } else {
                // get property
                value = configProvider.get().get(column.key);
            }

            appendEscapedAndQuoted(sb, value);
        }

        // additional result column
        appendEscapedAndQuoted(sb, context.getTestObjectName());
        appendEscapedAndQuoted(sb, context.isSuccess() ? JFunkConstants.OK : JFunkConstants.ERROR);

        if (context.isSuccess()) {
            appendEscapedAndQuoted(sb, "");
        } else {
            Throwable th = context.getThrowable();
            String msg = th.getMessage();

            Throwable root = th;
            while (root.getCause() != null) {
                root = root.getCause();
            }

            String rootMsg = root.getMessage();
            if (rootMsg != null && !rootMsg.equals(msg)) {
                msg += " - Root Message: " + rootMsg;
            }

            if (isBlank(msg)) {
                msg = th.getClass().getName();
            }
            appendEscapedAndQuoted(sb, msg);
        }

        if (sb.isEmpty()) {
            log.info("Ignoring empty row in report");
        } else {
            String line = sb.toString();
            reportLines.add(line);
        }
    }
}

From source file:org.eclipse.ebr.maven.AboutFilesUtil.java

private String getDevelopedByInfo(final Artifact artifact, final Model artifactPom) {
    final StrBuilder developedByInfo = new StrBuilder();

    // prefer organization if available
    if (null != artifactPom.getOrganization()) {
        final String url = artifactPom.getOrganization().getUrl();
        boolean wroteUrl = false;
        if (isPotentialWebUrl(url)) {
            try {
                final URL organizationUrl = toUrl(url); // parse as URL to avoid surprises
                developedByInfo.append("<a href=\"").append(organizationUrl.toExternalForm())
                        .append("\" target=\"_blank\">");
                wroteUrl = true;//from www  .  ja v  a 2s . c o m
            } catch (final MalformedURLException e) {
                getLog().debug(e);
                getLog().warn(format("Invalide organization url '%s' in artifact pom '%s'.", url,
                        artifact.getFile()));
            }
        }
        if (StringUtils.isNotBlank(artifactPom.getOrganization().getName())) {
            developedByInfo.append(escapeHtml4(artifactPom.getOrganization().getName()));
        } else if (StringUtils.isNotBlank(url)) {
            developedByInfo.append(escapeHtml4(removeWebProtocols(url)));
        }
        if (wroteUrl) {
            developedByInfo.append("</a>");
        }
    }

    // use to developers if no organization is available
    if (developedByInfo.isEmpty()) {
        if (!artifactPom.getDevelopers().isEmpty()) {
            appendDeveloperInfo(developedByInfo, artifactPom);
        } else {
            getLog().warn(format(
                    "Neither organization nor developer information is available for artifact '%s:%s:%s'. Please fill in manually.",
                    artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()));
            developedByInfo.append("someone");
        }
    }
    return developedByInfo.toString();
}

From source file:org.eclipse.ebr.maven.AboutFilesUtil.java

private String getOriginInfo(final Artifact artifact, final Model artifactPom) {
    final StrBuilder originInfo = new StrBuilder();
    {/*from w ww . j  a  va 2s . com*/
        final String url = artifactPom.getUrl();
        if (isPotentialWebUrl(url)) {
            try {
                final URL organizationUrl = toUrl(url); // parse as URL to avoid surprises
                originInfo.append(escapeHtml4(artifactPom.getName()))
                        .append(" including its source is available from ");
                originInfo.append("<a href=\"").append(organizationUrl.toExternalForm())
                        .append("\" target=\"_blank\">");
                originInfo.append(escapeHtml4(removeWebProtocols(url)));
                originInfo.append("</a>.");
            } catch (final MalformedURLException e) {
                getLog().debug(e);
                getLog().warn(
                        format("Invalide project url '%s' in artifact pom '%s'.", url, artifact.getFile()));
            }
        } else if (StringUtils.isNotBlank(url)) {
            originInfo.append(escapeHtml4(artifactPom.getName()))
                    .append(" including its source is available from ");
            originInfo.append(escapeHtml4(url)).append('.');
        }
    }
    // fall-back to Maven coordinates
    if (originInfo.isEmpty()) {
        getLog().warn(format(
                "No project origin information is available for artifact '%s:%s:%s'. Please fill in manually.",
                artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()));
        originInfo.append(escapeHtml4(artifactPom.getName())).append(" is available from Maven as ");
        originInfo.append(escapeHtml4(artifact.getGroupId())).append(':')
                .append(escapeHtml4(artifact.getArtifactId())).append(':')
                .append(escapeHtml4(artifact.getVersion())).append('.');
    }

    // include additional contact information if available
    if (null != artifactPom.getIssueManagement()) {
        originInfo.append(' ');
        appendIssueTrackingInfo(originInfo, artifact, artifactPom);
    }

    if (!artifactPom.getMailingLists().isEmpty()) {
        originInfo.append(" The following");
        if (artifactPom.getMailingLists().size() == 1) {
            originInfo.append(" mailing list");
        } else {
            originInfo.append(" mailing lists");
        }
        originInfo.append(" can be used to communicate with the project communities: ");
        appendMailingListInfo(originInfo, artifact, artifactPom);
        originInfo.append(".");
    }
    return originInfo.toString();
}

From source file:org.eclipse.ebr.maven.EclipseIpLogUtil.java

private String getProjectOrigin(final Model recipePom, final Xpp3Dom existingIpLog) {
    final String existingValue = getProjectInfo(existingIpLog, "origin");
    if (existingValue != null)
        return existingValue;

    final StrBuilder developedByInfo = new StrBuilder();

    // prefer organization if available
    if (null != recipePom.getOrganization()) {
        if (StringUtils.isNotBlank(recipePom.getOrganization().getName())) {
            developedByInfo.append(escapeHtml4(recipePom.getOrganization().getName()));
        } else if (StringUtils.isNotBlank(recipePom.getOrganization().getUrl())) {
            developedByInfo.append(escapeHtml4(removeWebProtocols(recipePom.getOrganization().getUrl())));
        }//from   ww  w .  ja  v a 2 s.  c o  m
    }

    // use to developers if no organization is available
    if (developedByInfo.isEmpty()) {
        if (!recipePom.getDevelopers().isEmpty()) {
            appendDeveloperInfo(developedByInfo, recipePom);
        }
    }

    // don't return anything if nothing is available
    if (developedByInfo.isEmpty())
        return null;

    return developedByInfo.toString();
}