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

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

Introduction

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

Prototype

public static boolean isNotEmpty(final CharSequence cs) 

Source Link

Document

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

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

Usage

From source file:de.knightsoftnet.mtwidgets.client.ui.widget.oracle.PhoneNumberDin5008RestOracle.java

@Override
protected boolean needSuggest(final String pentry) {
    return StringUtils.isNotEmpty(pentry)
            && (pentry.charAt(0) != '0' && StringUtils.countMatches(pentry, " ") < 2
                    || pentry.charAt(0) == '0' && !StringUtils.contains(pentry, ' '));
}

From source file:jp.eisbahn.oauth2.server.fetcher.accesstoken.impl.RequestParameter.java

/**
 * Return whether an access token is included in the request parameter's
 * values. Actually, this method confirms whether the "oauth_token" or
 * "access_token" request parameter exists or not.
 *
 * @param request/*from ww w. java 2s .  com*/
 *            The request object.
 * @return If either parameter exists, this result is true.
 */
@Override
public boolean match(Request request) {
    String oauthToken = request.getParameter("oauth_token");
    String accessToken = request.getParameter("access_token");
    return StringUtils.isNotEmpty(accessToken) || StringUtils.isNotEmpty(oauthToken);
}

From source file:com.glaf.core.startup.MultiDBUpdateStartup.java

