List of usage examples for org.apache.commons.lang WordUtils abbreviate
public static String abbreviate(String str, int lower, int upper, String appendToEnd)
From source file:org.apache.hadoop.hive.ql.exec.Utilities.java
/** * convert "From src insert blah blah" to "From src insert ... blah" *//*from w ww .j av a 2s . c o m*/ public static String abbreviate(String str, int max) { str = str.trim(); int len = str.length(); int suffixlength = 20; if (len <= max) { return str; } suffixlength = Math.min(suffixlength, (max - 3) / 2); String rev = StringUtils.reverse(str); // get the last few words String suffix = WordUtils.abbreviate(rev, 0, suffixlength, ""); suffix = StringUtils.reverse(suffix); // first few .. String prefix = StringUtils.abbreviate(str, max - suffix.length()); return prefix + suffix; }
From source file:org.jahia.ajax.gwt.helper.NodeHelper.java
private void populateNames(GWTJahiaNode n, JCRNodeWrapper node, Locale uiLocale) { n.setName(JCRContentUtils.unescapeLocalNodeName(node.getName())); n.setEscapedName(node.getName());/*from w w w . j av a 2 s . c om*/ try { if (node.getPath().equals("/")) { n.setDisplayName("root"); n.setName("root"); n.setEscapedName("root"); } else if (node instanceof JCRUserNode) { n.setDisplayName(((JCRUserNode) node).getDisplayableName(uiLocale)); } else if (node instanceof JCRGroupNode) { n.setDisplayName(((JCRGroupNode) node).getDisplayableName(uiLocale)); } else { n.setDisplayName(WordUtils.abbreviate( JCRContentUtils.unescapeLocalNodeName(node.getDisplayableName()), 70, 90, "...")); } } catch (Exception e) { logger.error("Error when getting name", e); } }
From source file:org.jahia.services.workflow.jbpm.custom.email.JBPMMailProducer.java
protected void fillSubject(MailTemplate template, Message email, WorkItem workItem, JCRSessionWrapper session) throws Exception { String subject = template.getSubject(); if (subject != null) { String evaluatedSubject = evaluateExpression(workItem, subject, session).replaceAll("[\r\n]", ""); email.setHeader("Subject", WordUtils.abbreviate(evaluatedSubject, 60, 74, "...")); }/*from w ww. ja va 2 s. co m*/ }
From source file:org.jahia.services.workflow.jbpm.JBPMMailProducer.java
protected void fillSubject(Message email, Execution execution, JCRSessionWrapper session) throws MessagingException { String subject = getTemplate().getSubject(); if (subject != null) { try {/*from w w w . j ava 2 s . c om*/ String evaluatedSubject = evaluateExpression(execution, subject, session).replaceAll("[\r\n]", ""); email.setSubject(WordUtils.abbreviate(evaluatedSubject, 60, 74, "...")); } catch (RepositoryException e) { logger.error(e.getMessage(), e); } catch (ScriptException e) { logger.error(e.getMessage(), e); } } }