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.haulmont.cuba.gui.components.validators.ScriptValidator.java

public ScriptValidator(Element element, String messagesPack) {
    this.script = element.getText();
    innerScript = StringUtils.isNotBlank(script);
    if (!innerScript) {
        scriptPath = element.attributeValue("script");
    }//w w  w . j  a v  a  2s. c om
    message = element.attributeValue("message");
    this.messagesPack = messagesPack;
}

From source file:com.enonic.cms.core.content.mail.AbstractAssignmentMailTemplate.java

protected String createAssignmentMailInfoElement() {
    String contentPath = content.getPathAsString();

    StringBuffer body = new StringBuffer();

    Map<String, String> keyValues = Maps.newLinkedHashMap();

    if (StringUtils.isNotBlank(contentPath)) {
        addKeyValue(keyValues, "%fldStatus%", getTranslatedStatus(contentVersion.getStatus()));

        if (assignmentDueDate != null) {
            addKeyValue(keyValues, "%contentAssignmentDuedate%",
                    DATE_FORMAT.print(assignmentDueDate.getTime()));
        }//  w w  w.  ja  va  2 s  . co  m

        addKeyValue(keyValues, "%fldDisplayName%", contentVersion.getTitle());
        addKeyValue(keyValues, "%fldContentType%", content.getContentType().getName());
        addKeyValue(keyValues, "%contentAssignedBy%", createUserName(assigner));
        addKeyValue(keyValues, "%contentAssignmentPath%", contentPath);
    }

    String adminUrl = getAdminUrl(content.getKey());

    if (StringUtils.isNotBlank(adminUrl)) {
        addKeyValue(keyValues, "%blockURL%", adminUrl);
    }

    appendKeyValuesWithPadding(body, keyValues);

    return body.toString();
}

From source file:io.renren.modules.oss.cloud.CloudStorageService.java

/**
 * //from ww  w .  ja va2 s  . c om
 * @param prefix ?
 * @param suffix ?
 * @return 
 */
public String getPath(String prefix, String suffix) {
    //?uuid
    String uuid = UUID.randomUUID().toString().replaceAll("-", "");
    //
    String path = DateUtils.format(new Date(), "yyyyMMdd") + "/" + uuid;

    if (StringUtils.isNotBlank(prefix)) {
        path = prefix + "/" + path;
    }

    return path + suffix;
}

From source file:com.rodiontsev.maven.plugins.buildinfo.providers.BuildTimeProvider.java

@Override
public Map<String, String> getInfo(MavenProject project, BuildInfoMojo mojo) {
    Map<String, String> info = new LinkedHashMap<String, String>();

    String dateTimePattern = mojo.getDateTimePattern();
    if (StringUtils.isNotBlank(dateTimePattern)) {
        String buildTime;//from  w w  w.jav a2  s.  co m
        try {
            DateFormat dateFormat = new SimpleDateFormat(dateTimePattern, Locale.ENGLISH);
            buildTime = dateFormat.format(new Date());
        } catch (IllegalArgumentException e) {
            buildTime = "the given pattern is invalid";
            mojo.getLog().warn(String.format(
                    "The given date-time pattern '%s' is invalid. Please read %s javadoc about user-defined patterns for date-time formatting.",
                    dateTimePattern, SimpleDateFormat.class.getCanonicalName()));
        }
        info.put("build.time", buildTime);
    }

    return info;
}

From source file:com.bibisco.manager.LocaleManager.java

private Locale initLocale() {

    Locale lLocale = null;//from ww  w.  j  a va  2 s.c o m

    mLog.debug("Start initLocale()");

    PropertiesManager lPropertiesManager = PropertiesManager.getInstance();
    String lStrLocale = lPropertiesManager.getProperty("locale");

    if (StringUtils.isNotBlank(lStrLocale)) {
        String[] lStrLocaleSplit = lStrLocale.split("_");
        lLocale = new Locale(lStrLocaleSplit[0], lStrLocaleSplit[1]);

    } else {
        lLocale = Locale.getDefault();
        lPropertiesManager.updateProperty("locale", lLocale.toString());
    }

    mLog.debug("End initLocale()");

    return lLocale;
}

From source file:bazaar4idea.command.BzrMergeCommand.java

