Example usage for org.apache.commons.lang3 StringUtils isNotEmpty

List of usage examples for org.apache.commons.lang3 StringUtils isNotEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isNotEmpty.

Prototype

public static boolean isNotEmpty(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is not empty ("") and not null.

 StringUtils.isNotEmpty(null)      = false StringUtils.isNotEmpty("")        = false StringUtils.isNotEmpty(" ")       = true StringUtils.isNotEmpty("bob")     = true StringUtils.isNotEmpty("  bob  ") = true 

Usage

From source file:com.nridge.core.base.std.Platform.java

/**
 * Determines if the current platform that the JVM is executing within is
 * a Windows-based operating system./*from  www.  j ava2  s  .  c o m*/
 * @return <i>true</i> if it is or <i>false</i> otherwise.
 */
public static boolean isWindows() {
    String osName;
    Properties osProperties;

    osProperties = System.getProperties();
    osName = (String) osProperties.get("os.name");
    return StringUtils.isNotEmpty(osName) && osName.startsWith(PLATFORM_WINDOWS);
}

From source file:com.nridge.core.io.log.DataFieldLogger.java

public void writeNV(String aName, String aValue) {
    if (StringUtils.isNotEmpty(aValue))
        mLogger.debug(aName + ": " + aValue);
}

From source file:architecture.ee.web.util.ServletUtils.java

public static String getDomainName(String url, boolean opt) {

    if (StringUtils.isNotEmpty(url)) {
        try {//from w w  w  .  j  ava  2 s  .co  m
            URI uri = new URI(url);
            String domain = uri.getHost();
            if (opt)
                return domain.startsWith("www.") ? domain.substring(4) : domain;
            return domain;
        } catch (URISyntaxException e) {
        }
    }
    return null;
}

From source file:com.hybris.mobile.app.commerce.utils.RegexUtils.java

/**
 * Try to identify and return a product code from the value and according to the different regex
 *
 * @param value/*from   ww w  .  j a  va 2s  .c  om*/
 * @return
 */
public static String getProductCode(String value) {
    String productCode = "";

    // Getting the hybris product code regex patterns
    String[] listRegexProducts = CommerceApplication.getContext().getResources()
            .getStringArray(R.array.regex_products);

    if (listRegexProducts != null) {

        boolean isProductMatching = false;
        int i = 0;

        // We continue while we have no match for the value
        while (!isProductMatching && i < listRegexProducts.length) {

            Pattern productPattern = Pattern.compile(listRegexProducts[i]);

            productCode = applyPattern(productPattern, value, 1).get(0);

            isProductMatching = StringUtils.isNotEmpty(productCode);

            i++;
        }

    }

    return productCode;

}

From source file:com.springstudy.utils.email.SimpleMailService.java

/**
 * ??./*from   w  w  w  .j a va 2 s  .  c  om*/
 */
public boolean sendNotificationMail(com.gmk.framework.common.utils.email.Email email) {
    SimpleMailMessage msg = new SimpleMailMessage();
    msg.setFrom(Global.getConfig("mailFrom"));
    msg.setTo(email.getAddress());
    if (StringUtils.isNotEmpty(email.getCc())) {
        String cc[] = email.getCc().split(";");
        msg.setCc(cc);//?
    }
    msg.setSubject(email.getSubject());

    // ????
    //      String content = String.format(textTemplate, userName, new Date());
    String content = email.getContent();
    msg.setText(content);
    try {
        mailSender.send(msg);
        if (logger.isInfoEnabled()) {
            logger.info("??{}", StringUtils.join(msg.getTo(), ","));
        }
        return true;
    } catch (Exception e) {
        logger.error(email.getAddressee() + "-" + email.getSubject() + "-" + "??", e);
    }
    return false;
}

From source file:com.green.modules.cms.service.SiteService.java

public Page<Site> find(Page<Site> page, Site site) {
    DetachedCriteria dc = siteDao.createDetachedCriteria();
    if (StringUtils.isNotEmpty(site.getName())) {
        dc.add(Restrictions.like("name", "%" + site.getName() + "%"));
    }// w  ww  . j  a  v a  2 s. c om
    dc.add(Restrictions.eq(Site.FIELD_DEL_FLAG, site.getDelFlag()));
    //dc.addOrder(Order.asc("id"));
    return siteDao.find(page, dc);
}

From source file:com.thoughtworks.go.util.command.ExecScript.java

/**
 * Ugly parsing of Exec output into some Elements. Gets called from StreamPumper.
 *
 * @param line the line of output to parse
 *//*  ww w . ja  v a2 s .  c o  m*/
public synchronized void consumeLine(final String line) {

    // check if the output contains the error string
    if (StringUtils.isNotEmpty(errorStr)) {
        // YES: set error flag
        if (StringUtils.equalsIgnoreCase(line.trim(), errorStr)) {
            foundError = true;
        }
    }
}

From source file:io.wcm.devops.conga.generator.util.EnvironmentExpander.java

private static Stream<Node> getSingleNodes(Node node, String environmentName) {
    List<Node> nodes = new ArrayList<>();

    boolean hasNode = StringUtils.isNotEmpty(node.getNode());
    boolean hasNodes = !node.getNodes().isEmpty();

    if (!hasNode && !hasNodes) {
        throw new GeneratorException(
                "Node without properties 'node' and 'nodes' found in '" + environmentName + "'.");
    } else if (hasNode && hasNodes) {
        throw new GeneratorException(
                "Node with both properties 'node' and 'nodes' found in '" + environmentName + "'.");
    } else if (hasNode) {
        nodes.add(node);/*from ww  w  .j  a v  a  2s .  c  o  m*/
    } else if (hasNodes) {
        for (String nodeName : node.getNodes()) {
            Node clonedNode = new Cloner().deepClone(node);
            clonedNode.setNode(nodeName);
            clonedNode.setNodes(ImmutableList.of());
            nodes.add(clonedNode);
        }
    }

    return nodes.stream();
}

From source file:com.thruzero.common.core.utils.StringUtilsExt.java

/**
 * Converts the given token stream of keyValuePairs, using the given separator, into a StringMap. Leading and trailing spaces of the keys and values are
 * trimmed.//from w ww  .ja  va  2 s  . c  om
 * <p>
 * Example input: "booleanTrue=true ,booleanFalse=false, integerOne=1,longOne=1234567890"
 */
public static StringMap tokensToMap(final String keyValuePairs, final String separator) {
    StringMap result = new StringMap();

    if (StringUtils.isNotEmpty(keyValuePairs)) {
        StringTokenizer st = new StringTokenizer(keyValuePairs, separator);

        while (st.hasMoreTokens()) {
            String token = st.nextToken();
            StringTokenizer st2 = new StringTokenizer(token, "=");

            result.put(StringUtils.trimToEmpty(st2.nextToken()),
                    st2.hasMoreTokens() ? StringUtils.trimToNull(st2.nextToken()) : null);
        }
    }

    return result;
}

From source file:de.dhbw.vetaraus.NeticaUtils.java

/**
 * Set the state of a single node to a given string value.
 *
 * @param node/*from  w  w w  .j  a  va  2s  . com*/
 *         The given node.
 * @param value
 *         The new node state.
 * @throws NeticaException
 */
public static void setNodeState(Node node, String value) throws NeticaException {
    if (StringUtils.isNotEmpty(value)) {
        node.finding().enterState(value);
    }
}