Example usage for org.apache.commons.lang StringUtils abbreviate

List of usage examples for org.apache.commons.lang StringUtils abbreviate

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils abbreviate.

Prototype

public static String abbreviate(String str, int maxWidth) 

Source Link

Document

Abbreviates a String using ellipses.

Usage

From source file:com.sfs.ucm.controller.ProjectPackageAction.java

/**
 * save action// ww  w.j a  v a 2  s.  c o  m
 * 
 * @throws UCMException
 */
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void save() throws UCMException {
    try {
        if (validate()) {
            if (this.projectPackage.getId() == null) {
                this.project.addProjectPackage(this.projectPackage);
            }

            try {
                em.persist(this.project);
            } catch (javax.ejb.EJBException e) {
                if (e.getCausedByException().equals(OptimisticLockException.class)) {
                    logger.error("OptimisticLockException {}", e.getMessage());
                    this.facesContextMessage.warningMessage("Another user is modifying this Artifact");
                }
                throw new UCMException(e);
            }

            logger.info("saved {}", this.projectPackage.getName());
            this.facesContextMessage.infoMessage("{0} saved successfully",
                    StringUtils.abbreviate(this.projectPackage.getName(), 25));

            // refresh list
            loadList();
            this.selected = true;
        }
    } catch (Exception e) {
        throw new UCMException(e);
    }
}

From source file:com.sfs.captor.model.Actor.java

/**
 * @return the responsibilities
 */
public String getResponsibilitiesAbbrv() {
    return StringUtils.abbreviate(responsibilities, Constants.ABBRV_DESC_LEN);
}

From source file:com.sfs.captor.model.Task.java

/**
 * @return the abbreviated name
 */
public String getNameAbbrv() {
    return StringUtils.abbreviate(this.name, Constants.ABBRV_NAME_LEN);
}

From source file:com.sfs.captor.model.TestCase.java

/**
 * Return identifier name string of the form UC1: name
 * //from   w w w . j  av a 2 s.com
 * @return identifier name
 */
public String getIdentifierNameAbbrv() {
    return getArtifact() + ": " + StringUtils.abbreviate(this.name, 40);
}

From source file:de.tudarmstadt.lt.n2n.annotators.RelationAnnotator.java

private void searchForRelationEntities(JCas aJCas) {
    for (Sentence sentence : JCasUtil.select(aJCas, Sentence.class)) {

        List<? extends Annotation> searchlist = null;
        if (_covering_annotation_type == null || Sentence.class.equals(_covering_annotation_type))
            searchlist = Arrays.asList(sentence);
        else//w  w  w .  j  av a2s .  co m
            searchlist = JCasUtil.selectCovered(_covering_annotation_type, sentence);

        for (Annotation clause_like_covering_anno : searchlist) {
            if (!JCasUtil.selectCovered(_covering_annotation_type, clause_like_covering_anno).isEmpty())
                continue;

            LOG.trace("searching for new relations in {} annotation [{}].",
                    _covering_annotation_type.getSimpleName(),
                    StringUtils.abbreviate(clause_like_covering_anno.getCoveredText(), 50));

            searchAndCreateEntityPairs(aJCas, sentence, clause_like_covering_anno);

            LOG.debug("found {} relations for {} annotation [{}].",
                    JCasUtil.selectCovered(Relation.class, clause_like_covering_anno).size(),
                    _covering_annotation_type.getSimpleName(),
                    StringUtils.abbreviate(clause_like_covering_anno.getCoveredText(), 50));
        }
    }
}

From source file:ch.ksfx.web.pages.publishing.ManagePublishingConfiguration.java

public String getAbbreviatedTextData() {
    if (publishingSharedData.getTextData() != null) {
        return StringUtils.abbreviate(publishingSharedData.getTextData(), 100);
    }/*from  www.  j  a v a 2 s.  c  o m*/

    return "";
}

From source file:de.unidue.inf.is.ezdl.gframedl.components.checkboxlist.CheckBoxListCellRenderer.java

private void makeDescriptionText(List<String> lines) {
    StringBuilder textBuilder = new StringBuilder();
    if (lines.size() > 1) {
        String lastLine = lines.get(1);

        if (lines.size() > 2) {
            lastLine = StringUtils.abbreviate(lastLine, lastLine.length() - 1);
        }//from   ww w  . ja  v  a 2  s.c om

        textBuilder.append(lines.get(0)).append("\n").append(lastLine);
        description.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    } else if (lines.size() > 0) {
        textBuilder.append(lines.get(0));
        description.setBorder(BorderFactory.createEmptyBorder(16, 10, 10, 10));
    }

    description.setText(textBuilder.toString());
}

From source file:com.sfs.captor.model.TestSet.java

/**
 * Return identifier name string of the form UC1: name
 * //  w  w  w .j a va 2s .c  o m
 * @return identifier name
 */
public String getIdentifierNameAbbrv() {
    return getArtifact() + ": " + StringUtils.abbreviate(this.name, 25);
}

From source file:com.sfs.captor.model.Actor.java

/**
 * @return the needs
 */
public String getNeedsAbbrv() {
    return StringUtils.abbreviate(needs, Constants.ABBRV_DESC_LEN);
}

From source file:com.sfs.captor.model.UseCase.java

/**
 * @return the objective
 */
public String getObjectiveAbbrv() {
    return StringUtils.abbreviate(objective, 50);
}