Java Code Examples for org.apache.commons.lang3.StringUtils#abbreviate()
The following examples show how to use
org.apache.commons.lang3.StringUtils#abbreviate() .
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 File: DocumentHelper.java From fess with 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 File: GeneralSepaForm.java From bisq with 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 3
Source File: JiraMessageParser.java From blackduck-alert with 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 File: MissingEndTagException.java From jinjava with 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 5
Source File: Stringcut.java From FlyCms with 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 6
Source File: AssetsForm.java From bisq with 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 7
Source File: IrrigationZoneDurationFragment.java From arcusandroid with 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 8
Source File: RecipientUtils.java From openemm with 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 9
Source File: AbbreviatedColumnGenerator.java From cuba with 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 10
Source File: AbstractJobEntityImpl.java From flowable-engine with Apache License 2.0 | 4 votes |
@Override public void setExceptionMessage(String exceptionMessage) { this.exceptionMessage = StringUtils.abbreviate(exceptionMessage, JobInfo.MAX_EXCEPTION_MESSAGE_LENGTH); }
Example 11
Source File: SignupEmailBase.java From sakai with Educational Community License v2.0 | 4 votes |
protected String getAbbreviatedMeetingTitle(){ return StringUtils.abbreviate(meeting.getTitle(), 30); }
Example 12
Source File: EditManagersBean.java From sakai with Educational Community License v2.0 | 4 votes |
public String getAbbreviatedSectionTitle() { return StringUtils.abbreviate(sectionTitle, 15); }
Example 13
Source File: Component.java From dependency-track with Apache License 2.0 | 4 votes |
public void setFilename(String filename) { this.filename = StringUtils.abbreviate(filename, 255); }
Example 14
Source File: AbstractJobEntity.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void setExceptionMessage(String exceptionMessage) { this.exceptionMessage = StringUtils.abbreviate(exceptionMessage, MAX_EXCEPTION_MESSAGE_LENGTH); }
Example 15
Source File: Log.java From sndml3 with MIT License | 4 votes |
public static String abbreviate(String message) { final int default_limit = 2048; return StringUtils.abbreviate(message, default_limit); }
Example 16
Source File: PublicEventDescription.java From alf.io with GNU General Public License v3.0 | 4 votes |
public String getShortDescription() { return StringUtils.abbreviate(getDescription(), 100); }
Example 17
Source File: SignupEmailBase.java From sakai with Educational Community License v2.0 | 4 votes |
protected String getAbbreviatedMeetingTitle(){ return StringUtils.abbreviate(meeting.getTitle(), 30); }
Example 18
Source File: ProviderDataAccessorTestIT.java From blackduck-alert with 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 File: AutoSubmitAssessmentsJob.java From sakai with 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 File: PreviewTextUtils.java From mblog with 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; }