org.apache.commons.lang3.StringUtils#abbreviate ( )源码实例Demo

下面列出了org.apache.commons.lang3.StringUtils#abbreviate ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: fess   文件: DocumentHelper.java
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
    }
}
 
源代码2 项目: jinjava   文件: MissingEndTagException.java
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;
}
 
源代码3 项目: blackduck-alert   文件: JiraMessageParser.java
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);
}
 
源代码4 项目: bisq   文件: GeneralSepaForm.java
@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));
        }
    }
}
 
@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);
}
 
源代码6 项目: cuba   文件: AbbreviatedColumnGenerator.java
@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;
    }
}
 
源代码7 项目: openemm   文件: RecipientUtils.java
/**
 *  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;
    }
}
 
源代码8 项目: FlyCms   文件: Stringcut.java
@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());
}
 
源代码9 项目: bisq   文件: AssetsForm.java
@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));
        }
    }
}
 
源代码10 项目: sndml3   文件: Log.java
public static String abbreviate(String message) {
	final int default_limit = 2048;
	return StringUtils.abbreviate(message, default_limit);
}
 
源代码11 项目: sakai   文件: EditManagersBean.java
public String getAbbreviatedSectionTitle() {
	return StringUtils.abbreviate(sectionTitle, 15);
}
 
源代码12 项目: flowable-engine   文件: AbstractJobEntityImpl.java
@Override
public void setExceptionMessage(String exceptionMessage) {
    this.exceptionMessage = StringUtils.abbreviate(exceptionMessage, JobInfo.MAX_EXCEPTION_MESSAGE_LENGTH);
}
 
源代码13 项目: sakai   文件: SignupEmailBase.java
protected String getAbbreviatedMeetingTitle(){
	return StringUtils.abbreviate(meeting.getTitle(), 30);
}
 
源代码14 项目: dependency-track   文件: Component.java
public void setFilename(String filename) {
    this.filename = StringUtils.abbreviate(filename, 255);
}
 
源代码15 项目: activiti6-boot2   文件: AbstractJobEntity.java
public void setExceptionMessage(String exceptionMessage) {
  this.exceptionMessage = StringUtils.abbreviate(exceptionMessage, MAX_EXCEPTION_MESSAGE_LENGTH);
}
 
源代码16 项目: alf.io   文件: PublicEventDescription.java
public String getShortDescription() {
    return StringUtils.abbreviate(getDescription(), 100);
}
 
源代码17 项目: sakai   文件: SignupEmailBase.java
protected String getAbbreviatedMeetingTitle(){
	return StringUtils.abbreviate(meeting.getTitle(), 30);
}
 
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);
}
 
源代码19 项目: sakai   文件: AutoSubmitAssessmentsJob.java
/**
 * 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);
}
 
源代码20 项目: mblog   文件: PreviewTextUtils.java
/**
 * 提取纯文本
 * @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;
}
 
 同类方法