List of usage examples for org.apache.commons.lang3 StringUtils abbreviate
public static String abbreviate(final String str, final int maxWidth)
Abbreviates a String using ellipses.
From source file:com.ijuru.kumva.sms.Messages.java
/** * Formats an SMS message from a list of revisions * @param entries the entries//from w w w . j av a 2 s. com * @return the SMS message body */ public static String searchResult(SearchResult result, String query) { StringBuilder builder = new StringBuilder(); List<Entry> entries = result.getMatches(); if (entries.size() > 0) { for (int e = 0; e < entries.size(); ++e) { Entry entry = entries.get(e); String entryStr = formatEntry(entry); if (e > 0) builder.append(ENTRY_SEPARATOR); builder.append(entryStr); if (builder.length() >= MAX_CHARS) break; } } else { builder.append(EMPTY_MESSAGE.replace("%s", query)); } String message = builder.toString(); if (message.length() > MAX_CHARS) message = StringUtils.abbreviate(message, MAX_CHARS); return message; }
From source file:com.twinsoft.convertigo.beans.statements.ContextSetStatement.java
public String toString() { return "set(" + key + ")=" + StringUtils.abbreviate(expression, 25); }
From source file:com.twinsoft.convertigo.beans.statements.GetNodesStatement.java
@Override public String toString() { return StringUtils.abbreviate(variableName, 20); }
From source file:ductive.parse.parsers.EOFParser.java
@Override public Result<Void> doApply(ParseContext ctx) { if (ctx.length() != 0) { String info = StringEscapeUtils.escapeJava(StringUtils.abbreviate(ctx.toString(), 60)); throw new NoMatchException(String.format("Extra content '%s' found while looking for EOF", info), ctx, 0);/* ww w . j a v a 2s.c om*/ } return Result.make(null, ctx); }
From source file:com.twinsoft.convertigo.beans.statements.ContextAddTextNodeStatement.java
public String toString() { String name = "<" + tagname + ">eval('" + StringUtils.abbreviate(expression, 15) + "')</" + tagname + ">"; return name;// ww w . j av a 2 s . c o m }
From source file:ca.phon.ui.JFileLabel.java
private void updateText() { String txt = ""; if (file != null) { setToolTipText(file.getAbsolutePath()); if (showNameOnly) { txt = file.getName();//from w w w . j a v a 2 s .c om } else { txt = StringUtils.abbreviate(file.getAbsolutePath(), maxChars); // txt = StringUtils.shortenStringUsingToken(file.getAbsolutePath(), PhonConstants.ellipsis+"", maxChars); } } setText(txt); }
From source file:com.sonicle.webtop.tasks.TplHelper.java
public static String buildTaskReminderSubject(ProfileI18n profileI18n, VTask task) { StringBuilder sb = new StringBuilder(); sb.append(StringUtils.abbreviate(task.getSubject(), 30)); return MessageFormat.format( WT.lookupResource(SERVICE_ID, profileI18n.getLocale(), TasksLocale.EMAIL_REMINDER_SUBJECT), sb.toString());//from w w w . j a va 2s . c o m }
From source file:com.adaptris.core.services.jdbc.TruncatedParameterLogger.java
@Override public void log(int paramterIndex, Object o) { String s = o == null ? "(null)" : o.toString(); log.trace("Setting argument {} to [{}]", paramterIndex, StringUtils.abbreviate(s, truncateLength())); }
From source file:com.sonicle.webtop.mail.TplHelper.java
public static String buildEventInvitationReplyEmailSubject(Locale locale, PartStat response, String eventTitle) {// w ww.j a v a 2 s . c om StringBuilder sb = new StringBuilder(); if (PartStat.ACCEPTED.equals(response)) { sb.append(WT.lookupResource(SERVICE_ID, locale, MailLocaleKey.ICAL_REPLY_ACCEPTED)); } else if (PartStat.DECLINED.equals(response)) { sb.append(WT.lookupResource(SERVICE_ID, locale, MailLocaleKey.ICAL_REPLY_DECLINED)); } else if (PartStat.TENTATIVE.equals(response)) { sb.append(WT.lookupResource(SERVICE_ID, locale, MailLocaleKey.ICAL_REPLY_ACCEPTED)); } sb.append(" "); sb.append(StringUtils.abbreviate(eventTitle, 30)); return sb.toString(); }
From source file:io.knotx.knot.templating.impl.HandlebarsFragment.java
String compileWith(Handlebars handlebars) { try {/*from w ww . j a v a 2 s . co m*/ Template compiledFragment = handlebars.compileInline(unwrappedContent); LOGGER.trace("Applying context [{}] to fragment [{}]", fragment.context(), StringUtils .abbreviate(fragment.content().replaceAll("[\n\r\t]", ""), MAX_FRAGMENT_CONTENT_LOG_LENGTH)); return compiledFragment .apply(Context.newBuilder(fragment.context()).push(JsonObjectValueResolver.INSTANCE).build()); } catch (IOException e) { LOGGER.error("Could not process fragment [{}]", fragment.content(), e); throw new IllegalStateException("Handlebars fragment can not be evaluated correctly."); } }