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.digitalpebble.stormcrawler.util.RefreshTag.java

public static String extractRefreshURL(DocumentFragment doc) {
    String value;//  ww w .  j a va 2s.  co m
    try {
        value = (String) expression.evaluate(doc, XPathConstants.STRING);
    } catch (XPathExpressionException e) {
        return null;
    }
    if (StringUtils.isBlank(value))
        return null;
    // 0;URL=http://www.apollocolors.com/site
    if (matcher.reset(value).matches()) {
        return matcher.group(1);
    }
    return null;
}

From source file:cms.service.account.HTMLGenerator.java

public final String generate(final String url) {
    // isBlank??0(whitespace) ? 
    if (StringUtils.isBlank(url))
        return null;

    //URL//from  ww w. ja va2 s  .c o  m
    Pattern pattern = Pattern.compile("(http://|https://){1}[\\w\\.\\-/:]+");
    Matcher matcher = pattern.matcher(url);
    if (!matcher.find())
        return null;

    //
    StringBuffer sb = new StringBuffer();

    try {
        //?XHMTL
        URL _url = new URL(url);
        URLConnection urlconnection = _url.openConnection();

        //System.out.println(urlconnection.getContentType());

        //?XHMTL
        BufferedReader in = new BufferedReader(new InputStreamReader(urlconnection.getInputStream(), "UTF-8"));

        String inputLine;//XHML,SB
        while ((inputLine = in.readLine()) != null) {
            sb.append(inputLine + "\n");
            //System.out.println(inputLine);
        }

    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return sb.toString();
}

From source file:de.hybris.platform.acceleratorservices.dataimport.batch.converter.PriceTranslator.java

@Override
public Object importValue(final String valueExpr, final Item toItem) throws JaloInvalidParameterException {
    clearStatus();/*from   w w w.  ja  v a 2 s.  c  o  m*/
    Double result = null;
    if (!StringUtils.isBlank(valueExpr)) {
        try {
            result = Double.valueOf(valueExpr);
        } catch (final NumberFormatException exc) {
            setError();
        }
        if (result != null && result.doubleValue() < 0.0) {
            setError();
        }
    }
    return result;
}

From source file:gov.nih.nci.protexpress.util.ManageProtAppInputOutputHelper.java

/**
 * Determines if an input name is empty.
 *
 * @param lst the list of inputs/outputs.
 * @return isValid value to determine if all inputs have names.
 *///from  w w w .j  av  a2s .c o m
public static boolean isNameEmpty(List<InputOutputObject> lst) {
    boolean isValid = true;
    for (InputOutputObject obj : lst) {
        if (isValid & StringUtils.isBlank(obj.getName())) {
            isValid = false;
        }
    }
    return isValid;
}

From source file:com.switchfly.inputvalidation.canonicalizer.StringCanonicalizer.java

@Override
public String execute(String content) {
    if (StringUtils.isBlank(content)) {
        return content;
    }//  w  w  w .  ja  v  a 2s  .  c  om
    try {
        return Normalizer.normalize(content, Normalizer.Form.NFC);
    } catch (Exception e) {
        throw new IllegalArgumentException("Canonicalization error", e);
    }
}

From source file:com.redhat.rhn.frontend.filter.StringMatcher.java

/**
 * {@inheritDoc}/*from   www. j  a  v a2  s.  c  o  m*/
 */
public boolean include(Object obj, String filterData, String filterColumn) {

    if (StringUtils.isBlank(filterData) || StringUtils.isBlank(filterColumn)) {
        return true; ///show all if I entered a blank value
    }
    String value = ((String) MethodUtil.callMethod(obj, StringUtil.beanify("get " + filterColumn),
            new Object[0]));
    if (!StringUtils.isBlank(value)) {
        return value.toUpperCase().indexOf(filterData.toUpperCase()) >= 0;
    }
    return false;
}

From source file:com.ewcms.publication.uri.RuleParse.java

/**
 * ?uri??//from  ww w.j  a v  a 2 s  .c om
 * 
 * @param patter
 *            uri
 * @return  key:?? value:?
 */
private static Map<String, String> parseVariables(String patter) {
    Map<String, String> variables = new HashMap<String, String>();
    if (!StringUtils.contains(patter, VARIABLE_START)) {
        return variables;
    }
    String[] tokens = StringUtils.splitByWholeSeparator(patter, VARIABLE_START);
    for (String token : tokens) {
        logger.debug("Token with ${{}", token);
        if (!StringUtils.contains(token, "}")) {
            logger.warn("\"{}\" is not closed", token);
            continue;
        }
        String value = StringUtils.split(token, VARIABLE_END)[0];
        if (StringUtils.isBlank(value)) {
            logger.warn("Variable's nam is null");
            continue;
        }
        logger.debug("variable is {}", value);
        String[] s = StringUtils.splitByWholeSeparator(value, VARIABLE_FORMAT);
        if (s.length == 1) {
            variables.put(s[0], null);
        } else {
            variables.put(s[0], s[1]);
        }
    }
    return variables;
}

From source file:com.baidu.rigel.biplatform.ma.file.serv.util.LocalFileOperationUtils.java

/**
 * /* w w w  .  j  av  a2  s .  c  o m*/
 * 
 * @param filePath
 *            ?
 */
public static boolean createFile(String filePath) {
    try {
        if (StringUtils.isBlank(filePath)) {
            return false;
        }
        File file = new File(filePath);
        // 
        if (filePath.endsWith("/")) {
            return false;
        }
        int pos = filePath.lastIndexOf("/");
        // ?????
        String dir = filePath.substring(0, pos);
        File dirFile = new File(dir);
        if (!dirFile.exists()) {
            dirFile.mkdirs();
        }
        return file.createNewFile();
    } catch (IOException e) {
        LOG.error(e.getMessage(), e);
        return false;
    }
}

From source file:cd.go.contrib.elasticagents.docker.executors.NonBlankField.java

@Override
public String doValidate(String input) {
    if (StringUtils.isBlank(input)) {
        return this.displayName + " must not be blank.";
    }/* ww  w . j a  v a  2  s. c om*/
    return null;
}

From source file:com.sap.prd.mobile.ios.mios.SCMUtil.java

public static String getConnectionString(final Properties versionInfo,
        final boolean hideConfidentialInformation) throws IOException {

    final String type = versionInfo.getProperty("type");

    final StringBuilder connectionString = new StringBuilder(128);

    if (type != null && type.equals("git")) {

        final String repo = versionInfo.getProperty("repo");

        if (StringUtils.isBlank(repo)) {
            if (!StringUtils.isBlank(versionInfo.getProperty("repo_1"))) {
                throw new IllegalStateException(
                        "Multipe git repositories provided. This use case is not supported. Provide only one git repository.");
            }/*from   w w  w . j  a  v a 2s.  com*/
            throw new IllegalStateException("No git repository provided. ");
        }

        if (hideConfidentialInformation) {
            try {
                URI uri = new URI(repo);
                int port = uri.getPort();
                if (port == -1) {
                    final String scheme = uri.getScheme();
                    if (scheme != null && gitDefaultPorts.containsKey(scheme)) {
                        port = gitDefaultPorts.get(scheme);
                    }
                }
                connectionString.append(port);

                if (uri.getHost() != null) {
                    connectionString.append(uri.getPath());
                }
            } catch (URISyntaxException e) {
                throw new IllegalStateException(String.format("Invalid repository uri: %s", repo));
            }
        } else {
            connectionString.append(PROTOCOL_PREFIX_GIT).append(repo);
        }

    } else {

        final String port = versionInfo.getProperty("port");

        if (StringUtils.isBlank(port))
            throw new IllegalStateException("No SCM port provided.");

        final String depotPath = versionInfo.getProperty("depotpath");

        if (hideConfidentialInformation) {
            try {
                URI perforceUri = new URI("perforce://" + port);

                int _port = perforceUri.getPort();
                if (_port == -1) {
                    _port = PERFORCE_DEFAULT_PORT;
                }
                connectionString.append(_port);
                connectionString.append(depotPath);
            } catch (URISyntaxException e) {
                throw new IllegalStateException(String.format("Invalid port: %s", port));
            }
        } else {

            if (StringUtils.isBlank(depotPath))
                throw new IllegalStateException("No depot path provided.");

            connectionString.append(PROTOCOL_PREFIX_PERFORCE).append(port).append(":")
                    .append(getDepotPath(depotPath));
        }
    }

    return connectionString.toString();
}