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:mitm.common.mail.repository.hibernate.MailRepositoryItemEntity.java
private void initMessageID(MimeMessage message) { try {// ww w .j a v a 2s . com messageID = StringUtils.abbreviate(message.getMessageID(), MESSAGE_ID_MAX_LENGTH); } catch (MessagingException e) { logger.debug("Error getting messageID.", e); } }
From source file:mobi.chouette.model.Line.java
/** * set line drawing color <br/>//from w w w . ja va2 s .c o m * truncated to 6 characters if too long * * @param value * New value in RRGGBB hexadecimal format */ public void setColor(String value) { color = StringUtils.abbreviate(value, 6); }
From source file:com.sfs.captor.controller.ProductReleaseAction.java
/** * Validate productRelease/* w ww . j av a 2s . com*/ * <ul> * <li>If new productRelease check for duplicate</li> * </ul> * * @return flag true if validation is successful */ private boolean validate() { boolean isvalid = true; if (this.productRelease.getId() == null) { if (this.productReleases.contains(this.productRelease)) { this.facesContextMessage.errorMessage("{0} already exists", StringUtils.abbreviate(this.productRelease.getVersion(), 25)); logger.error("{} already exists", this.productRelease.getVersion()); isvalid = false; RequestContext requestContext = RequestContext.getCurrentInstance(); requestContext.addCallbackParam("validationFailed", !isvalid); } } return isvalid; }
From source file:mitm.application.djigzo.james.mailets.AbstractRegExpPolicyChecker.java
private void handleError(Mail mail, Exception e) { logException(e);//w ww . j a v a 2 s.c o m /* * Place the error message in the Mail attributes so the exact details * of the error can be retrieved by other Mailets */ DjigzoMailAttributes mailAttributes = new DjigzoMailAttributesImpl(mail); /* * Get the root cause and add make sure the error message has some sane length */ String errorMessage = StringUtils.abbreviate(ExceptionUtils.getRootCauseMessage(e), MAX_POLICY_VIOLATION_ERROR_MESSAGE_LENGTH); mailAttributes.setPolicyViolationErrorMessage(errorMessage); mail.setState(errorProcessor); }
From source file:com.google.ie.common.builder.IdeaBuilder.java
/** * Shortens the length of title and description fields * /*from w w w. ja v a 2s . c o m*/ * @param idea */ private void shortenFields(Idea idea) { if (null != idea) { /* 50 chars for title */ idea.setTitle(StringUtils.abbreviate(idea.getTitle(), 50)); /* 100 chars for description */ idea.setDescription(StringUtils.abbreviate(idea.getDescription(), 150)); } }
From source file:com.evolveum.midpoint.model.common.expression.evaluator.GenerateExpressionEvaluator.java
private String toHumanReadableString(StringPolicyType stringPolicy) { if (stringPolicy.getDescription() != null) { return "StringPolicy: " + StringUtils.abbreviate(stringPolicy.getDescription(), 60); }/*from ww w .j a va 2 s. c o m*/ return "StringPolicy"; }
From source file:mitm.common.mail.repository.hibernate.MailRepositoryItemEntity.java
private void initSubject(MimeMessage message) { try {/* w w w . ja v a 2 s .co m*/ try { subject = message.getSubject(); } catch (MessagingException e) { /* * Fallback to raw headers */ subject = message.getHeader("subject", ", "); } subject = StringUtils.abbreviate(subject, SUBJECT_MAX_LENGTH); } catch (MessagingException e) { logger.debug("Error getting subject.", e); } }
From source file:com.sfs.captor.controller.ProjectPackageAction.java
/** * Validate projectPackage/*from w w w .j av a 2 s. co m*/ * <ul> * <li>If new projectPackage check for duplicate</li> * </ul> * * @return flag true if validation is successful */ private boolean validate() { boolean isvalid = true; if (this.projectPackage.getId() == null) { if (this.projectPackages.contains(this.projectPackage)) { this.facesContextMessage.errorMessage("{0} already exists", StringUtils.abbreviate(this.projectPackage.getName(), 25)); logger.error("{} already exists", this.projectPackage.getName()); isvalid = false; RequestContext requestContext = RequestContext.getCurrentInstance(); requestContext.addCallbackParam("validationFailed", !isvalid); } } return isvalid; }
From source file:mobi.chouette.model.Line.java
/** * set line text color <br/>//from www .ja va2s . c o m * truncated to 6 characters if too long * * @param value * New value in RRGGBB hexadecimal format */ public void setTextColor(String value) { textColor = StringUtils.abbreviate(value, 6); }
From source file:de.tudarmstadt.lt.n2n.annotators.JoBimPrinter.java
private void process_detailed(JCas aJCas) { _printstream.format("=== %s begin cas [%s] ===%n", getClass().getSimpleName(), StringUtils.abbreviate(aJCas.getDocumentText(), 30).replace("\n", "")); Collection<? extends Annotation> covering_annotations = JCasUtil.select(aJCas, _covering_annotation_type); for (Annotation covering_annotation : covering_annotations) { long src_id = aJCas.hashCode() + covering_annotation.getBegin(); int repetitions = 0; if (covering_annotation instanceof RepeatedSentence) repetitions = ((RepeatedSentence) covering_annotation).getRepetitionCount(); for (JoBim jb : getJoBims(covering_annotation, _sort_output)) { for (JobimAnnotationExtractor extractor : _extractors) { _printstream.format("- found JoBim covering '%s':%n", jb.getCoveredText()); _printstream.format(" - %-15s %s %n", "key=", extractor.extractKey(jb)); _printstream.format(" - %-15s %s %n", "values=", extractor.extractValues(jb)); _printstream.format(" - %-15s %s %n", "src_id=", String.valueOf(src_id)); _printstream.format(" - %-15s %s %n", "begin_idx=", String.valueOf(jb.getBegin())); _printstream.format(" - %-15s %s %n", "end_idx=", String.valueOf(jb.getEnd())); _printstream.format(" - %-15s %s %n", "repetitions=", String.valueOf(repetitions)); _printstream.format(" - %-15s %s %n", "occurrences=", String.valueOf(repetitions + 1)); _printstream.format(" - %-15s %s %n", "concise=", _write_old_format ? get_concise_string_old_format(jb, covering_annotation, extractor, repetitions) : get_concise_string(jb, covering_annotation, src_id, extractor, repetitions)); }//from w ww. j av a2s . c o m } } _printstream.format("=== %s end cas ===%n%n", getClass().getSimpleName()); }