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.edmunds.etm.management.util.DnsUtils.java

/**
 * Returns a set of all IP addresses for the given host names.
 *
 * @param hosts      collection of host names or IP addresses
 * @param retryCount maximum number of times to retry DNS lookups
 * @return set of all IP addresses (may be empty if no addresses were found)
 *//* ww w. jav  a  2 s . co m*/
public static Set<InetAddress> getAddressesByHost(Collection<String> hosts, int retryCount) {

    Set<InetAddress> allAddresses = new HashSet<InetAddress>();

    for (String host : hosts) {
        if (StringUtils.isBlank(host)) {
            continue;
        }
        InetAddress[] hostAddresses = getAddressesByHost(host, retryCount);
        if (hostAddresses != null) {
            allAddresses.addAll(Arrays.asList(hostAddresses));
        }
    }
    return allAddresses;
}

From source file:com.opengamma.language.view.ValueRequirementUtils.java

/**
 * Parses the string descriptions of the portfolio requirements into sets of value requirements (string/constraint pairs)
 * for each calculation configuration referenced.
 * //www.  j  a  v a2 s . c o m
 * @param portfolioRequirements the user supplied requirements
 * @return a map of configuration to value requirement sets
 */
public static Map<String, Set<Pair<String, ValueProperties>>> parseRequirements(
        final String[] portfolioRequirements) {
    final Map<String, Set<Pair<String, ValueProperties>>> results = new HashMap<String, Set<Pair<String, ValueProperties>>>();
    for (String requirement : portfolioRequirements) {
        if (StringUtils.isBlank(requirement)) {
            continue;
        }
        Triple<String, String, ValueProperties> parsedRequirement = parseRequirement(requirement);
        Set<Pair<String, ValueProperties>> configRequirements = results.get(parsedRequirement.getFirst());
        if (configRequirements == null) {
            configRequirements = new HashSet<Pair<String, ValueProperties>>();
            results.put(parsedRequirement.getFirst(), configRequirements);
        }
        configRequirements.add(Pair.of(parsedRequirement.getSecond(), parsedRequirement.getThird()));
    }
    return results;
}

From source file:ddf.util.WktStandard.java

/**
 * Normalize the given WKT to conform to the WKT grammar.
 *
 *
 * @param wkt/* w w  w .  j  ava  2  s  . com*/
 *            WKT to normalize
 * @return normalized WKT
 */
public static String normalize(String wkt) {
    if (StringUtils.isBlank(wkt)) {
        return wkt;
    }

    WKTReader wktReader = new WKTReader(GEOMETRY_FACTORY);
    try {
        // using JTS to normalize WKT into the correct format
        return wktReader.read(wkt).toText();
    } catch (ParseException e) {
        throw new IllegalArgumentException("Cannot parse wkt.", e);
    }
}

From source file:com.aerospike.play.sessionstore.DefaultSessionIDProvider.java

@Override
public String get() {
    play.mvc.Http.Context ctx = Http.Context.current();
    String sessionid = ctx.session().get("sessionid");
    if (StringUtils.isBlank(sessionid)) {
        String CHAR_LIST = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
        int string_length = 10;
        StringBuffer random_str = new StringBuffer();
        for (int i = 0; i < string_length; i++) {
            int randomInt = 0;
            Random randomGenerator = new Random();
            randomInt = randomGenerator.nextInt(CHAR_LIST.length());
            random_str.append(CHAR_LIST.charAt(randomInt));
        }// w  w  w.ja v  a  2 s  .c om
        sessionid = random_str.toString();
        ctx.session().put("sessionid", sessionid);
        log.debug("Setting up cookie");
    }
    return sessionid;
}

From source file:ar.com.zauber.commons.web.version.impl.InmutableVersionProvider.java

/**
 * Creates the InmutableVersionProvider.
 *
 *//*from w w w.ja  va2s . c om*/
public InmutableVersionProvider(final String version) {
    Validate.isTrue(!StringUtils.isBlank(version));

    this.version = version;
}

From source file:com.switchfly.inputvalidation.RequestParameter.java

public boolean isBlank() {
    return StringUtils.isBlank(getValue());
}

From source file:com.leixl.easyframework.system.dao.impl.EUserDaoImpl.java

public Pagination getPage(String username, String email, Integer groupId, Boolean disabled, Boolean admin,
        int pageNo, int pageSize) {
    Finder f = Finder.create("select bean from EUser bean");

    f.append(" where 1=1");
    if (!StringUtils.isBlank(username)) {
        f.append(" and bean.username like :username");
        f.setParam("username", "%" + username + "%");
    }//from   w  w  w .ja  v  a 2s.c o m
    if (!StringUtils.isBlank(email)) {
        f.append(" and bean.email like :email");
        f.setParam("email", "%" + email + "%");
    }
    if (groupId != null) {
        f.append(" and bean.group.id=:groupId");
        f.setParam("groupId", groupId);
    }
    if (disabled != null) {
        f.append(" and bean.disabled=:disabled");
        f.setParam("disabled", disabled);
    }
    if (admin != null) {
        f.append(" and bean.admin=:admin");
        f.setParam("admin", admin);
    }
    f.append(" order by bean.id desc");
    return find(f, pageNo, pageSize);
}

From source file:com.example.JcrPropertySampleModel.java

public JcrPropertySampleModel(int i) {
    if (StringUtils.isBlank(name)) { // Noncompliant {{Fields annotated by @JcrProperty shouldn't be accessed from constructor.}}
        modName = surname + i; // Noncompliant
    }/*w w  w.  ja v  a  2s  .  c  o m*/
    city = "Poznan";
}

From source file:com.prowidesoftware.swift.model.field.Field92MTest.java

@Test
public void testField92MString() {
    Field92M f = null;//from w  w  w.j  a v a2s  . co  m

    f = new Field92M("");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));

    f = new Field92M(":");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));

    f = new Field92M(":/");
    //assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));

    f = new Field92M("://");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));

    f = new Field92M(":///");
    assertTrue(StringUtils.isBlank(f.getComponent1()));
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));

    f = new Field92M(":DDDD");
    assertEquals("DDDD", f.getComponent1());
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));

    f = new Field92M(":DDDD//");
    assertEquals("DDDD", f.getComponent1());
    assertTrue(StringUtils.isBlank(f.getComponent2()));
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));

    f = new Field92M(":DDDD//EEEEEEEE");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertTrue(StringUtils.isBlank(f.getComponent3()));
    assertTrue(StringUtils.isBlank(f.getComponent4()));

    f = new Field92M(":DDDD//EEEEEEEE123/");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertEquals("123", f.getComponent3());
    assertTrue(StringUtils.isBlank(f.getComponent4()));

    f = new Field92M(":DDDD//EEEEEEEE123/FFFF");
    assertEquals("DDDD", f.getComponent1());
    assertEquals("EEEEEEEE", f.getComponent2());
    assertEquals("123", f.getComponent3());
    assertEquals("FFFF", f.getComponent4());
}

From source file:com.salesmanager.core.service.common.model.IntegrationProperties.java

public void setProperties1(String properties1) {
    if (!StringUtils.isBlank(properties1)) {
        properties1.trim();/*  w  w  w. j  av  a 2s .c  om*/
    }
    this.properties1 = properties1;
}