List of usage examples for org.apache.commons.lang StringUtils abbreviate
public static String abbreviate(String str, int maxWidth)
Abbreviates a String using ellipses.
From source file:com.flexive.shared.ContentLinkFormatter.java
protected String format(String formatString, FxPaths.Item item) { final String result = format(StringUtils.defaultString(formatString, DEFAULT_ITEM), new FxPK(item.getReferenceId())).replace("%{nodeId}", String.valueOf(item.getNodeId())); return result.replace("%{caption20}", StringUtils.abbreviate(item.getCaption(), MAX_CAPTION_LEN)) .replace("%{caption}", item.getCaption()); }
From source file:de.tudarmstadt.lt.ltbot.writer.PlainTextDocumentWriter.java
@Override protected void innerProcess(CrawlURI curi) throws InterruptedException { try {/*from w ww .j av a 2 s . c o m*/ File basedir = getPath().getFile(); FileUtils.ensureWriteableDirectory(basedir); } catch (IOException e) { throw new RuntimeException(String.format("Could not ensure writeable base directory '%s'. %s: %s.", getPath(), e.getClass().getName(), e.getMessage()), e); } _num_uris.getAndIncrement(); RecordingInputStream recis = curi.getRecorder().getRecordedInput(); if (0L == recis.getResponseContentLength()) { return; } // content already written for this URI. boolean is_revisited = curi.getData().containsKey(TEXT_EXTRACT_KEY); if (is_revisited) return; try { String cleaned_plaintext = _textExtractorInstance.getCleanedUtf8PlainText(curi); updateOuputFile(); writeplaintext(curi, cleaned_plaintext); String cleaned_plaintext_abbr = StringUtils.abbreviate(cleaned_plaintext, 50); curi.getData().put(TEXT_EXTRACT_KEY, cleaned_plaintext_abbr); } catch (IOException e) { curi.getNonFatalFailures().add(e); } }
From source file:mobi.chouette.model.Company.java
/** * set web site url <br/>//from www . ja v a2s. c om * truncated to 255 characters if too long * * @param value * New value */ public void setUrl(String value) { url = StringUtils.abbreviate(value, 255); }
From source file:com.sfs.captor.model.TestPlan.java
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("TestPlan [id="); builder.append(id);/*w ww .j a v a 2 s.co m*/ builder.append(", description="); builder.append(StringUtils.abbreviate(description, 80)); builder.append("]"); return builder.toString(); }
From source file:com.sfs.captor.controller.ProductReleaseAction.java
/** * save action/*from w w w . ja v a 2s .co m*/ * * @throws UCMException */ public void save() throws UCMException { try { if (validate()) { this.productRelease.setModifiedBy(authUser.getUsername()); if (this.productRelease.getId() == null) { this.project.addProductRelease(this.productRelease); } em.persist(this.project); logger.info("saved {}", this.productRelease.getVersion()); this.facesContextMessage.infoMessage("{0} saved successfully", StringUtils.abbreviate(this.productRelease.getVersion(), 25)); // refresh list loadList(); this.selected = true; // update producers projectEventSrc.fire(project); this.productReleaseSrc.fire(this.project); } } catch (Exception e) { throw new UCMException(e); } }
From source file:mobi.chouette.model.Company.java
/** * set default timezone <br/>/*w ww. ja v a 2 s. co m*/ * truncated to 255 characters if too long * * @param value * New value */ public void setTimeZone(String value) { timeZone = StringUtils.abbreviate(value, 255); }
From source file:com.sfs.captor.controller.ProjectPackageAction.java
/** * save action/*from w ww. j a v a 2 s.c om*/ * * @throws UCMException */ public void save() throws UCMException { try { if (validate()) { configure(); 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)); // update producers projectEvent.fire(this.project); projectPackageSrc.fire(this.project); // refresh list loadList(); this.selected = true; } } catch (Exception e) { throw new UCMException(e); } }
From source file:com.sfs.captor.model.StakeholderRequest.java
/** * @return the name abbreviated */ public String getNameAbbrv() { return StringUtils.abbreviate(name, 20); }
From source file:de.tudarmstadt.lt.ltbot.writer.SentenceWriter.java
@Override protected void innerProcess(CrawlURI curi) throws InterruptedException { try {//www . ja va 2 s. c om File basedir = getPath().getFile(); FileUtils.ensureWriteableDirectory(basedir); } catch (IOException e) { throw new RuntimeException(String.format("Could not ensure writeable base directory '%s'. %s: %s.", getPath(), e.getClass().getName(), e.getMessage()), e); } _num_uris.getAndIncrement(); RecordingInputStream recis = curi.getRecorder().getRecordedInput(); if (0L == recis.getResponseContentLength()) { return; } // content already written for this URI. boolean is_revisited = curi.getData().containsKey(SENTENCE_EXTRACT); if (is_revisited) return; try { String cleaned_plaintext = _textExtractorInstance.getCleanedUtf8PlainText(curi); updateOuputFile(); writeSentences(curi, cleaned_plaintext); String cleaned_plaintext_abbr = StringUtils.abbreviate(cleaned_plaintext, 50); curi.getData().put(SENTENCE_EXTRACT, cleaned_plaintext_abbr); } catch (IOException e) { curi.getNonFatalFailures().add(e); } }
From source file:com.sfs.ucm.model.Issue.java
/** * @return the abbreviated title */ public String getTitleAbbrv() { return StringUtils.abbreviate(this.title, Constants.ABBRV_NAME_LEN); }