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

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

Introduction

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

Prototype

public static boolean isEmpty(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is empty ("") or null.

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

NOTE: This method changed in Lang version 2.0.

Usage

From source file:com.glaf.activiti.executionlistener.factory.ExecutionListenerBeanFactory.java

public static Object getBean(Object key) {
    if (ctx == null) {
        String configLocation = CustomProperties.getString("activiti.executionListeners.context");
        if (StringUtils.isEmpty(configLocation)) {
            configLocation = SystemProperties.getString("activiti.executionListeners.context");
        }/*  w  w w . jav a  2s . c o m*/
        if (StringUtils.isEmpty(configLocation)) {
            configLocation = DEFAULT_CONFIG;
        }
        ctx = new ClassPathXmlApplicationContext(configLocation);
    }
    return ctx.getBean((String) key);
}

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

public static Object getBean(Object key) {
    if (ctx == null) {
        String configLocation = CustomProperties.getString("jbpm.actions.context");
        if (StringUtils.isEmpty(configLocation)) {
            configLocation = SystemProperties.getString("jbpm.actions.context");
        }//from w ww  . j a v a2 s.  co m
        if (StringUtils.isEmpty(configLocation)) {
            configLocation = DEFAULT_CONFIG;
        }
        ctx = new ClassPathXmlApplicationContext(configLocation);
    }
    return ctx.getBean((String) key);
}

From source file:com.jkoolcloud.tnt4j.streams.sample.custom.SampleIntegration.java

/**
 * Configure streams and parsers, and run each stream in its own thread.
 *
 * @param cfgFileName//from w  w w.  ja  v  a  2 s .c o m
 *            configuration file name
 */
public static void loadConfigAndRun(String cfgFileName) {
    try {
        StreamsConfigLoader cfg = StringUtils.isEmpty(cfgFileName) ? new StreamsConfigLoader()
                : new StreamsConfigLoader(cfgFileName);
        Collection<TNTInputStream<?, ?>> streams = cfg.getStreams();
        if (streams == null || streams.isEmpty()) {
            throw new IllegalStateException("No Activity Streams found in configuration"); // NON-NLS
        }

        ThreadGroup streamThreads = new ThreadGroup("Streams"); // NON-NLS
        StreamThread ft;
        for (TNTInputStream<?, ?> stream : streams) {
            ft = new StreamThread(streamThreads, stream,
                    String.format("%s:%s", stream.getClass().getSimpleName(), stream.getName())); // NON-NLS
            ft.start();
        }
    } catch (Exception e) {
        LOGGER.log(OpLevel.ERROR, String.valueOf(e.getLocalizedMessage()), e);
    }
}

From source file:com.fiorano.openesb.utils.crypto.StringEncrypter.java

public static ICustomEncryptor getDefaultInstance(String customClass)
        throws StringEncrypter.EncryptionException {
    try {//w  ww  . j  a v  a  2  s . c o  m

        if (!StringUtils.isEmpty(customClass)) {
            return (ICustomEncryptor) Thread.currentThread().getContextClassLoader().loadClass(customClass)
                    .newInstance();
        } else {
            return getDefaultInstance();
        }
    } catch (ClassNotFoundException ex) {
        throw new StringEncrypter.EncryptionException(ex);
    } catch (InstantiationException e) {
        throw new StringEncrypter.EncryptionException(e);
    } catch (IllegalAccessException e) {
        throw new StringEncrypter.EncryptionException(e);
    }
}

From source file:com.google.mr4c.stats.MR4CStats.java

private static void initClient() {
    CategoryConfig catConf = MR4CConfig.getDefaultInstance().getCategory(Category.STATS);
    String type = catConf.getProperty(StatsConfig.PROP_CLIENT);
    if (StringUtils.isEmpty(type)) {
        s_client = new NoOpStatsClient();
    } else if (STATSD_NAME.equals(type)) {
        s_client = createStatsdClient(catConf);
    } else {//from   www  .  j  av a  2s  .c  o m
        throw new IllegalArgumentException(String.format("No stats client type named [%s]", type));
    }
}

From source file:com.ge.predix.controller.test.ConfigureEnvironment.java

private static void setPropertyIfNotExist(final String name, final String value) {
    if (StringUtils.isEmpty(System.getProperty(name))) {
        System.setProperty(name, value);
    }//from  w w  w .j  a  va  2s .c  o m
}

From source file:com.adobe.cq.wcm.core.components.testing.MockXFFactory.java

public static ExperienceFragmentSocialVariation getExperienceFragmentSocialVariation(Page page) {
    ExperienceFragmentSocialVariation socialVariation = mock(ExperienceFragmentSocialVariation.class);
    StringBuilder stringBuilder = new StringBuilder();
    String image = null;//from   ww w .  ja va  2 s  .  com
    for (Resource resource : page.getContentResource().getChild("root").getChildren()) {
        if (resource.isResourceType(IMAGE_RT) && StringUtils.isEmpty(image)) {
            image = resource.getValueMap().get("fileReference", String.class);
        }
        String text = resource.getValueMap().get("text", String.class);
        if (StringUtils.isNotEmpty(text)) {
            stringBuilder.append(text);
        }
    }
    when(socialVariation.getText()).thenReturn(stringBuilder.toString());
    when(socialVariation.getImagePath()).thenReturn(image);
    return socialVariation;
}

From source file:com.alibaba.dubboadmin.web.pulltool.DateFormatUtil.java

/**
 * According to the specified format, Get a DateFormat
 *
 * @param format//from www  . ja v  a 2s  .c o  m
 * @return
 */
public static DateFormat getDateFormat(String format) {
    Map<String, DateFormat> map = tl.get();

    if (map == null) {
        map = new HashMap<String, DateFormat>();
        tl.set(map);
    }

    if (StringUtils.isEmpty(format)) {
        format = DEFAULT_FORMAT;
    }

    DateFormat ret = map.get(format);

    if (ret == null) {
        ret = new SimpleDateFormat(format);
        map.put(format, ret);
    }

    return ret;
}

From source file:com.glaf.activiti.tasklistener.factory.TaskListenerBeanFactory.java

public static Object getBean(Object key) {
    if (ctx == null) {
        String configLocation = CustomProperties.getString("activiti.taskListeners.context");
        if (StringUtils.isEmpty(configLocation)) {
            configLocation = SystemProperties.getString("activiti.taskListeners.context");
        }/*w ww.  ja  va 2  s  .com*/
        if (StringUtils.isEmpty(configLocation)) {
            configLocation = DEFAULT_CONFIG;
        }
        ctx = new ClassPathXmlApplicationContext(configLocation);
    }
    return ctx.getBean((String) key);
}

From source file:io.wcm.sling.commons.resource.ResourceType.java

/**
 * Converts the resource type to an absolute path. If it does not start with "/" the resource is resolved
 * via search paths using resource resolver. If not matching resource is found it is returned unchanged.
 * @param resourceType Resource type/*from  w  w w . j a v  a 2s.co m*/
 * @return Absolute resource type
 */
public static String makeAbsolute(String resourceType, ResourceResolver resourceResolver) {
    if (StringUtils.isEmpty(resourceType) || StringUtils.startsWith(resourceType, "/")) {
        return resourceType;
    }

    // first try to resolve path via component manager - because on publish instance the original resource may not accessible
    ComponentManager componentManager = resourceResolver.adaptTo(ComponentManager.class);
    if (componentManager != null) {
        Component component = componentManager.getComponent(resourceType);
        if (component != null) {
            return component.getPath();
        } else {
            return resourceType;
        }
    }

    // otherwise use resource resolver directly
    Resource resource = resourceResolver.getResource(resourceType);
    if (resource != null) {
        return resource.getPath();
    } else {
        return resourceType;
    }
}