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

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

Introduction

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

Prototype

public static boolean isNotEmpty(String str) 

Source Link

Document

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

Usage

From source file:com.jeklsoft.cassandraclient.hector.HectorTest.java

public static me.prettyprint.hector.api.Keyspace configureHectorAccessToCassandra(String cassandraHostname,
        Integer cassandraPort, String cassandraClusterName, String cassandraKeySpaceName,
        String configurationPath, List<String> cassandraCommands) throws Exception {

    try {/* w  w  w .ja  v a  2  s. co m*/
        if (StringUtils.isNotEmpty(configurationPath) && (cassandraCommands != null)
                && (!cassandraCommands.isEmpty())) {
            URL stream = HectorTest.class.getClassLoader().getResource("cassandra.yaml");
            File cassandraYaml = new File(stream.toURI());

            EmbeddedCassandra.builder().withCleanDataStore().withStartupCommands(cassandraCommands)
                    .withHostname(cassandraHostname).withHostport(cassandraPort)
                    .withCassandaConfigurationDirectoryPath(configurationPath)
                    .withCassandaYamlFile(cassandraYaml).build();
        }

        CassandraHostConfigurator configurator = new CassandraHostConfigurator(
                cassandraHostname + ":" + cassandraPort);
        Cluster cluster = HFactory.getOrCreateCluster(cassandraClusterName, configurator);
        me.prettyprint.hector.api.Keyspace keyspace = HFactory.createKeyspace(cassandraKeySpaceName, cluster);
        return keyspace;
    } catch (Exception e) {
        throw new RuntimeException("Error configuring access", e);
    }
}

From source file:elaborate.editor.solr.SolrServerFactory.java

public static synchronized SolrServerWrapper getInstance() {
    if (instance == null) {
        QueryComposer queryComposer = new ElaborateEditorQueryComposer();
        String url = Configuration.instance().getSetting(Configuration.SOLR_URL_KEY);
        if (StringUtils.isNotEmpty(url)) {
            instance = new RemoteSolrServer(url, queryComposer);
        } else {//from w  w w. j  a  v a 2s  .com
            instance = new LocalSolrServer(null, "entries", queryComposer);
        }
    }
    return instance;
}

From source file:com.envision.envservice.common.util.IPUtil.java

/**
 * ?IP?//from  w  w w .jav a 2 s . c  om
 * 
 * @Title: getRemoteAddr 
 * @return IP 
 * @Date 2015-10-30
 */
public static String getRemoteAddr(HttpServletRequest request) {
    String ipAddress = null;

    String proxyIP = request.getHeader(Constants.PROXY_IP);
    if (StringUtils.isNotEmpty(proxyIP)) {
        ipAddress = proxyIP;
    } else {
        ipAddress = request.getRemoteAddr();
    }

    return ipAddress;
}

From source file:com.haulmont.cuba.core.entity.LocaleHelper.java

public static String getLocalizedName(String localeBundle) {
    Locale locale = AppBeans.get(UserSessionSource.class).getLocale();
    String localeName = null;/*from  w  w  w .j ava  2 s .  c om*/
    if (StringUtils.isNotEmpty(localeBundle)) {
        Properties localeProperties = loadProperties(localeBundle);
        if (localeProperties != null) {
            String key = locale.getLanguage();
            if (StringUtils.isNotEmpty(locale.getCountry()))
                key += "_" + locale.getCountry();
            if (localeProperties.containsKey(key))
                localeName = (String) localeProperties.get(key);
        }
    }
    return localeName;
}

From source file:com.alifi.jgenerator.utils.StringFormatUtils.java

/**
 *  ?/*from  w ww.  jav a2 s.  c  o  m*/
 * 
 * @param str
 * @return
 */
public static String humpCPix(String pix, String str) {
    if (StringUtils.isNotEmpty(str)) {
        String strs = str.toLowerCase();
        String pixx = pix.toLowerCase();
        return hump(strs.replaceFirst(pixx, "").replaceAll("_", " "));
    }
    return null;
}

From source file:com.youtube.serializer.YoutubeEventClassifier.java

public static Class detectClass(String json) {
    Preconditions.checkNotNull(json);// www  .j  a  v  a 2s .  c o m
    Preconditions.checkArgument(StringUtils.isNotEmpty(json));

    ObjectNode objectNode;
    try {
        objectNode = (ObjectNode) mapper.readTree(json);
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }

    if (objectNode.findValue("kind") != null && objectNode.get("kind").toString().equals(VIDEO_IDENTIFIER)) {
        return Video.class;
    } else if (objectNode.findValue("kind") != null
            && objectNode.get("kind").toString().contains(CHANNEL_IDENTIFIER)) {
        return com.google.api.services.youtube.model.Channel.class;
    } else {
        return ObjectNode.class;
    }
}

From source file:com.baifendian.swordfish.execserver.job.spark.SparkSubmitArgsUtil.java

/**
 * ? <p>//  www.j  a  v a 2 s  . c o m
 *
 * @return ?
 */
