Java Code Examples for org.apache.commons.lang3.StringUtils#abbreviate()
The following examples show how to use
org.apache.commons.lang3.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: fess File: DocumentHelper.java License: Apache License 2.0 | 7 votes |
public String getDigest(final ResponseData responseData, final String content, final Map<String, Object> dataMap, final int maxWidth) { if (content == null) { return StringUtil.EMPTY; // empty } String subContent; if (content.length() < maxWidth * 2) { subContent = content; } else { subContent = content.substring(0, maxWidth * 2); } final int[] spaceChars = getSpaceChars(); try (final Reader reader = new StringReader(subContent)) { final String originalStr = TextUtil.normalizeText(reader).initialCapacity(content.length()).spaceChars(spaceChars).execute(); return StringUtils.abbreviate(originalStr, maxWidth); } catch (final IOException e) { return StringUtil.EMPTY; // empty } }
Example 2
Source Project: jinjava File: MissingEndTagException.java License: Apache License 2.0 | 6 votes |
public MissingEndTagException( String endTag, String startDefintion, int lineNumber, int startPosition ) { super( startDefintion, "Missing end tag: " + endTag + " for tag defined as: " + StringUtils.abbreviate(startDefintion, 255), lineNumber, startPosition ); this.endTag = endTag; this.startDefinition = startDefintion; }
Example 3
Source Project: blackduck-alert File: JiraMessageParser.java License: Apache License 2.0 | 6 votes |
private String createTitle(String provider, LinkableItem topic, LinkableItem subTopic, ComponentItem arbitraryItem) { StringBuilder title = new StringBuilder(); title.append("Alert - Provider: "); title.append(provider); title.append(createTitlePartStringPrefixedWithComma(topic)); if (null != subTopic) { title.append(createTitlePartStringPrefixedWithComma(subTopic)); } if (null != arbitraryItem) { title.append(createTitlePartStringPrefixedWithComma(arbitraryItem.getComponent())); arbitraryItem .getSubComponent() .ifPresent(linkableItem -> title.append(createTitlePartStringPrefixedWithComma(linkableItem))); if (arbitraryItem.collapseOnCategory()) { title.append(", "); title.append(arbitraryItem.getCategory()); } else { title.append(createTitlePartStringPrefixedWithComma(arbitraryItem.getCategoryItem())); } } return StringUtils.abbreviate(title.toString(), TITLE_SIZE_LIMIT); }
Example 4
Source Project: bisq File: GeneralSepaForm.java License: GNU Affero General Public License v3.0 | 6 votes |
@Override protected void autoFillNameTextField() { if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.isSelected()) { TradeCurrency singleTradeCurrency = this.paymentAccount.getSingleTradeCurrency(); String currency = singleTradeCurrency != null ? singleTradeCurrency.getCode() : null; if (currency != null) { String iban = ibanInputTextField.getText(); if (iban.length() > 9) iban = StringUtils.abbreviate(iban, 9); String method = Res.get(paymentAccount.getPaymentMethod().getId()); CountryBasedPaymentAccount countryBasedPaymentAccount = (CountryBasedPaymentAccount) this.paymentAccount; String country = countryBasedPaymentAccount.getCountry() != null ? countryBasedPaymentAccount.getCountry().code : null; if (country != null) accountNameTextField.setText(method.concat(" (").concat(currency).concat("/").concat(country) .concat("): ").concat(iban)); } } }
Example 5
Source Project: arcusandroid File: IrrigationZoneDurationFragment.java License: Apache License 2.0 | 5 votes |
@Override public void doContentSection() { String deviceAddress = getArguments().getString(MODEL_ADDR, ""); ModelSource<DeviceModel> m = DeviceModelProvider.instance().getModel(deviceAddress); m.addModelListener(Listeners.runOnUiThread(new Listener<ModelEvent>() { public void onEvent(ModelEvent e) { if (e instanceof ModelAddedEvent) { // model is loaded } } })); m.load(); if (m.get() != null) { deviceModel = m.get(); } capabilityUtils = new CapabilityUtils(deviceModel); getZoneNames(); stationPicker = (NumberPicker) contentView.findViewById(R.id.station_picker); stationPicker.setMinValue(1); stationPicker.setValue(1); stationPicker.setMaxValue(zoneNameArr.length); for(int i = 0; i < zoneNameArr.length; i++){ zoneNameArrTrunk[i]=StringUtils.abbreviate(zoneNameArr[i],20); } stationPicker.setDisplayedValues(zoneNameArrTrunk); updateTimeSelector(); zoneSelection = (Version1TextView) contentView.findViewById(R.id.zone_selected); durationSelection = (Version1TextView) contentView.findViewById(R.id.duration_selected); }
Example 6
Source Project: cuba File: AbbreviatedColumnGenerator.java License: Apache License 2.0 | 5 votes |
@Override public Object generateCell(com.vaadin.v7.ui.Table source, Object itemId, Object columnId) { Property property = source.getItem(itemId).getItemProperty(columnId); Object value = property.getValue(); if (value == null) { return null; } String stringValue = value.toString(); if (columnId instanceof MetaPropertyPath) { MetaProperty metaProperty = ((MetaPropertyPath) columnId).getMetaProperty(); if (DynamicAttributesUtils.isDynamicAttribute(metaProperty)) { stringValue = dynamicAttributesTools.getDynamicAttributeValueAsString(metaProperty, value); } } String cellValue = stringValue; boolean isMultiLineCell = StringUtils.contains(stringValue, "\n"); if (isMultiLineCell) { cellValue = StringUtils.replaceChars(cellValue, '\n', ' '); } int maxTextLength = column.getMaxTextLength(); if (stringValue.length() > maxTextLength + MAX_TEXT_LENGTH_GAP || isMultiLineCell) { return StringUtils.abbreviate(cellValue, maxTextLength); } else { return cellValue; } }
Example 7
Source Project: openemm File: RecipientUtils.java License: GNU Affero General Public License v3.0 | 5 votes |
/** * If string length is more than 500 characters cut it and add "..." in the end. * * @param string recipient type letter * @return cut string */ public static String cutRecipientDescription(String string){ try { return StringUtils.abbreviate(string, MAX_DESCRIPTION_LENGTH); } catch (IllegalArgumentException e) { logger.error("RecipientUtils.cutRecipientDescription: " + e, e); return string; } }
Example 8
Source Project: FlyCms File: Stringcut.java License: MIT License | 5 votes |
@SuppressWarnings("rawtypes") public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { DefaultObjectWrapperBuilder builder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_28); // 获取页面的参数 String content = params.get("content").toString(); Integer num = Integer.parseInt(params.get("num").toString()); content = Jsoup.clean(content, Whitelist.none()); content = StringUtils.abbreviate(content, num); env.setVariable("info_content", builder.build().wrap(content)); body.render(env.getOut()); }
Example 9
Source Project: bisq File: AssetsForm.java License: GNU Affero General Public License v3.0 | 5 votes |
@Override protected void autoFillNameTextField() { if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.isSelected()) { String currency = paymentAccount.getSingleTradeCurrency() != null ? paymentAccount.getSingleTradeCurrency().getCode() : ""; if (currency != null) { String address = addressInputTextField.getText(); address = StringUtils.abbreviate(address, 9); accountNameTextField.setText(currency.concat(": ").concat(address)); } } }
Example 10
Source Project: sndml3 File: Log.java License: MIT License | 4 votes |
public static String abbreviate(String message) { final int default_limit = 2048; return StringUtils.abbreviate(message, default_limit); }
Example 11
Source Project: sakai File: EditManagersBean.java License: Educational Community License v2.0 | 4 votes |
public String getAbbreviatedSectionTitle() { return StringUtils.abbreviate(sectionTitle, 15); }
Example 12
Source Project: flowable-engine File: AbstractJobEntityImpl.java License: Apache License 2.0 | 4 votes |
@Override public void setExceptionMessage(String exceptionMessage) { this.exceptionMessage = StringUtils.abbreviate(exceptionMessage, JobInfo.MAX_EXCEPTION_MESSAGE_LENGTH); }
Example 13
Source Project: sakai File: SignupEmailBase.java License: Educational Community License v2.0 | 4 votes |
protected String getAbbreviatedMeetingTitle(){ return StringUtils.abbreviate(meeting.getTitle(), 30); }
Example 14
Source Project: dependency-track File: Component.java License: Apache License 2.0 | 4 votes |
public void setFilename(String filename) { this.filename = StringUtils.abbreviate(filename, 255); }
Example 15
Source Project: activiti6-boot2 File: AbstractJobEntity.java License: Apache License 2.0 | 4 votes |
public void setExceptionMessage(String exceptionMessage) { this.exceptionMessage = StringUtils.abbreviate(exceptionMessage, MAX_EXCEPTION_MESSAGE_LENGTH); }
Example 16
Source Project: alf.io File: PublicEventDescription.java License: GNU General Public License v3.0 | 4 votes |
public String getShortDescription() { return StringUtils.abbreviate(getDescription(), 100); }
Example 17
Source Project: sakai File: SignupEmailBase.java License: Educational Community License v2.0 | 4 votes |
protected String getAbbreviatedMeetingTitle(){ return StringUtils.abbreviate(meeting.getTitle(), 30); }
Example 18
Source Project: blackduck-alert File: ProviderDataAccessorTestIT.java License: Apache License 2.0 | 4 votes |
private ProviderProjectEntity convertToProjectEntity(Long providerConfigId, ProviderProject providerProject) { String trimmedDescription = StringUtils.abbreviate(providerProject.getDescription(), DefaultProviderDataAccessor.MAX_DESCRIPTION_LENGTH); return new ProviderProjectEntity(providerProject.getName(), trimmedDescription, providerProject.getHref(), providerProject.getProjectOwnerEmail(), providerConfigId); }
Example 19
Source Project: sakai File: AutoSubmitAssessmentsJob.java License: Educational Community License v2.0 | 2 votes |
/** * Sometimes when logging to the sakai_events table it's possible to be logging * with a string you don't know the size of. (An exception message is a good * example) * * This method is supplied to keep the lengh of logged messages w/in the limits * of the sakai_event.ref column size. * * The sakai_event.ref column size is currently 256 * * @param target * @return */ static final public String safeEventLength(final String target) { return StringUtils.abbreviate(target, 255); }
Example 20
Source Project: mblog File: PreviewTextUtils.java License: GNU General Public License v3.0 | 2 votes |
/** * 提取纯文本 * @param html 代码 * @param length 提取文本长度 * @return string */ public static String getText(String html, int length){ String text = getText(html); text = StringUtils.abbreviate(text, length); return text; }