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

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

Introduction

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

Prototype

public static boolean isNotBlank(String str) 

Source Link

Document

Checks if a String is not empty (""), not null and not whitespace only.

Usage

From source file:com.bibisco.manager.TextEditorManager.java

public static CharacterWordCount getCharacterWordCount(String pStrText) {

    Integer lIntWordsCount = 0;/*www .  jav  a2  s  . c om*/

    mLog.debug("Start getCharacterWordCount(String): HTML: [", pStrText, "]");

    CharacterWordCount lCharacterWordCount = new CharacterWordCount();

    if (StringUtils.isNotBlank(pStrText)) {
        HtmlParsingResult lHtmlParsingResult = parseHtml(pStrText, false);
        lCharacterWordCount.setCharacters(lHtmlParsingResult.characterCount);
        lCharacterWordCount.setWords(lHtmlParsingResult.words.size());
    } else {
        lCharacterWordCount.setCharacters(0);
        lCharacterWordCount.setWords(0);
    }

    mLog.debug("End getCharacterWordCount(String): return " + lIntWordsCount);

    return lCharacterWordCount;
}

From source file:com.roncoo.pay.trade.utils.MerchantApiUtil.java

/**
 * ????/*from   w w w .  j a  va 2 s. c o m*/
 * @param paramMap  ???
 * @param paySecret ??
 * @return
 */
public static String getSign(Map<String, Object> paramMap, String paySecret) {
    SortedMap<String, Object> smap = new TreeMap<String, Object>(paramMap);
    StringBuffer stringBuffer = new StringBuffer();
    for (Map.Entry<String, Object> m : smap.entrySet()) {
        Object value = m.getValue();
        if (value != null && StringUtils.isNotBlank(String.valueOf(value))) {
            stringBuffer.append(m.getKey()).append("=").append(value).append("&");
        }
    }
    stringBuffer.delete(stringBuffer.length() - 1, stringBuffer.length());

    String argPreSign = stringBuffer.append("&paySecret=").append(paySecret).toString();
    String signStr = MD5Util.encode(argPreSign).toUpperCase();

    return signStr;
}

From source file:io.github.jeddict.db.accessor.MapKeyUtil.java

public static void load(MapKeyAccessor accessor, MapKeyHandler mapKeyHandler) {
    MapKeyType mapKeyType = mapKeyHandler.getValidatedMapKeyType();
    if (mapKeyType != null) {
        if (mapKeyType == MapKeyType.NEW) {
            if (StringUtils.isNotBlank(mapKeyHandler.getMapKeyAttributeType())) {
                AccessorUtil.setEnumerated(accessor, mapKeyHandler.getMapKeyEnumerated());
                AccessorUtil.setTemporal(accessor, mapKeyHandler.getMapKeyTemporal());
                accessor.setMapKeyClassName(mapKeyHandler.getMapKeyAttributeType());
                if (mapKeyHandler.getMapKeyColumn() != null) {
                    accessor.setMapKeyColumn(mapKeyHandler.getMapKeyColumn().getAccessor());
                }/*from   w  ww .j  ava2  s  . co m*/
            } else if (mapKeyHandler.getMapKeyEntity() != null) {
                accessor.setMapKeyClassName(mapKeyHandler.getMapKeyEntity().getClazz());
                accessor.setMapKeyJoinColumns(mapKeyHandler.getMapKeyJoinColumn().stream()
                        .map(JoinColumn::getAccessor).collect(toList()));
            } else if (mapKeyHandler.getMapKeyEmbeddable() != null) {
                accessor.setMapKeyClassName(mapKeyHandler.getMapKeyEmbeddable().getClazz());
                AttributeValidator.filterMapKey(mapKeyHandler);
                accessor.setMapKeyAttributeOverrides(mapKeyHandler.getMapKeyAttributeOverride().stream()
                        .map(AttributeOverrideSpecMetadata::getInstance).collect(toList()));
            }
        } else {
            //                MapKeyMetadata mapKeyMetadata = new MapKeyMetadata();
            //                mapKeyMetadata.setName(mapKeyHandler.getMapKeyAttribute().getName());
            //                accessor.setMapKey(mapKeyMetadata);
            accessor.setAttributeType(LIST_TYPE);//ignore @MapKey(<Key>) and set List type
        }
    }
}

From source file:com.junly.common.enums.HttpChannelType.java

public static String getDetailByCode(String code) {

    if (StringUtils.isNotBlank(code)) {
        for (HttpChannelType activitie : HttpChannelType.values()) {
            if (StringUtils.equals(code, activitie.getCode())) {
                return activitie.getDetail();
            }/* w ww  .ja v  a  2s .  c o  m*/
        }
    }
    return null;
}

From source file:com.mobileman.projecth.web.util.NumUtils.java

public static BigDecimal convert2decimal(String str) {
    try {//from ww  w . j a va 2s .  c  o  m
        if (StringUtils.isNotBlank(str)) {
            return new BigDecimal(str);
        }
    } catch (Exception ex) {
    }
    return null;
}

From source file:com.doculibre.constellio.wicket.utils.SimpleParamsUtils.java

public static String appendParams(String url, SimpleParams simpleParams) {
    StringBuffer sb = new StringBuffer(url);
    for (String paramName : simpleParams.keySet()) {
        for (String paramValue : simpleParams.getList(paramName)) {
            if (sb.indexOf("?") == -1 && StringUtils.isNotBlank(url)) {
                sb.append("?");
            } else if (sb.length() > 0) {
                sb.append("&");
            }/* w  w  w . j a v  a  2  s  . c o  m*/
            sb.append(paramName + "=" + paramValue);
        }
    }
    return sb.toString();
}

