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.jjw.cloudymvc.web.mvc.Version.java

/**
 * Returns the enumeration for the given API version name
 *
 * @param versionName The name of the API version
 * @return The enumeration for this API version name or null if none exists
 *//*from   w  w w  .ja  v  a2  s  . c o m*/
public static Version fromVersionName(String versionName) {
    if (StringUtils.isEmpty(versionName)) {
        return null;
    }

    for (Version elementApiVersion : Version.values()) {
        if (StringUtils.equalsIgnoreCase(versionName, elementApiVersion.versionName)) {
            return elementApiVersion;
        }
    }

    return null;
}

From source file:io.apiman.manager.api.rest.impl.util.FieldValidator.java

/**
 * Validates an version./*from w  w w.  j ava 2  s.  c om*/
 * @param name
 * @throws InvalidNameException
 */
public static void validateVersion(String name) throws InvalidNameException {
    if (StringUtils.isEmpty(name)) {
        throw ExceptionFactory
                .invalidVersionException(Messages.i18n.format("FieldValidator.EmptyVersionError")); //$NON-NLS-1$
    }
}

From source file:com.arrow.acs.ManifestUtils.java

public static Manifest readManifest(Class<?> clazz) {
    String method = "readManifest";
    String jarFile = null;/*  w  w  w  .  j  a v  a 2 s  .c  om*/
    String path = clazz.getProtectionDomain().getCodeSource().getLocation().toString();
    for (String token : path.split("/")) {
        token = token.replace("!", "").toLowerCase().trim();
        if (token.endsWith(".jar")) {
            jarFile = token;
            break;
        }
    }
    LOGGER.logInfo(method, "className: %s, path: %s, jarFile: %s", clazz.getName(), path, jarFile);
    InputStream is = null;
    try {
        if (!StringUtils.isEmpty(jarFile)) {
            Enumeration<URL> enumeration = Thread.currentThread().getContextClassLoader()
                    .getResources(JarFile.MANIFEST_NAME);
            while (enumeration.hasMoreElements()) {
                URL url = enumeration.nextElement();
                for (String token : url.toString().split("/")) {
                    token = token.replace("!", "").toLowerCase();
                    if (token.equals(jarFile)) {
                        LOGGER.logInfo(method, "loading manifest from: %s", url.toString());
                        return new Manifest(is = url.openStream());
                    }
                }
            }
        } else {
            URL url = new URL(path + "/META-INF/MANIFEST.MF");
            LOGGER.logInfo(method, "loading manifest from: %s", url.toString());
            return new Manifest(is = url.openStream());
        }
    } catch (IOException e) {
    } finally {
        IOUtils.closeQuietly(is);
    }
    LOGGER.logError(method, "manifest file not found for: %s", clazz.getName());
    return null;
}

From source file:io.knotx.junit.util.KnotContextFactory.java

public static KnotContext empty(String template) {
    return new KnotContext()
            .setClientResponse(new ClientResponse()
                    .setBody(StringUtils.isEmpty(template) ? Buffer.buffer() : Buffer.buffer(template))
                    .setStatusCode(HttpResponseStatus.OK.code()).setHeaders(MultiMap.caseInsensitiveMultiMap()))
            .setClientRequest(new ClientRequest());
}

From source file:com.google.mr4c.content.RelativeContentFactory.java

public static File getWorkingDirectory() {
    String confWD = MR4CConfig.getDefaultInstance().getCategory(Category.CORE)
            .getProperty(CoreConfig.PROP_ROOT_DIR);
    return StringUtils.isEmpty(confWD) ? s_defaultWD : new File(confWD);
}

From source file:com.wellsandwhistles.android.redditsp.common.DialogUtils.java

public static void showSearchDialog(Context context, int titleRes, final OnSearchListener listener) {
    final AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context);
    final EditText editText = (EditText) LayoutInflater.from(context).inflate(R.layout.dialog_editbox, null);

    alertBuilder.setView(editText);/*from  w  w  w .  j av a 2 s. c om*/
    alertBuilder.setTitle(titleRes);

    alertBuilder.setPositiveButton(R.string.action_search, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final String query = General.asciiLowercase(editText.getText().toString()).trim();
            if (StringUtils.isEmpty(query)) {
                listener.onSearch(null);
            } else {
                listener.onSearch(query);
            }
        }
    });

    alertBuilder.setNegativeButton(R.string.dialog_cancel, null);

    final AlertDialog alertDialog = alertBuilder.create();
    alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    alertDialog.show();
}

From source file:de.shadowhunt.subversion.Resource.java

/**
 * Create a new {@link Resource} instance for the given value.
 *
 * @param path value of the {@link Resource}
 *
 * @return the new {@link Resource} instance with the given value
 *//*  w  ww.ja  va2 s.  co m*/
public static Resource create(final String path) {
    if (StringUtils.isEmpty(path) || SEPARATOR.equals(path)) {
        return ROOT;
    }

    final StringBuilder sb = new StringBuilder();
    for (final String segment : PATH_PATTERN.split(path)) {
        if (!StringUtils.isEmpty(segment)) {
            sb.append(SEPARATOR_CHAR);
            sb.append(segment);
        }
    }

    return new Resource(sb.toString());
}

From source file:com.thinkbiganalytics.util.PartitionKey.java

public static PartitionKey createFromString(String value) {
    if (StringUtils.isEmpty(value)) {
        return null;
    }/* w ww  .  j  a  v a  2s.  c om*/
    String[] values = value.split("\\|");
    if (values.length != 3) {
        throw new RuntimeException("Expecting format field|type|formula got " + value);
    }
    return new PartitionKey(values[0], values[1], values[2]);
}

From source file:cn.vlabs.clb.server.ui.frameservice.URLBuilder.java

public static String getImageURL(String storageKey) {
    if (StringUtils.isEmpty(storageKey))
        return null;
    return NGX_DOMAIN + "/" + IMAGE_CTX + "/" + storageKey + ".jpg";
}

From source file:com.ec2box.common.util.AppConfig.java

/**
 * gets the property from config//www  .  j  a  v a  2  s  . c om
 *
 * @param name property name
 * @param defaultValue default value if property is empty
 * @return configuration property
 */
public static String getProperty(String name, String defaultValue) {
    String value = prop.getString(name);
    if (StringUtils.isEmpty(value)) {
        value = defaultValue;
    }
    return value;
}