public static List<String> buildArgs(SparkParam param) {
    List<String> args = new ArrayList<>();

    args.add(SparkSubmitArgsConst.MASTER);
    args.add("yarn");

    args.add(SparkSubmitArgsConst.DEPLOY_MODE);
    args.add("cluster");

    if (StringUtils.isNotEmpty(param.getMainClass())) {
        args.add(SparkSubmitArgsConst.CLASS);
        args.add(param.getMainClass());
    }

    if (param.getDriverCores() != 0) {
        args.add(SparkSubmitArgsConst.DRIVER_CORES);
        args.add(String.format("%d", param.getDriverCores()));
    }

    if (StringUtils.isNotEmpty(param.getDriverMemory())) {
        args.add(SparkSubmitArgsConst.DRIVER_MEMORY);
        args.add(param.getDriverMemory());
    }

    if (param.getNumExecutors() != 0) {
        args.add(SparkSubmitArgsConst.NUM_EXECUTORS);
        args.add(String.format("%d", param.getNumExecutors()));
    }

    if (param.getExecutorCores() != 0) {
        args.add(SparkSubmitArgsConst.EXECUTOR_CORES);
        args.add(String.format("%d", param.getExecutorCores()));
    }

    if (StringUtils.isNotEmpty(param.getExecutorMemory())) {
        args.add(SparkSubmitArgsConst.EXECUTOR_MEMORY);
        args.add(param.getExecutorMemory());
    }

    if (param.getLibJars() != null && !param.getLibJars().isEmpty()) {
        args.add(SparkSubmitArgsConst.JARS);
        args.add(getFilesStr(param.getLibJars(), false));
    }

    if (param.getFiles() != null && !param.getFiles().isEmpty()) {
        args.add(SparkSubmitArgsConst.FILES);
        args.add(getFilesStr(param.getFiles(), true));
    }

    if (param.getArchives() != null && !param.getArchives().isEmpty()) {
        args.add(SparkSubmitArgsConst.ARCHIVES);
        args.add(getFilesStr(param.getArchives(), true));
    }

    if (StringUtils.isNotEmpty(param.getQueue())) {
        args.add(SparkSubmitArgsConst.QUEUE);
        args.add(param.getQueue());
    }

    if (param.getProperties() != null && !param.getProperties().isEmpty()) {
        for (Property property : param.getProperties()) {
            args.add(SparkSubmitArgsConst.CONF);
            args.add(property.getProp() + "=" + property.getValue());
        }
    }

    if (param.getMainJar() != null) {
        args.add(param.getMainJar().getRes());
    }

    if (StringUtils.isNotEmpty(param.getArgs())) {
        args.add(param.getArgs());
    }

    return args;
}

From source file:info.magnolia.cms.gui.controlx.search.SimpleSearchUtil.java

/**
 * Return the expression build by a simple search
 *///from  w w w.  j  av a  2  s  .c om
public static SearchQueryExpression getSimpleSearchExpression(String searchStr, SearchConfig config) {
    if (StringUtils.isNotEmpty(searchStr)) {
        List expressions = new ArrayList();
        for (Iterator iter = config.getControlDefinitions().iterator(); iter.hasNext();) {
            SearchControlDefinition def = (SearchControlDefinition) iter.next();
            expressions.add(new StringSearchQueryParameter(def.getColumn(), searchStr,
                    StringSearchQueryParameter.CONTAINS));
        }
        return chainExpressions(expressions, SearchQueryOperator.OR);
    } else {
        return null;
    }
}

From source file:com.opengamma.examples.simulated.DBTestUtils.java

public static void createTestHsqlDB(String configResourceLocation) throws IOException {
    Properties props = loadProperties(configResourceLocation);

    DbTool dbTool = new DbTool();
    dbTool.setCatalog("og-financial");
    dbTool.setJdbcUrl(props.getProperty(JDBC_URL_KEY));
    dbTool.setUser(props.getProperty(DB_USERNAME_KEY, ""));
    dbTool.setPassword(props.getProperty(DB_PASSWORD_KEY, ""));
    dbTool.setCreate(true);// www.j  a  v a  2 s. com
    dbTool.setDrop(true);
    dbTool.setCreateTables(true);
    dbTool.execute();

    if (StringUtils.isNotEmpty(props.getProperty(JDBC_URL_KEY_USER))) {
        DbTool dbTool2 = new DbTool();
        dbTool2.setCatalog("og-financial");
        dbTool2.setJdbcUrl(props.getProperty(JDBC_URL_KEY_USER));
        dbTool2.setUser(props.getProperty(DB_USERNAME_KEY, ""));
        dbTool2.setPassword(props.getProperty(DB_PASSWORD_KEY, ""));
        dbTool2.setCreate(true);
        dbTool2.setDrop(true);
        dbTool2.setCreateTables(true);
        dbTool2.execute();
    }
}

From source file:com.taobao.top.common.server.RefundMessageUrlKit.java

public static String perform(String prefixUrl, String dbUrl) {
    if (StringUtils.isNotEmpty(dbUrl) && dbUrl.length() > 2) {
        if (StringUtils.isBlank(prefixUrl)) {
            prefixUrl = DEFAULT_ONLINE_PICTURL;
        }//  ww w.j  a v  a2 s  . c o m
        if (!prefixUrl.startsWith(preFix_http)) {
            prefixUrl = preFix_http + prefixUrl;
        }
        int index = prefixUrl.indexOf(".");
        String target = prefixUrl.substring(0, index) + "0" + getRandomNumber() + prefixUrl.substring(index);
        target = StringUtils.replace(target, ".taobao.", ".taobaocdn.");
        if (!target.endsWith(SEP)) {
            target = target + SEP;
        }
        return target + REFUND + SEP + dbUrl;
    }
    return null;
}