public void startup(ServletContext context, String text) {
    logger.debug("-----------------MultiDBUpdateStartup.startup----------------");
    if (StringUtils.isNotEmpty(text)) {
        JSONObject json = JSON.parseObject(text);
        logger.debug(json.toJSONString());
        String sql = json.getString("sql");
        String dbName = json.getString("dbName");
        if (StringUtils.isNotEmpty(sql) && !DBUtils.isLegalQuerySql(sql)) {
            logger.error(sql);//  w ww.j a  v a 2 s  .co m
            throw new RuntimeException(" SQL statement illegal ");
        }
        if (StringUtils.isNotEmpty(sql) && StringUtils.isNotEmpty(dbName)) {
            Properties defaultProps = DBConfiguration.getTemplateProperties(Environment.DEFAULT_SYSTEM_NAME);
            Properties props = DBConfiguration.getTemplateProperties(dbName);
            logger.debug(dbName + " props:" + props);
            if (props != null && StringUtils.isNotEmpty(props.getProperty(DBConfiguration.JDBC_URL))) {
                String old_url = props.getProperty(DBConfiguration.JDBC_URL);
                Connection conn = null;
                PreparedStatement stmt = null;
                ResultSet rs = null;
                try {
                    conn = DBConnectionFactory.getConnection();
                    if (conn != null) {
                        DBUpdateThread t = new DBUpdateThread(props);
                        ThreadFactory.run(t);
                        stmt = conn.prepareStatement(sql);
                        rs = stmt.executeQuery();
                        while (rs.next()) {
                            Map<String, Object> dataMap = new java.util.HashMap<String, Object>();
                            Enumeration<?> e = props.keys();
                            while (e.hasMoreElements()) {
                                String key = (String) e.nextElement();
                                String value = props.getProperty(key);
                                dataMap.put(key, value);
                            }
                            String host = rs.getString(1);
                            String databaseName = rs.getString(2);
                            String name = rs.getString(5);
                            if (databaseName.indexOf("$") != -1) {
                                String url_xy = defaultProps.getProperty(DBConfiguration.JDBC_URL);
                                String driver = defaultProps.getProperty(DBConfiguration.JDBC_DRIVER);
                                String db = null;
                                if (StringUtils.equals(driver,
                                        "com.microsoft.sqlserver.jdbc.SQLServerDriver")) {
                                    db = url_xy.substring(url_xy.lastIndexOf("=") + 1, url_xy.length());
                                } else if (StringUtils.equals(driver, "net.sourceforge.jtds.jdbc.Driver")) {
                                    db = url_xy.substring(url_xy.lastIndexOf("/") + 1, url_xy.length());
                                }
                                if (db != null) {
                                    databaseName = StringTools.replaceIgnoreCase(databaseName, "self", db);
                                }
                            }
                            logger.debug("databaseName:" + databaseName);
                            dataMap.put(DBConfiguration.HOST, host);
                            dataMap.put(DBConfiguration.DATABASE, databaseName);
                            props.put(DBConfiguration.HOST, host);
                            props.put(DBConfiguration.DATABASE, databaseName);
                            props.put(DBConfiguration.JDBC_USER, rs.getString(3));
                            props.put(DBConfiguration.JDBC_PASSWORD, rs.getString(4));

                            logger.debug(dataMap);
                            String url = ExpressionTools.evaluate(old_url, dataMap);
                            props.put(DBConfiguration.JDBC_URL, url);
                            host = StringTools.replace(host, ".", "_");
                            props.put(DBConfiguration.JDBC_NAME, name);

                            /**
                             * ???
                             */
                            if (DBConnectionFactory.checkConnection(props)) {
                                logger.debug("SQL......");
                                DBUpdateThread thread = new DBUpdateThread(props);
                                ThreadFactory.run(thread);
                            }
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                    logger.error(ex);
                } finally {
                    JdbcUtils.close(rs);
                    JdbcUtils.close(stmt);
                    JdbcUtils.close(conn);
                }
            }
        }
    }
}

From source file:net.sf.dynamicreports.report.builder.datatype.CharacterType.java

@Override
public Character stringToValue(String value, Locale locale) throws DRException {
    if (StringUtils.isNotEmpty(value)) {
        return new Character(value.charAt(0));
    }/*from   w w w. j  a v a2s.co m*/
    return null;
}

From source file:entities.ExtenuatingCircumstance.java

public String getSubmitted_date() {
    if (StringUtils.isNotEmpty(submitted_date)) {
        if (submitted_date.indexOf(" ") > 0) {
            return submitted_date.substring(0, submitted_date.indexOf(" "));
        }/*from   w ww.  j a va  2s .c  o m*/
    }
    return submitted_date;
}

From source file:com.easysoft.action.core.BusinessLogAction.java

@RequestMapping(params = { "dataGrid" })
public ModelAndView dataGrid(Integer rows, Integer page, String operator) {
    PageOption pageOption = new PageOption();
    pageOption.setPageSize(rows);//ww w . j av  a2  s. c  o  m
    pageOption.setCurrentPageNo(page);
    if (StringUtils.isNotEmpty(operator)) {
        pageOption.addSearch("operator", operator);
    }
    bnLogQuery.queryForPage(pageOption);

    DataGridReturn dataGridReturn = new DataGridReturn(pageOption.getTotalCount(),
            (List<AdminUser>) pageOption.getResult());
    String json = JsonUtils.beanToJson(dataGridReturn);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("json", json);
    return new ModelAndView("admin/json_message", map);
}

From source file:com.glaf.core.startup.MultiDBNativeCmdStartup.java

public void startup(ServletContext context, String text) {
    logger.debug("-----------------MultiDBNativeCmdStartup.startup----------------");
    if (StringUtils.isNotEmpty(text)) {
        JSONObject json = JSON.parseObject(text);
        logger.debug(json.toJSONString());
        String sql = json.getString("sql");
        String dbName = json.getString("dbName");
        String cmd = json.getString("cmd");
        if (StringUtils.isNotEmpty(sql) && !DBUtils.isLegalQuerySql(sql)) {
            logger.error(sql);/*  w w  w .  j  a  v  a2 s . com*/
            throw new RuntimeException(" SQL statement illegal ");
        }
        if (StringUtils.isNotEmpty(sql) && StringUtils.isNotEmpty(dbName) && StringUtils.isNotEmpty(cmd)) {
            Properties defaultProps = DBConfiguration.getTemplateProperties(Environment.DEFAULT_SYSTEM_NAME);
            Properties props = DBConfiguration.getTemplateProperties(dbName);
            logger.debug(dbName + " props:" + props);
            if (props != null && StringUtils.isNotEmpty(props.getProperty(DBConfiguration.JDBC_URL))) {
                String old_url = props.getProperty(DBConfiguration.JDBC_URL);
                Connection conn = null;
                PreparedStatement stmt = null;
                ResultSet rs = null;
                try {
                    conn = DBConnectionFactory.getConnection();
                    if (conn != null) {
                        DBNativeCmdThread t = new DBNativeCmdThread(cmd, defaultProps);
                        ThreadFactory.run(t);
                        stmt = conn.prepareStatement(sql);
                        rs = stmt.executeQuery();
                        while (rs.next()) {
                            Map<String, Object> dataMap = new java.util.HashMap<String, Object>();
                            Enumeration<?> e = props.keys();
                            while (e.hasMoreElements()) {
                                String key = (String) e.nextElement();
                                String value = props.getProperty(key);
                                dataMap.put(key, value);
                            }
                            String host = rs.getString(1);
                            String databaseName = rs.getString(2);
                            String user = rs.getString(3);
                            String password = rs.getString(4);
                            String name = rs.getString(5);
                            if (databaseName.indexOf("$") != -1) {
                                String url_xy = defaultProps.getProperty(DBConfiguration.JDBC_URL);
                                String driver = defaultProps.getProperty(DBConfiguration.JDBC_DRIVER);
                                String db = null;
                                if (StringUtils.equals(driver,
                                        "com.microsoft.sqlserver.jdbc.SQLServerDriver")) {
                                    db = url_xy.substring(url_xy.lastIndexOf("=") + 1, url_xy.length());
                                } else if (StringUtils.equals(driver, "net.sourceforge.jtds.jdbc.Driver")) {
                                    db = url_xy.substring(url_xy.lastIndexOf("/") + 1, url_xy.length());
                                }
                                if (db != null) {
                                    databaseName = StringTools.replaceIgnoreCase(databaseName, "self", db);
                                }
                            }
                            logger.debug("databaseName:" + databaseName);
                            dataMap.put(DBConfiguration.HOST, host);
                            dataMap.put(DBConfiguration.DATABASE, databaseName);
                            props.put(DBConfiguration.JDBC_USER, rs.getString(3));
                            props.put(DBConfiguration.JDBC_PASSWORD, rs.getString(4));
                            props.put(DBConfiguration.HOST, host);
                            props.put(DBConfiguration.DATABASE, databaseName);
                            props.put(DBConfiguration.JDBC_USER, user);
                            props.put(DBConfiguration.JDBC_PASSWORD, password);

                            logger.debug(dataMap);
                            String url = ExpressionTools.evaluate(old_url, dataMap);
                            props.put(DBConfiguration.JDBC_URL, url);
                            host = StringTools.replace(host, ".", "_");
                            props.put(DBConfiguration.JDBC_NAME, name);

                            /**
                             * ???
                             */
                            if (DBConnectionFactory.checkConnection(props)) {
                                logger.debug("......");
                                DBNativeCmdThread thread = new DBNativeCmdThread(cmd, props);
                                ThreadFactory.run(thread);
                            }
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                    logger.error(ex);
                } finally {
                    JdbcUtils.close(rs);
                    JdbcUtils.close(stmt);
                    JdbcUtils.close(conn);
                }
            }
        }
    }
}

From source file:io.wcm.devops.conga.generator.ContextPropertiesBuilder.java

/**
 * Build context variables that are global to the environment.
 * @param environmentName Environment name
 * @param environment Environment/*from  w w  w  .j av  a  2 s.co  m*/
 * @param version Environment version
 * @return Context variables map
 */
public static Map<String, Object> buildEnvironmentContextVariables(String environmentName,
        Environment environment, String version) {
    Map<String, Object> map = new HashMap<>();

    map.put(ContextProperties.VERSION, version);
    map.put(ContextProperties.ENVIRONMENT, environmentName);

    // clone environment before resolving variables to make sure they are resolved only for this context, not for file generation
    Environment clonedEnvironemnt = new Cloner().deepClone(environment);

    // resolve all variables at any level in environment
    VariableObjectTreeResolver.resolve(clonedEnvironemnt);

    // list of nodes
    map.put(ContextProperties.NODES, clonedEnvironemnt.getNodes());
    Map<String, List<Node>> nodesByRole = new HashMap<>();
    Map<String, Map<String, List<Node>>> nodesByRoleVariant = new HashMap<>();
    for (Node node : clonedEnvironemnt.getNodes()) {
        for (NodeRole nodeRole : node.getRoles()) {
            List<Node> nodes = nodesByRole.get(nodeRole.getRole());
            if (nodes == null) {
                nodes = new ArrayList<>();
                nodesByRole.put(nodeRole.getRole(), nodes);
            }
            nodes.add(node);

            if (StringUtils.isNotEmpty(nodeRole.getVariant())) {
                Map<String, List<Node>> nodesByVariant = nodesByRoleVariant.get(nodeRole.getRole());
                if (nodesByVariant == null) {
                    nodesByVariant = new HashMap<>();
                    nodesByRoleVariant.put(nodeRole.getRole(), nodesByVariant);
                }
                List<Node> variantNodes = nodesByVariant.get(nodeRole.getVariant());
                if (variantNodes == null) {
                    variantNodes = new ArrayList<>();
                    nodesByVariant.put(nodeRole.getVariant(), variantNodes);
                }
                variantNodes.add(node);
            }
        }
    }
    map.put(ContextProperties.NODES_BY_ROLE, nodesByRole);
    map.put(ContextProperties.NODES_BY_ROLE_VARIANT, nodesByRoleVariant);

    // list of tenants
    map.put(ContextProperties.TENANTS, clonedEnvironemnt.getTenants());
    Map<String, List<Tenant>> tenantsByRole = new HashMap<>();
    for (Tenant tenant : clonedEnvironemnt.getTenants()) {
        for (String tenantRoleName : tenant.getRoles()) {
            List<Tenant> tenants = tenantsByRole.get(tenantRoleName);
            if (tenants == null) {
                tenants = new ArrayList<>();
                tenantsByRole.put(tenantRoleName, tenants);
            }
            tenants.add(tenant);
        }
    }
    map.put(ContextProperties.TENANTS_BY_ROLE, tenantsByRole);

    return map;
}

From source file:ch.cyberduck.core.HostUrlProvider.java

public String get(final Scheme scheme, final int port, final String username, final String hostname,
        final String path) {
    final String base = String.format("%s://%s%s%s", scheme,
            includeUsername && StringUtils.isNotEmpty(username) ? String.format("%s@", username) : "",
            new PunycodeConverter().convert(hostname),
            port != scheme.getPort() ? String.format(":%d", port) : "");
    if (includePath) {
        if (StringUtils.isNotBlank(path)) {
            return String.format("%s%s", base, PathNormalizer.normalize(path));
        }/*  w w w  .j  av  a 2s.  c o m*/
    }
    return base;
}

From source file:br.com.ateliens.repository.ClientesFiltrados.java

private Criteria criarCriteriaParaFiltro(FiltroCliente filtro) {
    Session session = manager.unwrap(Session.class);
    Criteria criteria = session.createCriteria(Cliente.class);

    if (StringUtils.isNotEmpty(filtro.getNome())) {
        criteria.add(Restrictions.ilike("nome", filtro.getNome(), MatchMode.ANYWHERE));
    }//w w  w .  jav a 2s  .c o  m
    return criteria;
}