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

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

Introduction

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

Prototype

public static boolean isNotBlank(final CharSequence cs) 

Source Link

Document

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

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

Usage

From source file:musiccrawler.validate.Validator.java

public static String validPath(String input) {
    if (StringUtils.isNotBlank(input)) {
        if (!input.startsWith(Constant.CharacterSpec.FORWARD_SLASH)) {
            return Constant.CharacterSpec.FORWARD_SLASH + input;
        } else if (!input.endsWith(Constant.CharacterSpec.FORWARD_SLASH)) {
            return input + Constant.CharacterSpec.FORWARD_SLASH;
        } else {/*from w w w  .  jav a  2  s .  c o m*/
            return Constant.CharacterSpec.FORWARD_SLASH + input + Constant.CharacterSpec.FORWARD_SLASH;
        }
    }
    return input;
}

From source file:dependencygraph.utils.InputFormatValidator.java

/**
 * Validates the given input line is in valid format
 * Expected format is A->B//from  w  w  w .  ja va  2s .  c om
 *
 * @param inputLine the input line to validate
 * @return true if file in valid format
 */
public static boolean validateInputLine(String inputLine) {
    String[] splitLine = inputLine.split(ApplicationConstants.VERTEX_SEPARATOR_INDICATOR);
    return splitLine.length == 2 && StringUtils.isNotBlank(splitLine[0]);
}

From source file:com.cnten.platform.util.FileUtil.java

public static String getExtensionName(String fileName) {
    String extension = "";
    if (StringUtils.isNotBlank(fileName)) {
        int lastIndex = fileName.lastIndexOf('.');
        lastIndex = lastIndex > 0 ? lastIndex + 1 : 0;
        extension = fileName.substring(lastIndex);
    }/*w  w  w. ja  va 2s .c  o m*/
    return extension;
}

From source file:com.movies.util.MovieUtil.java

/**
 * Checks if it is ok to save a person object. Mandatory fields are #{@link Person#name}, #{@link Person#surname}, #{@link Person#birthDate}, #{@link Person#sex} and #{@link Person#country}.
 * @param person// www.j  a va  2  s .c om
 * @return true if it is ok to save, false otherwise. 
 */
public static boolean okToSave(Person person) {
    return person != null && StringUtils.isNotBlank(person.getName())
            && StringUtils.isNotBlank(person.getSurname()) && person.getBirthDate() != null
            && person.getCountry() != null && person.getSex() != null;
}

From source file:cf.janga.hook.utils.IOUtils.java

public static boolean hasExtension(File file, String extension) {
    String fileName = file.getName();
    return StringUtils.isNotBlank(fileName) && fileName.endsWith("." + extension) && file.isFile();
}

From source file:edu.usu.sdl.openstorefront.common.util.NetworkUtil.java

/**
 * Get the correct client ip from a request
 *
 * @param request//  w  ww  .j a v  a2 s. co  m
 * @return client ip or N/A if not found
 */
public static String getClientIp(HttpServletRequest request) {
    String clientIp = OpenStorefrontConstant.NOT_AVAILABLE;
    if (request != null) {
        clientIp = request.getRemoteAddr();

        //Check for header ip it may be forwarded by a proxy
        String clientIpFromHeader = request.getHeader("x-forwarded-for");
        if (StringUtils.isNotBlank(clientIpFromHeader)) {
            clientIp = clientIp + " Forward for: " + clientIpFromHeader;
        } else {
            clientIpFromHeader = request.getHeader("x-real-ip");
            if (StringUtils.isNotBlank(clientIpFromHeader)) {
                clientIp = clientIp + " X-real IP: " + clientIpFromHeader;
            }
        }
    }
    return clientIp;
}

From source file:com.mb.ext.web.util.MessageHelper.java

public static String getMessageByErrorId(MessageSource messageSource, String errorCode) {
    Locale currentLocale = LocaleContextHolder.getLocale();
    if (StringUtils.isNotBlank(errorCode)) {
        return messageSource.getMessage(errorCode, null, currentLocale);
    }//from   w w  w.  j a  v a2s  .  c o m

    return getDefaultMessage(messageSource);
}

From source file:mobile.vo.user.JobExp.java

public static List<JobExp> createList(Expert expert) {
    List<JobExp> list = new ArrayList<>();

    if (null != expert && StringUtils.isNotBlank(expert.jobExp)) {
        JsonNode expertJobExp = Json.parse(expert.jobExp);
        if (expertJobExp.isArray()) {
            Iterator<JsonNode> elements = expertJobExp.elements();
            while (elements.hasNext()) {
                JsonNode next = elements.next();
                list.add(create(next));/*w  w w  .ja  va  2  s .c o m*/
            }
        }
    }

    return list;
}

From source file:mobile.vo.user.EducationExp.java

public static List<EducationExp> createList(Expert expert) {
    List<EducationExp> exp = new ArrayList<>();

    if (null != expert && StringUtils.isNotBlank(expert.educationExp)) {
        JsonNode eduExpNode = Json.parse(expert.educationExp);
        if (eduExpNode.isArray()) {
            Iterator<JsonNode> elements = eduExpNode.elements();
            while (elements.hasNext()) {
                JsonNode next = elements.next();
                exp.add(create(next));//from w  ww.j  ava 2 s . com
            }
        }
    }

    return exp;
}

From source file:br.com.gerenciapessoal.service.CadastroUsuarioService.java

@SuppressWarnings("null")
public static String md5(String input) {
    String md5 = null;/*from  w  ww  . ja va  2 s.  c  o  m*/
    if (!StringUtils.isNotBlank(input)) {
        return null;
    }
    try {
        //Create MessageDigest object for MD5           
        MessageDigest digest = MessageDigest.getInstance("MD5");
        //Update input string in message digest           
        digest.update(input.getBytes(), 0, input.length());
        //Converts message digest value in base 16 (hex)            
        md5 = new BigInteger(1, digest.digest()).toString(16);
    } catch (NoSuchAlgorithmException e) {
    }
    return md5.trim();
}