Java Code Examples for org.apache.commons.lang.StringUtils#abbreviate()
The following examples show how to use
org.apache.commons.lang.StringUtils#abbreviate() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: rapidminer-studio File: ConnectionInformationMetaData.java License: GNU Affero General Public License v3.0 | 6 votes |
@Override public String getDescription() { final StringBuilder builder = new StringBuilder(super.getDescription()); ConnectionConfiguration config = Optional.ofNullable(getConfiguration()).orElse(UNKNOWN_CONNECTION); String tags = String.join(TAG_DELIMITER, Optional.ofNullable(config.getTags()).orElseGet(Collections::emptyList)).trim(); String description = StringUtils.abbreviate(Objects.toString(config.getDescription(), "").trim(), DESCRIPTION_PREVIEW_LENGTH); if (!description.isEmpty()) { builder.append("<p style='margin-top:2px;margin-bottom:3px;'>").append(description).append("</p>"); } if (!tags.isEmpty()) { builder.append("<p style='margin-top:2px;'>"); builder.append(I18N.getGUILabel("connection.metadata.connection_type.tags.label")).append(" "); builder.append(tags).append("</p>"); } return builder.toString(); }
Example 2
Source Project: incubator-tajo File: TajoAdmin.java License: Apache License 2.0 | 6 votes |
public static void processList(Writer writer, TajoClient client) throws ParseException, IOException, ServiceException, SQLException { List<BriefQueryInfo> queryList = client.getRunningQueryList(); SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); String fmt = "%1$-20s %2$-7s %3$-20s %4$-30s%n"; String line = String.format(fmt, "QueryId", "State", "StartTime", "Query"); writer.write(line); line = String.format(fmt, line20, line7, line20, line30); writer.write(line); for (BriefQueryInfo queryInfo : queryList) { String queryId = String.format("q_%s_%04d", queryInfo.getQueryId().getId(), queryInfo.getQueryId().getSeq()); String state = getQueryState(queryInfo.getState()); String startTime = df.format(queryInfo.getStartTime()); String sql = StringUtils.abbreviate(queryInfo.getQuery(), 30); line = String.format(fmt, queryId, state, startTime, sql); writer.write(line); } }
Example 3
Source Project: openhab1-addons File: Twitter.java License: Eclipse Public License 2.0 | 6 votes |
/** * Sends a direct message via Twitter * * @param recipientId * the receiver of this direct message * @param messageTxt * the direct message to send * * @return <code>true</code>, if sending the direct message has been successful * and <code>false</code> in all other cases. */ @ActionDoc(text = "Sends a direct message via Twitter", returns = "<code>true</code>, if sending the direct message has been successful and <code>false</code> in all other cases.") public static boolean sendDirectMessage( @ParamDoc(name = "recipientId", text = "the receiver of this direct message") String recipientId, @ParamDoc(name = "messageTxt", text = "the direct message to send") String messageTxt) { if (!checkPrerequisites()) { return false; } try { // abbreviate the Tweet to meet the allowed character limit ... messageTxt = StringUtils.abbreviate(messageTxt, CHARACTER_LIMIT); // send the direct message DirectMessage message = client.sendDirectMessage(recipientId, messageTxt); logger.debug("Successfully sent direct message '{}' to @", message.getText(), message.getRecipientScreenName()); return true; } catch (TwitterException e) { logger.warn("Failed to send Tweet '{}' because of : ", messageTxt, e.getLocalizedMessage()); return false; } }
Example 4
Source Project: idea-php-annotation-plugin File: PhpElementsUtil.java License: MIT License | 6 votes |
@Nullable public static String getClassDeprecatedMessage(@NotNull PhpClass phpClass) { if (phpClass.isDeprecated()) { PhpDocComment docComment = phpClass.getDocComment(); if (docComment != null) { for (PhpDocTag deprecatedTag : docComment.getTagElementsByName("@deprecated")) { String tagValue = deprecatedTag.getTagValue(); if (StringUtils.isNotBlank(tagValue)) { return StringUtils.abbreviate("Deprecated: " + tagValue, 100); } } } } return null; }
Example 5
Source Project: pushfish-android File: SingleMessageLogger.java License: BSD 2-Clause "Simplified" License | 5 votes |
public static void nagUserAboutDynamicProperty(String propertyName, Object target, Object value) { if (!isEnabled()) { return; } nagUserOfDeprecated("Creating properties on demand (a.k.a. dynamic properties)", "Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties"); String propertyWithClass = target.getClass().getName() + "." + propertyName; if (DYNAMIC_PROPERTIES.add(propertyWithClass)) { String propertyWithTarget = String.format("\"%s\" on \"%s\"", propertyName, target); String theValue = (value==null)? "null" : StringUtils.abbreviate(value.toString(), 25); nagUserWith(String.format("Deprecated dynamic property: %s, value: \"%s\".", propertyWithTarget, theValue)); } else { nagUserWith(String.format("Deprecated dynamic property \"%s\" created in multiple locations.", propertyName)); } }
Example 6
Source Project: projectforge-webapp File: KostFormatter.java License: GNU General Public License v3.0 | 5 votes |
/** * Gibt vollständige Kundennummer aus ("5.xxx") und hängt den Kundennamen (max. 30 stellig) an, z. B. "5.120 - DHL Verwaltungs GmbH" * @param kunde */ public static String formatKunde(final KundeDO kunde) { if (kunde == null) { return ""; } return format(kunde) + " - " + StringUtils.abbreviate(kunde.getName(), 30); }
Example 7
Source Project: projectforge-webapp File: TimesheetDO.java License: GNU General Public License v3.0 | 5 votes |
/** * @return The abbreviated description (maximum length is 50 characters). */ @Transient public String getShortDescription() { if (this.description == null) { return ""; } return StringUtils.abbreviate(getDescription(), 50); }
Example 8
Source Project: projectforge-webapp File: BuchungssatzImportRow.java License: GNU General Public License v3.0 | 5 votes |
/** * Achtung: Diese Klasse ruft ggf. korrigierend und ändernd check() auf. * @see java.lang.Object#toString() * @see #check() */ public String toString() { check(); // Leider muss dieser modifizierende check() ausgeführt werden, da auf die aufrufende Klasse ExcelImport kein Einfluss // genommen werden kann. String txt = StringUtils.abbreviate(text, 30); DayHolder day = new DayHolder(datum); return StringUtils.leftPad(NumberHelper.getAsString(satzNr), 4) + " " + StringUtils.leftPad(day.isoFormat(), 10) + StringUtils.leftPad(NumberHelper.getAsString(betrag, NumberHelper.getCurrencyFormat(Locale.GERMAN)), 12) + " " + kost1 != null ? StringUtils.leftPad(kost1.toString(), 12) : "- " + " " + kost2 != null ? StringUtils.leftPad(kost2 .toString(), 12) : "- " + " " + StringUtils.rightPad(txt, 30); }
Example 9
Source Project: objectlabkit File: TextRenderer.java License: Apache License 2.0 | 5 votes |
private String formatColumn(ReportColumn c, String value) { if (IntegerUtil.assign(c.getSize(), 0) > 3) { if (c.isTruncate()) { return StringUtils.leftPad(truncate(c.getSize(), value), c.getSize()); } return StringUtils.abbreviate(StringUtils.leftPad(value, c.getSize()), c.getSize()); } return StringUtils.leftPad(truncate(c.getSize(), value), c.getSize()); }
Example 10
Source Project: usergrid File: IterationsChartLayout.java License: Apache License 2.0 | 5 votes |
private String firstMessages(JSONArray arr) { String s = ""; int len = Math.min(5, arr.length()); for (int i = 0; i < len; i++) { JSONObject json = JsonUtil.get(arr, i); s += "* " + StringUtils.abbreviate( json.optString( "message" ), 200 ) + "\n" + StringUtils.abbreviate(json.optString("trace"), 500) + "\n\n"; } return s; }
Example 11
Source Project: idea-php-symfony2-plugin File: PhpCommandGotoCompletionRegistrar.java License: MIT License | 5 votes |
@NotNull @Override public Collection<LookupElement> getLookupElements() { Collection<LookupElement> elements = new ArrayList<>(); Map<String, CommandArg> targets = getCommandConfigurationMap(phpClass, addMethod); for(CommandArg key: targets.values()) { LookupElementBuilder lookup = LookupElementBuilder.create(key.getName()).withIcon(Symfony2Icons.SYMFONY); String description = key.getDescription(); if(description != null) { if(description.length() > 25) { description = StringUtils.abbreviate(description, 25); } lookup = lookup.withTypeText(description, true); } if(key.getDefaultValue() != null) { lookup = lookup.withTailText("(" + key.getDefaultValue() + ")", true); } elements.add(lookup); } return elements; }
Example 12
Source Project: idea-php-symfony2-plugin File: TwigLineMarkerProvider.java License: MIT License | 5 votes |
@Override public String getElementText(PsiElement psiElement) { return StringUtils.abbreviate( SymbolPresentationUtil.getSymbolPresentableText(psiElement), 50 ); }
Example 13
Source Project: usergrid File: OverviewChartLayout.java License: Apache License 2.0 | 5 votes |
@Override protected void pointClicked( JSONObject json ) throws JSONException { super.pointClicked( json ); String caption = "Commit: " + StringUtils.abbreviate( json.getString( "commitId" ), 10 ); nextChartButton.setCaption( caption ); nextChartButton.setVisible( true ); }
Example 14
Source Project: projectforge-webapp File: MyEvent.java License: GNU General Public License v3.0 | 5 votes |
/** * * @param title * @param labelValues {{"text without label"}{"value", "label"}, ...} * @return */ public MyEvent setTooltip(final String title, final String[][] labelValues) { this.tooltipTitle = title; final StringBuffer buf = new StringBuffer(); boolean first = true; for (final String[] lv : labelValues) { if (lv == null || lv.length < 1 || lv.length > 2) { if (WebConfiguration.isDevelopmentMode() == true) { throw new IllegalArgumentException("labelValues must be string arrays of length 1 or 2!"); } continue; } String value = lv[0]; if (StringUtils.isBlank(value) == true) { continue; } value = StringUtils.abbreviate(value, 80); final String label = lv.length == 2 ? lv[1] : null; if (first == true) { first = false; } else { buf.append("\n"); } if (label != null) { buf.append(label).append(": ").append(value); } else { buf.append(value); } } if (first == false) { buf.append("\n"); } buf.append(PFUserContext.getLocalizedString("timesheet.duration")).append(": ").append(getDuration()); this.tooltipContent = HtmlHelper.escapeHtml(buf.toString(), true); return this; }
Example 15
Source Project: document-management-software File: Generic.java License: GNU Lesser General Public License v3.0 | 4 votes |
public String getDisplayString1() { return StringUtils.abbreviate(getString1(), 65); }
Example 16
Source Project: axelor-open-suite File: InventoryService.java License: GNU Affero General Public License v3.0 | 4 votes |
public String computeTitle(Inventory entity) { return entity.getStockLocation().getName() + (!Strings.isNullOrEmpty(entity.getDescription()) ? "-" + StringUtils.abbreviate(entity.getDescription(), 10) : ""); }
Example 17
Source Project: hiped2 File: PaddedTable.java License: Apache License 2.0 | 4 votes |
public String abbreviate(String s) { return StringUtils.abbreviate(s, maxColLength); }
Example 18
Source Project: DotCi File: IssueCommentPayload.java License: MIT License | 4 votes |
public String getDescription() { return StringUtils.abbreviate(this.comment.getBody(), 40); }
Example 19
Source Project: projectforge-webapp File: HRPlanningEntryDO.java License: GNU General Public License v3.0 | 4 votes |
@Transient public String getShortDescription() { return StringUtils.abbreviate(getDescription(), 50); }
Example 20
Source Project: idea-php-symfony2-plugin File: TwigLineMarkerProvider.java License: MIT License | 4 votes |
@Override public String getElementText(PsiElement psiElement) { String symbolPresentableText = SymbolPresentationUtil.getSymbolPresentableText(psiElement); return StringUtils.abbreviate(symbolPresentableText, 50); }