public BzrAbstractResult execute() {
    ShellCommandService commandService = ShellCommandService.getInstance(project);
    List<String> arguments = new LinkedList<String>();
    if (StringUtils.isNotBlank(revision)) {
        arguments.add("--rev");
        arguments.add(revision);//w  ww  . j a va  2  s  .co m
    } else if (StringUtils.isNotBlank(branch)) {
        arguments.add(branch);
    }
    return commandService.execute2(repo, "merge", arguments);
}

From source file:com.enitalk.configs.RedisConfig.java

@Bean
public JedisConnectionFactory jedisConnectionFactory() {
    JedisConnectionFactory j = new JedisConnectionFactory();
    j.setUsePool(true);/* w w w. j  a  va 2 s . c  o  m*/
    String redisHost = env.getProperty("redis.host", "localhost");
    logger.info("Redis env host {}", redisHost);
    j.setHostName(redisHost);
    if (StringUtils.isNotBlank(env.getProperty("redis.pass"))) {
        j.setPassword(env.getProperty("redis.pass"));
    }
    return j;
}

From source file:com.intuit.tank.util.TestParamUtil.java

/**
 * extracts the ramp and simulation time from the given values.
 * /*from   w w w .j a v a2  s  .c o m*/
 * @param executionTime
 *            the calculated execution time.
 * @param rampTimeString
 *            the expression for the ramp time
 * @param simulationTimeString
 *            the expresssion for the simulation time
 * @return {@link TestParameterContainer} contianing the values.
 * @throws IllegalArgumentException
 *             if there is an issue evaluating the expressions or there is a cyclic dependency.
 */
public static TestParameterContainer evaluateTestTimes(long executionTime, String rampTimeString,
        String simulationTimeString) throws IllegalArgumentException {
    boolean rampComplete = false;
    long rampTime = 0;
    long simTime = 0;
    Builder builder = TestParameterContainer.builder();
    if (StringUtils.isNotBlank(rampTimeString)) {
        if (!rampTimeString.toLowerCase().contains(SIMULATION_TIME)) {
            rampTime = evaluateExpression(rampTimeString, executionTime, simTime, rampTime);
            builder.withRampTime(rampTime);
            rampComplete = true;
        }
    }
    if (StringUtils.isNotBlank(simulationTimeString)) {
        if (rampTimeString.toLowerCase().contains(RAMP_TIME) && !rampComplete) {
            throw new IllegalArgumentException("cyclic dependeny of ramp time and simulation time.");
        }
        simTime = evaluateExpression(simulationTimeString, executionTime, simTime, rampTime);
        builder.withSimulationTime(simTime);
    }
    if (!rampComplete && StringUtils.isNotBlank(rampTimeString)) {
        rampTime = evaluateExpression(rampTimeString, executionTime, simTime, rampTime);
        builder.withRampTime(rampTime);
    }
    return builder.build();
}

From source file:com.sfs.whichdoctor.formatter.OutputFormatter.java

/**
 * Output the person bean to the person's formal name.
 *
 * @param person the person/*from   w w  w. ja v  a2 s .c o  m*/
 *
 * @return the string
 */
public static String toMemberName(final PersonBean person) {
    final StringBuffer name = new StringBuffer();

    if (person != null) {
        if (StringUtils.isNotBlank(person.getTitle())) {
            name.append(person.getTitle().trim());
            name.append(" ");
        }
        if (StringUtils.isNotBlank(person.getFirstName())) {
            name.append(person.getFirstName().trim());
            name.append(" ");
        }
        if (StringUtils.isNotBlank(person.getMiddleName())) {
            name.append(person.getMiddleName().trim());
            name.append(" ");
        }
        if (StringUtils.isNotBlank(person.getLastName())) {
            name.append(person.getLastName().trim());
        }
        if (StringUtils.isNotBlank(person.getHonors())) {
            name.append(", ");
            name.append(person.getHonors().trim());
        }

        final String type = person.getMembershipField("Membership Type");
        if (StringUtils.equals(type, "Member: Fellow") || StringUtils.equals(type, "Member: Life Fellow")) {
            name.append(", FRACP");
        }
    }
    return name.toString();
}

From source file:com.btobits.automator.fix.ant.task.SMTPStartTask.java

@Override
protected void validate() throws Exception {
    Assert.assertTrue("Reference to SMTP acceptor is not specified", StringUtils.isNotBlank(refId));
}