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.opensymphony.xwork2.config.ConfigurationUtil.java

/**
 * Splits the string into a list using a comma as the token separator.
 * @param parent The comma separated string.
 * @return A list of tokens from the specified string.
 *//* w  w w  .j av  a  2  s .c  o  m*/
public static List<String> buildParentListFromString(String parent) {
    if (StringUtils.isEmpty(parent)) {
        return Collections.emptyList();
    }

    StringTokenizer tokenizer = new StringTokenizer(parent, ",");
    List<String> parents = new ArrayList<>();

    while (tokenizer.hasMoreTokens()) {
        String parentName = tokenizer.nextToken().trim();

        if (StringUtils.isNotEmpty(parentName)) {
            parents.add(parentName);
        }
    }

    return parents;
}

From source file:com.googlecode.jsendnsca.MessagePayloadTest.java

@Test
public void shouldConstructValidObjectWhenUsingNoArgConstructor() throws Exception {
    final MessagePayload messagePayload = new MessagePayload();

    assertTrue(StringUtils.isNotEmpty(messagePayload.getHostname()));
    assertEquals(Level.UNKNOWN, messagePayload.getLevel());
    assertEquals("UNDEFINED", messagePayload.getServiceName());
    assertEquals(StringUtils.EMPTY, messagePayload.getMessage());
}

From source file:com.inkubator.hrm.web.recruitment.RecruitmenSelectionSeriesFormController.java

@PostConstruct
@Override//from  w  w w.  j ava2s  .  c  o m
public void initialization() {
    super.initialization();
    try {
        String recruitSelectionSeriesId = FacesUtil.getRequestParameter("recruitSelectionSeriesId");
        model = new RecruitmenSelectionSeriesModel();
        isUpdate = Boolean.FALSE;
        if (StringUtils.isNotEmpty(recruitSelectionSeriesId)) {
            RecruitmenSelectionSeries recruitmenSelectionSeries = recruitAdvertisementCategoryService
                    .getEntiyByPK(Long.parseLong(recruitSelectionSeriesId));
            if (recruitmenSelectionSeries != null) {
                model = getModelFromEntity(recruitmenSelectionSeries);
                isUpdate = Boolean.TRUE;
            }
        }

    } catch (Exception e) {
        LOGGER.error("Error", e);
    }
}

From source file:com.mingo.mongo.aggregation.AggregationUtils.java

/**
 * Add field to builder with $ prefix./*ww  w. ja  va 2 s  .co m*/
 *
 * @param builder {@link BasicDBObjectBuilder}
 * @param field   field
 */
public static void appendFieldWithSimplePrefix(BasicDBObjectBuilder builder, String field) {
    if (StringUtils.isNotEmpty(field)) {
        builder.add(field, SIMPLE_PREFIX + field);
    }
}

From source file:io.mandrel.requests.proxy.AuthenticatorUtils.java

public static String computeDigestAuthentication(Realm realm) {

    StringBuilder builder = new StringBuilder().append("Digest ");
    append(builder, "username", realm.getPrincipal(), true);
    append(builder, "realm", realm.getRealmName(), true);
    append(builder, "nonce", realm.getNonce(), true);
    append(builder, "uri", computeRealmURI(realm), true);
    if (StringUtils.isNotEmpty(realm.getAlgorithm()))
        append(builder, "algorithm", realm.getAlgorithm(), false);

    append(builder, "response", realm.getResponse(), true);

    if (realm.getOpaque() != null)
        append(builder, "opaque", realm.getOpaque(), true);

    if (realm.getQop() != null) {
        append(builder, "qop", realm.getQop(), false);
        // nc and cnonce only sent if server sent qop
        append(builder, "nc", realm.getNc(), false);
        append(builder, "cnonce", realm.getCnonce(), true);
    }//from w w  w  .j av a 2  s.c  om
    builder.setLength(builder.length() - 2); // remove tailing ", "

    // FIXME isn't there a more efficient way?
    return new String(ISO_8859_1.encode(CharBuffer.wrap(builder)).toString());
}

From source file:io.wcm.handler.link.markup.SimpleLinkMarkupBuilder.java

@Override
public Anchor build(Link link) {
    ValueMap props = link.getLinkRequest().getResourceProperties();

    // build anchor
    Anchor anchor = new Anchor(link.getUrl());

    // window target
    String target = props.get(LinkNameConstants.PN_LINK_WINDOW_TARGET, String.class);
    if (StringUtils.isNotEmpty(target) && !"_self".equals(target)) {
        anchor.setTarget(target);//  w  ww.  j  a  v a2s  .  c o  m
    }

    // all other link reference properties like popup windows settings, user tracking
    // have to be handled by project-specific implementations of LinkMarkupBuilder

    return anchor;
}

From source file:de.micromata.genome.gwiki.plugin.wikilink_1_0.GWikiWikiLinkConfig.java

