Example usage for org.apache.commons.lang StringUtils abbreviate

List of usage examples for org.apache.commons.lang StringUtils abbreviate

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils abbreviate.

Prototype

public static String abbreviate(String str, int maxWidth) 

Source Link

Document

Abbreviates a String using ellipses.

Usage

From source file:com.sammyun.plugin.paypal.PaypalPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);/*from  ww  w .j a v  a2s. co m*/
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("cmd", "_xclick");
    parameterMap.put("business", pluginConfig.getAttribute("partner"));
    parameterMap.put("item_name",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 100));
    parameterMap.put("amount", payment.getAmount().setScale(2).toString());
    parameterMap.put("currency_code", pluginConfig.getAttribute("currency"));
    parameterMap.put("return", getNotifyUrl(sn, NotifyMethod.sync));
    parameterMap.put("notify_url", getNotifyUrl(sn, NotifyMethod.async));
    parameterMap.put("invoice", sn);
    parameterMap.put("charset", "UTF-8");
    parameterMap.put("no_shipping", "1");
    parameterMap.put("no_note", "0");
    parameterMap.put("rm", "2");
    parameterMap.put("custom", "preschoolEdu");
    return parameterMap;
}

From source file:de.tudarmstadt.lt.n2n.preparsed.annotators.PreParsedLineParser.java

public void parse(JCas aJCas, boolean create_sentences, boolean create_tokens, boolean create_dependencies,
        boolean create_collapsed_dependencies, boolean create_constituents, boolean write_penntree)
        throws IllegalStateException {

    DocumentMetaData metadata = DocumentMetaData.get(aJCas);
    String cas_id = metadata.getDocumentId();
    String cas_text = aJCas.getDocumentText();
    LOG.trace("[{}] Splitting text into lines '{}'.", cas_id, StringUtils.abbreviate(cas_text, 50));
    if (cas_text.trim().isEmpty()) {
        LOG.trace("[{}] Text is empty.", cas_id);
        return;// www. java2s. com
    }

    List<Integer> line_idxs = new ArrayList<Integer>();
    line_idxs.add(0);
    for (int index = 0; (index = cas_text.indexOf('\n', index) + 1) > 0; line_idxs.add(index))
        ;
    LOG.debug("[{}] Found {} newline characters -> {} lines [{}]", cas_id, line_idxs.size(),
            line_idxs.size() + 1, StringUtils.abbreviate(cas_text, 50));
    if (line_idxs.get(line_idxs.size() - 1) < cas_text.length()) // if cas doesn't end with a new line
        line_idxs.add(cas_text.length());

    for (int i = 0; i < line_idxs.size() - 1; i++) {
        int bline_idx = line_idxs.get(i);
        int eline_idx = line_idxs.get(i + 1);
        parseLine(aJCas, create_sentences, create_tokens, create_dependencies, create_collapsed_dependencies,
                create_constituents, write_penntree, bline_idx, eline_idx);
    }
}

From source file:com.dp2345.plugin.paypal.PaypalPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);/*  w  ww  . j  a v  a 2  s .  c  o  m*/
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("cmd", "_xclick");
    parameterMap.put("business", pluginConfig.getAttribute("partner"));
    parameterMap.put("item_name",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 100));
    parameterMap.put("amount", payment.getAmount().setScale(2).toString());
    parameterMap.put("currency_code", pluginConfig.getAttribute("currency"));
    parameterMap.put("return", getNotifyUrl(sn, NotifyMethod.sync));
    parameterMap.put("notify_url", getNotifyUrl(sn, NotifyMethod.async));
    parameterMap.put("invoice", sn);
    parameterMap.put("charset", "UTF-8");
    parameterMap.put("no_shipping", "1");
    parameterMap.put("no_note", "0");
    parameterMap.put("rm", "2");
    parameterMap.put("custom", "dp2345");
    return parameterMap;
}

From source file:eu.uqasar.model.process.Process.java

/**
 *
 * @param maxLength/* w w  w  .j a  va2s  . c  om*/
 * @return the abbreviated name
 */
private String getAbbreviatedName(int maxLength) {
    return StringUtils.abbreviate(getName(), maxLength);
}

From source file:de.iteratec.iteraplan.businesslogic.service.SealServiceImpl.java

/** {@inheritDoc} */
public Seal createSeal(InformationSystemRelease isr, String comment) {
    Preconditions.checkNotNull(isr);//  w ww  .j a va2s  .c  om
    UserContext.getCurrentPerms().userHasFunctionalPermission(TypeOfFunctionalPermission.SEAL);

    Seal seal = new Seal();

    String loginName = UserContext.getCurrentUserContext().getLoginName();
    seal.setUser(loginName);
    seal.setDate(new Date());
    isr.addSeal(seal);
    seal.setComment(StringUtils.abbreviate(comment, 4000));

    isr.setSealState(SealState.VALID);

    getHibernateTemplate().save(seal);
    return seal;
}

From source file:de.tudarmstadt.lt.lm.service.PreTokenizedStringProvider.java

