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

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

Introduction

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

Prototype

public static boolean isBlank(final CharSequence cs) 

Source Link

Document

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

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

Usage

From source file:com.thoughtworks.go.util.validators.JettyWorkDirValidator.java

public Validation validate(Validation val) {
    if (StringUtils.isBlank(systemEnvironment.getPropertyImpl("jetty.home"))) {
        systemEnvironment.setProperty("jetty.home", systemEnvironment.getPropertyImpl("user.dir"));
    }/*from ww  w .j  a  v a2 s . c  o m*/
    systemEnvironment.setProperty("jetty.base", systemEnvironment.getPropertyImpl("jetty.home"));

    File home = new File(systemEnvironment.getPropertyImpl("jetty.home"));
    File work = new File(systemEnvironment.getPropertyImpl("jetty.home"), "work");
    if (home.exists()) {
        if (work.exists()) {
            try {
                FileUtils.deleteDirectory(work);
            } catch (IOException e) {
                String message = format("Error trying to remove Jetty working directory {0}: {1}",
                        work.getAbsolutePath(), e);
                return val.addError(new RuntimeException(message));
            }
        }
        work.mkdir();
    }
    return Validation.SUCCESS;
}

From source file:com.netsteadfast.greenstep.action.utils.IdFieldCheckUtils.java

@Override
public boolean check(String value) throws ControllerException {
    if (StringUtils.isBlank(value)) {
        return false;
    }/*from w  w w .  j  av  a  2 s  .  c  om*/
    if (!SimpleUtils.checkBeTrueOf_azAZ09(value.replaceAll("-", "").replaceAll("_", ""))) {
        return false;
    }
    if (Constants.HTML_SELECT_NO_SELECT_ID.equals(value)) { // id? all
        return false;
    }
    return true;
}

From source file:gov.va.vinci.leo.tools.AsciiFilter.java

/**
 * @see gov.va.vinci.leo.tools.TextFilter#filter(java.lang.String)
 * @param text the text to filter.// w w w. j  a  va 2s.  co m
 * @return the text filtered.
 */
@Override
public String filter(String text) {
    if (StringUtils.isBlank(text)) {
        return text;
    } //if
    return AsciiService.toASCII8(text);
}

From source file:com.trenako.web.editors.ScalePropertyEditor.java

@Override
public void setAsText(String text) throws IllegalArgumentException {
    if (allowEmpty && StringUtils.isBlank(text)) {
        setValue(null);/*from   w w  w . j av a  2s .  c  o  m*/
        return;
    }

    if (!ObjectId.isValid(text)) {
        throw new IllegalArgumentException(text + " is not a valid ObjectId");
    }

    ObjectId id = new ObjectId(text);
    setValue(new Scale(id));
}

From source file:de.yaio.commons.net.IpAddressMatcher.java

/** 
 * creates an IpAddressMatcher/*www .  ja v a2  s .c  o m*/
 * @param ipList                 list of ip-addresses with/without netmask
 */
public IpAddressMatcher(List<String> ipList) {
    this.ipList = new ArrayList<SubnetUtils>();
    for (String ip : ipList) {
        if (StringUtils.isBlank(ip)) {
            continue;
        }
        SubnetUtils ipMatcher;
        if (ip.indexOf("/") > 0) {
            ipMatcher = new SubnetUtils(ip);
        } else {
            ipMatcher = new SubnetUtils(ip + "/32");
        }
        ipMatcher.setInclusiveHostCount(true);
        this.ipList.add(ipMatcher);
    }
}

From source file:com.hbc.api.trade.bdata.common.DownloadConfigService.java

/**
 * https ??//w w w  .  j  a v  a  2s. c  o  m
 * @param relativePath
 * @return
 */
public String getFullPath(String relativePath) {
    if (relativePath != null) {
        String downloadHost = ConfigLoader.getProp("host.download");
        if (StringUtils.isBlank(downloadHost)) {
            downloadHost = "";
            logger.info("?URL host");
        }
        String fullPath = downloadHost.concat("/").concat(relativePath);
        logger.info("?URL" + fullPath);
        return fullPath;
    }
    return null;
}

From source file:io.wcm.caravan.io.http.impl.CaravanHttpServiceConfigValidator.java

/**
 * Validates service configuration when reading the configuration.
 * @param serviceId Service ID//from w  w  w .  ja v  a 2  s .c o m
 * @param config OSGi config
 */
public static boolean isValidServiceConfig(String serviceId, Map<String, Object> config) {
    if (StringUtils.isBlank(serviceId)) {
        log.warn("Invalid transport layer service configuration without service ID, ignoring.", serviceId);
        return false;
    }
    String[] hosts = PropertiesUtil.toStringArray(config.get(RIBBON_HOSTS_PROPERTY));
    if (hosts == null || hosts.length == 0) {
        log.warn("Invalid transport layer service configuration for '{}' without hosts, ignoring.", serviceId);
        return false;
    }
    return true;
}

From source file:com.github.britter.beanvalidators.strings.AlphabeticConstraintValidator.java

@Override
public boolean isValid(final String value, final ConstraintValidatorContext context) {
    // Don't validate null, empty and blank strings, since these are validated by @NotNull, @NotEmpty and @NotBlank
    return StringUtils.isBlank(value) || allowSpaces ? StringUtils.isAlphaSpace(value)
            : StringUtils.isAlpha(value);
}

From source file:com.trenako.web.editors.RailwayPropertyEditor.java

@Override
public void setAsText(String text) throws IllegalArgumentException {
    if (allowEmpty && StringUtils.isBlank(text)) {
        setValue(null);//w  w w .  java2s .c o  m
        return;
    }

    if (!ObjectId.isValid(text)) {
        throw new IllegalArgumentException(text + " is not a valid ObjectId");
    }

    ObjectId id = new ObjectId(text);
    setValue(new Railway(id));
}

From source file:com.gtafe.tools.utils.MimeUtils.java

/**
 * Return the mime type for a given extension. Extensions can include the
 * dot or just be the extension without the dot. Extension mappings are
 * found in the mimeTypes.properties file in the org.extremecomponents.util
 * package./*from  w ww . j  ava 2s. c o  m*/
 */
public static String getExtensionMimeType(String extension) {
    String result = null;

    if (StringUtils.isBlank(extension)) {
        return result;
    }

    extension = extension.toLowerCase();

    if (!extension.startsWith(".")) {
        extension = "." + extension;
    }

    result = (String) properties.get(extension);

    return result;
}