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

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

Introduction

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

Prototype

public static boolean isBlank(String str) 

Source Link

Document

Checks if a String is whitespace, empty ("") or null.

Usage

From source file:com.jnj.b2b.storefront.forms.validation.B2BUpdatePwdFormValidator.java

@Override
public void validate(final Object obj, final Errors errors) {
    final UpdatePwdForm form = (UpdatePwdForm) obj;
    if (StringUtils.isBlank(form.getPwd())) {
        errors.rejectValue("pwd", "updatePwd.pwd.invalid");
    }/*  w  w w .ja  v  a  2 s  .co m*/
    if (!matchPattern(form.getCheckPwd())) {
        errors.rejectValue("checkPwd", "updatePwd.checkPwd.invalid");
    }
    isCheckEquals(form, errors);
}

From source file:com.mmj.app.common.CustomDispatcherServlet.java

@Override
protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception {

    String contentType = request.getHeader("Content-Type");

    if (!StringUtils.isBlank(contentType) && contentType.toLowerCase().startsWith("application/json")) {
        request = new FilterRequestWrapper(request);
    }//  w  ww . jav a2 s  .  com
    super.doService(request, response);
}

From source file:com.zxy.commons.codec.utils.Base64Utils.java

/**
 * ?/*from w w  w  .j av  a2  s .  c  o m*/
 * 
 * @param base64Str ?
 * @param charset 
 * @return ?
 */
public static String decode(String base64Str, String charset) {
    if (StringUtils.isBlank(base64Str)) {
        return null;
    }
    return new String(Base64.decodeBase64(base64Str.getBytes(Charset.forName(charset))));
}

From source file:com.ning.metrics.collector.endpoint.EventExtractorUtil.java

public Granularity granularityFromString(final String granularityString) {
    if (StringUtils.isBlank(granularityString)) {
        return Granularity.HOURLY;
    }/*w ww. j av  a  2 s.  c om*/

    return Granularity.valueOf(granularityString.toUpperCase(Locale.US));
}

From source file:edu.mayo.cts2.framework.plugin.service.bprdf.util.UriUtils.java

/**
 * Gets the namespace name tuple.//from w  ww . j  a v a2s. c o m
 * The first element in the array will be the name
 * The seconed element in the array wil be the namespace uri
 *
 * @param uri the uri
 * @return the namespace name tuple
 */
public static String[] getNamespaceNameTuple(String uri) {
    String name;
    String namespace;

    int splitPoint = Util.splitNamespace(uri);

    if (splitPoint == uri.length()) {
        name = StringUtils.substringAfterLast(uri, "/");
        namespace = StringUtils.substringBeforeLast(uri, "/") + "/";
    } else {
        namespace = uri.substring(0, splitPoint);
        name = uri.substring(splitPoint);
    }

    if (StringUtils.isBlank(name) || StringUtils.isBlank(namespace)) {
        throw new UriParseException(uri);
    } else {
        return new String[] { name, namespace };
    }
}

From source file:com.drunkendev.confluence.plugins.attachments.PurgeAttachmentsSettingsService.java

public PurgeAttachmentSettings getSettings(String spaceKey) {
    return StringUtils.isBlank(spaceKey) ? getSettings()
            : (PurgeAttachmentSettings) bandanaManager.getValue(new ConfluenceBandanaContext(spaceKey), KEY,
                    false);/*from w w  w .  java 2s .  c o  m*/
}

From source file:com.baidu.fsg.uid.utils.DockerUtils.java

/**
 * Retrieve host & port from environment
 *//*from www .  ja  v  a2  s.c  o  m*/
private static void retrieveFromEnv() {
    // retrieve host & port from environment
    DOCKER_HOST = System.getenv(ENV_KEY_HOST);
    DOCKER_PORT = System.getenv(ENV_KEY_PORT);

    // not found from 'JPAAS_HTTP_PORT', then try to find from 'JPAAS_HOST_PORT_8080'
    if (StringUtils.isBlank(DOCKER_PORT)) {
        DOCKER_PORT = System.getenv(ENV_KEY_PORT_ORIGINAL);
    }

    boolean hasEnvHost = StringUtils.isNotBlank(DOCKER_HOST);
    boolean hasEnvPort = StringUtils.isNotBlank(DOCKER_PORT);

    // docker can find both host & port from environment
    if (hasEnvHost && hasEnvPort) {
        IS_DOCKER = true;

        // found nothing means not a docker, maybe an actual machine
    } else if (!hasEnvHost && !hasEnvPort) {
        IS_DOCKER = false;

    } else {
        LOGGER.error("Missing host or port from env for Docker. host:{}, port:{}", DOCKER_HOST, DOCKER_PORT);
        throw new RuntimeException(
                "Missing host or port from env for Docker. host:" + DOCKER_HOST + ", port:" + DOCKER_PORT);
    }
}

From source file:com.flexive.faces.converter.EnumConverter.java

@SuppressWarnings({ "unchecked" })
public static Enum getValue(String value) {
    if (StringUtils.isBlank(value) || "-1".equals(value)) {
        return null;
    }//from   w ww  .  jav a2 s  . c  om
    String[] values = value.split("::");
    if (values.length != 2) {
        throw new IllegalArgumentException("Invalid argument for enum converter: " + value);
    }
    try {
        return Enum.valueOf((Class<? extends Enum>) Class.forName(values[0]), values[1]);
    } catch (ClassNotFoundException e) {
        throw new IllegalArgumentException(e);
    }
}

From source file:io.renren.common.utils.DateUtils.java

/**
 * ??//from  www .  j  a  v a  2 s.c  o m
 * @param strDate 
 * @param pattern ?DateUtils.DATE_TIME_PATTERN
 */
public static Date stringToDate(String strDate, String pattern) {
    if (StringUtils.isBlank(strDate)) {
        return null;
    }

    DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern);
    return fmt.parseLocalDateTime(strDate).toDate();
}

From source file:net.firejack.platform.core.validation.constraint.RuleMapper.java

/**
 * @param id//w ww.j  a va  2  s  . com
 * @return
 */
public static ConstraintsSourceClass getConstrainedType(String id) {
    ConstraintsSourceClass sourceClass = null;
    if (StringUtils.isBlank(id)) {
        return sourceClass;
    }
    String[] values = id.split("\\?");
    if (values.length == 1) {
        sourceClass = new ConstraintsSourceClass(CONSTRAINT_LOCATIONS.get(id));
    } else {
        sourceClass = new ConstraintsSourceClass(CONSTRAINT_LOCATIONS.get(values[0]));
        Map<String, String> params = new HashMap<String, String>();
        String[] parameters = values[1].split("\\|");
        for (String parameter : parameters) {
            String[] p = parameter.split("=");
            if (p.length == 2) {
                params.put(p[0], p[1]);
            } else {
                params.put(p[0], null);
            }
        }
        sourceClass.setParams(params);
    }
    return sourceClass;
}