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

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

Introduction

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

Prototype

public static boolean isNotBlank(String str) 

Source Link

Document

Checks if a String is not empty (""), not null and not whitespace only.

Usage

From source file:com.dianping.phoenix.dev.core.tools.generator.stable.GitRepositoryListGenerator.java

private static List<ProjectRepositoryPair> parsePage(int pageNo) throws Exception {
    String page = curl(REPO_BASEURL + "/public/projects?page=" + pageNo);
    List<ProjectRepositoryPair> pairs = null;

    if (StringUtils.isNotBlank(page)) {
        String[] lines = StringUtils.split(page, "\n");
        for (String line : lines) {
            if (StringUtils.isNotBlank(line)) {
                int pos = line.indexOf(PATTERN_PRE);
                if (pos >= 0) {
                    pairs = pairs == null ? new ArrayList<ProjectRepositoryPair>() : pairs;
                    String repoUrl = line.substring(pos + PATTERN_PRE.length() - REPO_BASEURL.length(),
                            line.length() - PATTERN_SUF.length());
                    String projectName = repoUrl.substring(repoUrl.lastIndexOf("/") + 1,
                            repoUrl.length() - PATTERN_GIT.length());

                    if (hasPom(repoUrl)
                            || repoUrl.startsWith("http://code.dianpingoa.com/arch/phoenix-maven-config.git")) {
                        pairs.add(new ProjectRepositoryPair(projectName, repoUrl));
                    }//from w  ww .  j av a  2 s  .  c  o  m
                }
            }
        }
    }

    return pairs;
}

From source file:com.edm.utils.View.java

/**
 * cron.//from   ww  w .j  a  v a  2  s  . c  o m
 */
public String cron(String cron) {
    String cronStr = null;
    if (StringUtils.isNotBlank(cron)) {
        String[] crons = StringUtils.splitPreserveAllTokens(cron, " ");
        if (Asserts.empty(crons) || crons.length < 5) {
            return null;
        }

        String minute = crons[0];
        String hour = crons[1];
        String day = crons[2];
        String week = crons[3];
        String month = crons[4];

        // month
        if (!day.equals("*")) {
            cronStr = "?";
            if (day.equals("-1"))
                cronStr += "?";
            else
                cronStr += day + "";
        }
        // week
        if (!week.equals("*")) {
            cronStr = "?";
            if (week.equals("1,2,3,4,5"))
                cronStr += "";
            else if (week.equals("6,7"))
                cronStr += "?";
            else if (StringUtils.splitPreserveAllTokens(week, ",").length == 1)
                cronStr += "" + WeekMap.week(week);
        }
        // day
        if (month.equals("*") && week.equals("*") && day.equals("*")) {
            cronStr = "?";
        }

        if (StringUtils.isNotBlank(cronStr)) {
            if (hour.length() == 1)
                hour = "0" + hour;
            if (minute.length() == 1)
                minute = "0" + minute;
            cronStr += hour + ":" + minute;
        }
    }

    return cronStr;
}

From source file:dk.dma.msinm.user.security.Credentials.java

public boolean isValid() {
    return StringUtils.isNotBlank(email) && StringUtils.isNotBlank(password);
}

From source file:edu.wisc.my.stats.web.support.QueryFactEditor.java

/**
 * @see java.beans.PropertyEditorSupport#setAsText(java.lang.String)
 *///from   ww  w .  ja v a 2s .  co m
@Override
public void setAsText(String text) throws IllegalArgumentException {
    if (!StringUtils.isNotBlank(text)) {
        this.setValue(null);
    } else {
        final long id = Long.parseLong(text);
        final Fact fact = this.factProvider.getFactById(id);
        this.setValue(fact);
    }
}

From source file:io.fabric8.jenkins.openshiftsync.BuildConfigProjectProperty.java

@DataBoundConstructor
public BuildConfigProjectProperty(String buildConfigAsXML) {
    if (StringUtils.isNotBlank(buildConfigAsXML)) {
        this.buildConfig = (BuildConfig) xstream2().fromXML(buildConfigAsXML);
    }/*from  w w w  .  jav  a 2  s .  com*/
}