From source file:com.bstek.dorado.common.ClientType.java

public static int parseClientTypes(String clientTypes) {
    int clientTypesValue = 0;
    if (StringUtils.isNotBlank(clientTypes)) {
        String[] clientTypeArray = StringUtils.split(clientTypes.toLowerCase(), ",; ");
        if (ArrayUtils.indexOf(clientTypeArray, DESKTOP_NAME) >= 0) {
            clientTypesValue += ClientType.DESKTOP;
        }/*from   ww  w.  j  av a2  s  .co  m*/
        if (ArrayUtils.indexOf(clientTypeArray, TOUCH_NAME) >= 0) {
            clientTypesValue += ClientType.TOUCH;
        }
    }
    return clientTypesValue;
}

From source file:biz.netcentric.cq.tools.actool.helper.PurgeHelper.java

public static String purgeACLs(final Session session, final String path) throws Exception {

    StringBuilder message = new StringBuilder();
    if (StringUtils.isNotBlank(path)) {
        String queryString = "/jcr:root" + path.trim() + "//rep:policy";
        Query query = session.getWorkspace().getQueryManager().createQuery(queryString, Query.XPATH);
        QueryResult result = query.execute();
        NodeIterator nodeIterator = result.getNodes();

        AccessControlManager accessManager = session.getAccessControlManager();

        while (nodeIterator.hasNext()) {
            Node res = nodeIterator.nextNode().getParent();
            if (res != null) {
                AccessControlPolicy[] policies = accessManager.getPolicies(res.getPath());
                for (int j = 0; j < policies.length; j++) {
                    accessManager.removePolicy(res.getPath(), policies[j]);
                }/*from  ww w  .ja  v  a2s . c o m*/
                message.append("Removed all policies from node " + res.getPath() + ".\n");
            }
        }
        message.append("\n\nCompleted removing ACLs from path: " + path + " and it's subpaths!");
    }

    session.save();

    return message.toString();
}

From source file:com.sfs.whichdoctor.formatter.ExpenseClaimFormatter.java

private static String getQuantity(final ExpenseClaimBean expenseClaim) {

    final StringBuffer value = new StringBuffer();

    if (StringUtils.equals(expenseClaim.getExpenseClass(), "Travel")
            && StringUtils.equals(expenseClaim.getExpenseType(), "Petrol (Lump sum)")) {
        if (StringUtils.isNotBlank(expenseClaim.getCurrencyAbbreviation())
                && !StringUtils.equals(expenseClaim.getCurrencyAbbreviation(), DEFAULT_CURRENCY_ABBR)) {
            value.append(expenseClaim.getCurrencyAbbreviation());
        }/*  www.j a va  2 s . c o m*/
        value.append(Formatter.toCurrency(expenseClaim.getRate()));
    }
    if (StringUtils.equals(expenseClaim.getExpenseClass(), "Travel")
            && StringUtils.equals(expenseClaim.getExpenseType(), "Mileage Reimbursement")) {
        value.append(expenseClaim.getQuantity() + " kilometers @ ");
        value.append(Formatter.toCurrency(expenseClaim.getRate()));
        if (StringUtils.isNotBlank(expenseClaim.getCurrencyAbbreviation())
                && !StringUtils.equals(expenseClaim.getCurrencyAbbreviation(), DEFAULT_CURRENCY_ABBR)) {
            value.append(expenseClaim.getCurrencyAbbreviation());
        }
        value.append(" per kilometer");
    }
    if (value.length() == 0) {
        value.append(expenseClaim.getQuantity() + " @ ");
        if (StringUtils.isNotBlank(expenseClaim.getCurrencyAbbreviation())
                && !StringUtils.equals(expenseClaim.getCurrencyAbbreviation(), DEFAULT_CURRENCY_ABBR)) {
            value.append(expenseClaim.getCurrencyAbbreviation());
        }
        value.append(Formatter.toCurrency(expenseClaim.getRate()));
    }
    if (StringUtils.isNotBlank(expenseClaim.getDescription())) {
        if (value.length() > 0) {
            value.append(" - ");
        }
        value.append(expenseClaim.getDescription());
    }
    if (StringUtils.isNotBlank(expenseClaim.getCurrencyAbbreviation())
            && !StringUtils.equals(expenseClaim.getCurrencyAbbreviation(), DEFAULT_CURRENCY_ABBR)) {
        if (value.length() > MAX_QUANTITY) {
            value.append("<br/>");
        }
        value.append(" (Rate: " + expenseClaim.getCurrencyAbbreviation() + "$1 = " + DEFAULT_CURRENCY_ABBR + "$"
                + expenseClaim.getExchangeRate() + ")");
    }
    return value.toString();
}

From source file:de.hybris.platform.chinesetaxinvoiceaddon.forms.validation.TaxInvoiceValidator.java

protected static void validateInvoiceName(TaxInvoiceForm invoiceForm, final int maxFieldLength,
        final Errors errors) {

    if (StringUtils.isNotBlank(invoiceForm.getRecipientType())
            && invoiceForm.getRecipientType().equals(InvoiceRecipientType.UNIT.getCode())) {
        String recipient = invoiceForm.getRecipient();
        if (recipient == null || StringUtils.isEmpty(recipient)
                || (StringUtils.length(recipient) > maxFieldLength)) {
            errors.rejectValue(InvoiceField.RECIPIENT.getFieldKey(), InvoiceField.RECIPIENT.getErrorKey());
        }/*from  w w  w.  j  av  a 2s .c o  m*/
    }
}