@Override
public List<String> splitSentences(String text, String language_code) throws Exception {
    LOG.trace(String.format("Splitting sentences from text: %s", StringUtils.abbreviate(text, 200)));
    List<String> sentences = new ArrayList<String>();

    text = de.tudarmstadt.lt.utilities.StringUtils.trim_and_replace_emptyspace(text, " ");

    for (LineIterator iter = new LineIterator(new StringReader(text)); iter.hasNext();) {
        String line = iter.nextLine();
        String sentence = de.tudarmstadt.lt.utilities.StringUtils.trim(line);
        if (sentence.isEmpty())
            continue;
        sentences.add(sentence);/*from   ww w . j  a v  a  2s  .  c  o  m*/
        LOG.trace(String.format("Current sentence: %s", StringUtils.abbreviate(sentence, 200)));
    }
    LOG.debug(String.format("Split text '%s' into '%d' sentences.", StringUtils.abbreviate(text, 200),
            sentences.size()));
    return sentences;
}

From source file:net.osxx.plugin.tenpayBank.TenpayBankPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);/*from   w  w  w.j av  a  2 s . c  o m*/
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("trade_mode", "1");
    parameterMap.put("partner", pluginConfig.getAttribute("partner"));
    parameterMap.put("input_charset", "utf-8");
    parameterMap.put("sign_type", "MD5");
    parameterMap.put("return_url", getNotifyUrl(sn, NotifyMethod.sync));
    parameterMap.put("notify_url", getNotifyUrl(sn, NotifyMethod.async));
    parameterMap.put("out_trade_no", sn);
    parameterMap.put("subject",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    parameterMap.put("body",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    String bank = request.getParameter(BANK_PARAMETER_NAME);
    parameterMap.put("bank_type", StringUtils.isNotEmpty(bank) ? bank : DEFAULT_BANK);
    parameterMap.put("seller_id", pluginConfig.getAttribute("partner"));
    parameterMap.put("total_fee", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("fee_type", "1");
    parameterMap.put("spbill_create_ip", request.getLocalAddr());
    parameterMap.put("attach", "osxx");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}

From source file:net.groupbuy.plugin.tenpayBank.TenpayBankPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);/*www  .  j  av  a  2s.  c  o m*/
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("trade_mode", "1");
    parameterMap.put("partner", pluginConfig.getAttribute("partner"));
    parameterMap.put("input_charset", "utf-8");
    parameterMap.put("sign_type", "MD5");
    parameterMap.put("return_url", getNotifyUrl(sn, NotifyMethod.sync));
    parameterMap.put("notify_url", getNotifyUrl(sn, NotifyMethod.async));
    parameterMap.put("out_trade_no", sn);
    parameterMap.put("subject",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    parameterMap.put("body",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    String bank = request.getParameter(BANK_PARAMETER_NAME);
    parameterMap.put("bank_type", StringUtils.isNotEmpty(bank) ? bank : DEFAULT_BANK);
    parameterMap.put("seller_id", pluginConfig.getAttribute("partner"));
    parameterMap.put("total_fee", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("fee_type", "1");
    parameterMap.put("spbill_create_ip", request.getLocalAddr());
    parameterMap.put("attach", "shopxx");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}

From source file:com.sammyun.plugin.tenpayBank.TenpayBankPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);//ww  w .j  a  v a  2s .  c  o m
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("trade_mode", "1");
    parameterMap.put("partner", pluginConfig.getAttribute("partner"));
    parameterMap.put("input_charset", "utf-8");
    parameterMap.put("sign_type", "MD5");
    parameterMap.put("return_url", getNotifyUrl(sn, NotifyMethod.sync));
    parameterMap.put("notify_url", getNotifyUrl(sn, NotifyMethod.async));
    parameterMap.put("out_trade_no", sn);
    parameterMap.put("subject",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    parameterMap.put("body",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    String bank = request.getParameter(BANK_PARAMETER_NAME);
    parameterMap.put("bank_type", StringUtils.isNotEmpty(bank) ? bank : DEFAULT_BANK);
    parameterMap.put("seller_id", pluginConfig.getAttribute("partner"));
    parameterMap.put("total_fee", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("fee_type", "1");
    parameterMap.put("spbill_create_ip", request.getLocalAddr());
    parameterMap.put("attach", "preschoolEdu");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}

From source file:com.dp2345.plugin.tenpayBank.TenpayBankPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);//from  ww  w  .j a va  2  s  .c o m
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("trade_mode", "1");
    parameterMap.put("partner", pluginConfig.getAttribute("partner"));
    parameterMap.put("input_charset", "utf-8");
    parameterMap.put("sign_type", "MD5");
    parameterMap.put("return_url", getNotifyUrl(sn, NotifyMethod.sync));
    parameterMap.put("notify_url", getNotifyUrl(sn, NotifyMethod.async));
    parameterMap.put("out_trade_no", sn);
    parameterMap.put("subject",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    parameterMap.put("body",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 30));
    String bank = request.getParameter(BANK_PARAMETER_NAME);
    parameterMap.put("bank_type", StringUtils.isNotEmpty(bank) ? bank : DEFAULT_BANK);
    parameterMap.put("seller_id", pluginConfig.getAttribute("partner"));
    parameterMap.put("total_fee", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("fee_type", "1");
    parameterMap.put("spbill_create_ip", request.getLocalAddr());
    parameterMap.put("attach", "dp2345");
    parameterMap.put("sign", generateSign(parameterMap));
    return parameterMap;
}