public GWikiWikiLinkConfig(GWikiContext wikiContext) {
    this.wikiContext = wikiContext;
    GWikiElement el = wikiContext.getWikiWeb().findElement("admin/config/WikiLinkConfig");
    if (el == null) {
        return;//  w  w  w.j  a v  a  2  s  .co m
    }
    Object co = el.getMainPart().getCompiledObject();
    if ((co instanceof GWikiProps) == false) {
        return;
    }
    GWikiProps pco = (GWikiProps) co;

    enabled = pco.getBooleanValue("WIKILINK_DISABLE", false) == false;
    String m = pco.getStringValue("WIKILINK_PAGEIDMATCHER", "+*,-admin/*,-edit/*");
    if (StringUtils.isNotEmpty(m) == true) {
        matcher = new BooleanListRulesFactory<String>().createMatcher(m);
    }

}

From source file:com.quatico.base.aem.test.model.Properties.java

public Properties append(String name, Object value) {
    if (StringUtils.isNotEmpty(name) && value != null) {
        this.data.add(name);
        this.data.add(value);
    }/* www  .  j a v a  2 s . c om*/
    return this;
}

From source file:com.glaf.jbpm.factory.JbpmActionHandlerTypes.java

static Map<String, Class<?>> initializeHandlerTypes() {
    Map<String, Class<?>> types = new java.util.HashMap<String, Class<?>>();
    String resource = SystemProperties.getString("jbpm.actions");
    if (StringUtils.isEmpty(resource)) {
        resource = DEFAULT_CONFIG;//from w w w  .  ja v  a  2 s .  com
    }
    if (StringUtils.isNotEmpty(resource)) {
        InputStream actionTypesStream = PropertiesUtils.getInputStream(resource);
        Element actionHandlesElement = XmlUtils.parseXmlInputStream(actionTypesStream).getDocumentElement();
        Iterator<?> nodeTypeIterator = XmlUtils.elementIterator(actionHandlesElement, "action-handler");
        while (nodeTypeIterator.hasNext()) {
            Element nodeTypeElement = (Element) nodeTypeIterator.next();
            String elementTag = nodeTypeElement.getAttribute("element");
            String className = nodeTypeElement.getAttribute("class");
            try {
                Class<?> clazz = com.glaf.core.util.ClassUtils.loadClass(className);
                types.put(elementTag, clazz);
            } catch (Exception ex) {
                if (LogUtils.isDebug()) {
                    ex.printStackTrace();
                }
                logger.error("node '" + elementTag + "' will not be available. class '" + className
                        + "' couldn't be loaded");
            }
        }
    }

    String ext_resource = CustomProperties.getString("jbpm.actions");
    if (StringUtils.isNotEmpty(ext_resource)) {
        InputStream actionTypesStream = PropertiesUtils.getInputStream(resource);
        Element actionHandlesElement = XmlUtils.parseXmlInputStream(actionTypesStream).getDocumentElement();
        Iterator<?> nodeTypeIterator = XmlUtils.elementIterator(actionHandlesElement, "action-handler");
        while (nodeTypeIterator.hasNext()) {
            Element nodeTypeElement = (Element) nodeTypeIterator.next();
            String elementTag = nodeTypeElement.getAttribute("element");
            String className = nodeTypeElement.getAttribute("class");
            try {
                Class<?> clazz = com.glaf.core.util.ClassUtils.loadClass(className);
                types.put(elementTag, clazz);
            } catch (Exception ex) {
                if (LogUtils.isDebug()) {
                    ex.printStackTrace();
                }
                logger.error("node '" + elementTag + "' will not be available. class '" + className
                        + "' couldn't be loaded");
            }
        }
    }

    return types;
}

From source file:com.glaf.core.context.ContextFactory.java

public static void reload() {
    logger.info("?......");
    if (ctx == null) {
        try {/*  w w w. j a v  a 2  s. c o m*/
            if (StringUtils.isNotEmpty(conf.get("spring-config"))) {
                String filename = SystemProperties.getConfigRootPath() + conf.get("spring-config");
                logger.info("load custom spring config:" + filename);
                if (filename.startsWith("/")) {
                    filename = "/" + filename;// For linux
                }
                ctx = new FileSystemXmlApplicationContext(filename);
            } else if (StringUtils.isNotEmpty(conf.get("spring-config-file"))) {
                String filename = conf.get("spring-config-file");
                logger.info("load custom spring config:" + filename);
                if (filename.startsWith("/")) {
                    filename = "/" + filename;// For linux
                }
                ctx = new FileSystemXmlApplicationContext(filename);
            } else if (StringUtils.isNotEmpty(System.getProperty("spring-config-file"))) {
                String filename = System.getProperty("spring-config-file");
                logger.info("load custom spring config:" + filename);
                if (filename.startsWith("/")) {
                    filename = "/" + filename;// For linux
                }
                ctx = new FileSystemXmlApplicationContext(filename);
            } else {
                String filename = SystemProperties.getConfigRootPath() + Constants.SPRING_APPLICATION_CONTEXT;
                logger.info("load default spring config:" + filename);
                ctx = new FileSystemXmlApplicationContext(filename);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            logger.error(ex);
        }
    }
}