From source file:ml.shifu.shifu.core.binning.obj.NumBinInfo.java

public static List<NumBinInfo> constructNumBinfo(String binsData, char fieldSeparator) {
    List<NumBinInfo> binInfos = new ArrayList<NumBinInfo>();

    List<Double> thresholds = new ArrayList<Double>();
    thresholds.add(Double.NEGATIVE_INFINITY);

    if (StringUtils.isNotBlank(binsData)) {
        String[] fields = StringUtils.split(binsData, fieldSeparator);
        if (fields != null) {
            for (String field : fields) {
                Double val = null;
                try {
                    val = Double.valueOf(field);
                    thresholds.add(val);
                } catch (Exception e) {
                    // skip illegal double
                }//from ww w . j  a  va 2s  .c o m
            }
        }
    }

    thresholds.add(Double.POSITIVE_INFINITY);
    Collections.sort(thresholds);

    for (int i = 0; i < thresholds.size() - 1; i++) {
        binInfos.add(new NumBinInfo(thresholds.get(i), thresholds.get(i + 1)));
    }

    return binInfos;
}

From source file:edu.usu.sdl.openstorefront.storage.model.AttributeCodePk.java

/**
 * Creates a AttributeCodePk from key//from  w w  w.  j av  a  2 s  . co  m
 *
 * @param key
 * @return Null if it can't decode key
 */
public static AttributeCodePk fromKey(String key) {
    AttributeCodePk attributeCodePk = null;
    if (StringUtils.isNotBlank(key)) {
        String keySplit[] = key.split(ReflectionUtil.COMPOSITE_KEY_SEPERATOR);
        if (keySplit.length > 0) {
            attributeCodePk = new AttributeCodePk();
            attributeCodePk.setAttributeType(keySplit[0]);
            attributeCodePk.setAttributeCode(keySplit[1]);
        }
    }
    return attributeCodePk;
}

From source file:com.activecq.api.utils.TextUtil.java

/**
 * Returns the first non-null and non-empty String from the parameter list of strings.
 *
 * Ex. TextUtil.getFirstNonEmpty(x.getPageTitle(),
 *                                      x.getNavigationTitle(),
 *                                      x.getTitle(),
 *                                      x.getName())
 *
 * @param values//from w ww.  j av  a  2s .co m
 * @return
 */
public static String getFirstNonEmpty(String... values) {
    if (values == null || values.length < 1) {
        return null;
    }
    List<String> list = Arrays.asList(values);

    for (String item : list) {
        if (StringUtils.isNotBlank(item)) {
            return item;
        }
    }

    return null;
}

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

/**
 * Retrieve host & port from environment
 *///  w  w w.  j  a va 2  s. com
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:de.hybris.platform.accountsummaryaddon.document.criteria.validator.impl.AmountCriteriaValidator.java

@Override
public boolean isValid(final String startRange, final String endRange, final Model model) {

    Optional<BigDecimal> parsedStartRange = Optional.empty();
    Optional<BigDecimal> parsedEndRange = Optional.empty();

    if (LOG.isDebugEnabled()) {
        LOG.debug("validating amount ranges");
    }/*w  ww.  j a v  a2s  . c  om*/

    if (StringUtils.isNotBlank(startRange)) {
        parsedStartRange = AccountSummaryAddonUtils.parseBigDecimal(startRange);
        if (!parsedStartRange.isPresent()) {
            GlobalMessages.addErrorMessage(model,
                    "text.company.accountsummary.criteria.amount.format.from.invalid");
            return false;
        }
    }

    if (StringUtils.isNotBlank(endRange)) {
        parsedEndRange = AccountSummaryAddonUtils.parseBigDecimal(endRange);
        if (!parsedEndRange.isPresent()) {
            GlobalMessages.addErrorMessage(model,
                    "text.company.accountsummary.criteria.amount.format.to.invalid");
            return false;
        }
    }

    if (parsedStartRange.isPresent() && parsedEndRange.isPresent()
            && parsedStartRange.get().compareTo(parsedEndRange.get()) == 1) {
        GlobalMessages.addErrorMessage(model, "text.company.accountsummary.criteria.amount.invalid");
        return false;
    }

    return true;
}