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

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

Introduction

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

Prototype

public static boolean isEmpty(String str) 

Source Link

Document

Checks if a String is empty ("") or null.

Usage

From source file:fr.jetoile.hadoopunit.HadoopUtils.java

public static void setHadoopHome() {

    // Set hadoop.home.dir to point to the windows lib dir
    if (System.getProperty("os.name").startsWith("Windows")) {

        if (StringUtils.isEmpty(System.getenv("HADOOP_HOME"))) {

            try {
                configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE);
            } catch (ConfigurationException e) {
                LOG.error("unable to load {}", HadoopUnitConfig.DEFAULT_PROPS_FILE, e);
            }//from  w w w.ja v  a2  s. c  om

            String hadoop_home = configuration.getString("HADOOP_HOME");

            LOG.info("Setting hadoop.home.dir: {}", hadoop_home);
            if (hadoop_home == null) {
                LOG.error("HADOOP_HOME should be set or informed into hadoop-unit-default.properties");
                System.exit(-1);
            } else {
                System.setProperty("HADOOP_HOME", hadoop_home);
            }

        } else {
            System.setProperty("HADOOP_HOME", System.getenv("HADOOP_HOME"));
        }

        String windowsLibDir = System.getenv("HADOOP_HOME");

        LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
        System.setProperty("hadoop.home.dir", windowsLibDir);
        System.load(new File(windowsLibDir + Path.SEPARATOR + "bin" + Path.SEPARATOR + "hadoop.dll")
                .getAbsolutePath());
        System.load(new File(windowsLibDir + Path.SEPARATOR + "bin" + Path.SEPARATOR + "hdfs.dll")
                .getAbsolutePath());
    }
}

From source file:com.syaku.commons.DateUtils.java

/**
* @method : getDate(parameter,parameter2)
* @brief :  ,  .     ./*www  . j  av a2s  .  com*/
* @parameters {
parameter : (String) $1 =  , $2 =  , $3 =  , $4 =  , $5 =  , $6 = 
parameter2 : (String) (-_:./\s)   
    }
* @return : (String)   || 00:00:00
*/
public static String getDate(String patten, String date) {
    if (StringUtils.isEmpty(date))
        return date;
    String sysdate_patten = "(^[0-9]*)[-_:.\\/\\s]?([0-9]*)[-_:.\\/\\s]?([0-9]*)[-_:.\\/\\s]?([0-9]*)[-_:.\\/\\s]?([0-9]*)[-_:.\\/\\s]?([0-9]*)(.*)$";
    Pattern date_comp = Pattern.compile(sysdate_patten);
    if (date_comp.matcher(date).find())
        return date.replaceAll(sysdate_patten, patten);
    else
        return getDate(patten, "00:00:00");
}

From source file:com.dc.gameserver.extComponents.Kit.DateUtil.java

/**
 * ??/* ww w .ja va 2  s. co m*/
 * @param endTime
 * @return
 * @throws Exception
 */
public static Date getEndTime(String endTime) throws Exception {
    if (StringUtils.isEmpty(endTime)) {
        endTime = DEFAULT_ENDTIME;
    }
    return DateUtil.DATEFORMAT_DAY.parse(endTime);
}

From source file:jp.co.nemuzuka.utils.HtmlStringUtils.java

/**
 * textarea./*w  ww  . j a v a  2  s  .  com*/
 * textArea?????
 * ?
 * http:????https:????<a/>
 * \r\n/\r/\n?<br />?????
 * @param target 
 * @return 
 */
public static final String escapeTextAreaString(String target) {

    if (StringUtils.isEmpty(target)) {
        return "";
    }

    //?
    String resultStr = escape(target);
    resultStr = getATagString(resultStr);
    return replaseNl(resultStr);
}

From source file:com.photon.phresco.commons.CIPasswordScrambler.java

public static String unmask(String secret) throws PhrescoException {
    if (StringUtils.isEmpty(secret)) {
        return StringUtils.EMPTY;
    }/*from   w w w.  j  a  v  a2  s  .  c  om*/

    try {
        return new String(Base64.decode(secret.toCharArray()), "UTF-8");
    } catch (IOException e) {
        throw new PhrescoException(e);
    }
}

From source file:com.mmj.app.common.util.SpiderHtmlUtils.java

/**
 * ?URLhtml?//from  w  ww  . j av  a  2s  .com
 * 
 * @param url
 * @return
 */
public static String getHtmlByUrl(String url) {
    if (StringUtils.isEmpty(url)) {
        return null;
    }
    String html = null;
    HttpClient httpClient = new DefaultHttpClient();// httpClient
    HttpUriRequest httpget = new HttpGet(url);// get?URL
    httpget.setHeader("Connection", "keep-alive");
    httpget.setHeader("Referer", "http://www.baidu.com");
    httpget.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
    httpget.setHeader("User-Agent",
            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36");
    try {
        HttpResponse responce = httpClient.execute(httpget);// responce
        int responseCode = responce.getStatusLine().getStatusCode();// ?
        if (responseCode == HttpStatus.SC_OK || responseCode == HttpStatus.SC_MOVED_PERMANENTLY
                || responseCode == HttpStatus.SC_MOVED_TEMPORARILY) {// 200 ?
            // 
            HttpEntity entity = responce.getEntity();
            if (entity != null) {
                html = EntityUtils.toString((org.apache.http.HttpEntity) entity);// html??
            }
        }
    } catch (Exception e) {
        logger.error("SpiderHtmlUtils:getHtmlByUrl sprider url={} error!!!", url);
    } finally {
        httpClient.getConnectionManager().shutdown();
    }
    return html;
}

From source file:com.bstek.dorado.core.DoradoAbout.java

/**
 * ??//w w w . j  a v  a 2 s . c  o m
 */
public static String getVersion() {
    Package pkg = DoradoAbout.class.getPackage();
    String version = null;
    if (pkg != null)
        version = pkg.getImplementationVersion();
    if (StringUtils.isEmpty(version))
        version = instanceId;
    return version;
}

From source file:com.hangum.tadpole.engine.sql.util.ObjectCompileUtil.java

/**
 * object ?  - ? ?   ?? . // w ww.  j a v a 2  s.com
 * 
 * @param userDB
 * @param ddlType
 * @param objectName
 * @return
 */
public static String validateObject(UserDBDAO userDB, QUERY_DDL_TYPE ddlType, String objectName) {
    if (StringUtils.isEmpty(objectName))
        return "";
    String retMsg = ""; //$NON-NLS-1$

    if (userDB.getDBDefine() == DBDefine.ORACLE_DEFAULT | userDB.getDBDefine() == DBDefine.TIBERO_DEFAULT) {
        try {
            String strObjectName = StringUtils.upperCase(objectName);
            if (ddlType == QUERY_DDL_TYPE.PROCEDURE) {
                retMsg = OracleObjectCompileUtils.otherObjectCompile(QUERY_DDL_TYPE.PROCEDURE, "PROCEDURE", //$NON-NLS-1$
                        strObjectName, userDB);
            } else if (ddlType == QUERY_DDL_TYPE.PACKAGE) {
                retMsg = OracleObjectCompileUtils.packageCompile(strObjectName, userDB);
            } else if (ddlType == QUERY_DDL_TYPE.FUNCTION) {
                retMsg = OracleObjectCompileUtils.otherObjectCompile(QUERY_DDL_TYPE.FUNCTION, "FUNCTION", //$NON-NLS-1$
                        strObjectName, userDB);
            } else if (ddlType == QUERY_DDL_TYPE.TRIGGER) {
                retMsg = OracleObjectCompileUtils.otherObjectCompile(QUERY_DDL_TYPE.TRIGGER, "TRIGGER", //$NON-NLS-1$
                        strObjectName, userDB);
            } else if (ddlType == QUERY_DDL_TYPE.SYNONYM) {
                retMsg = OracleObjectCompileUtils.otherObjectCompile(QUERY_DDL_TYPE.SYNONYM, "SYNONYM", //$NON-NLS-1$
                        strObjectName, userDB);
            }
        } catch (Exception e) {
            logger.error("object compile", e);
        }
    }

    return retMsg;
}

From source file:com.github.dbourdette.otto.web.util.SizeInBytes.java

public static SizeInBytes fromValue(String value) {
    if (StringUtils.isEmpty(value)) {
        throw new IllegalArgumentException("value is not a valid size");
    }//from  w  w w  . ja v  a  2  s  .c  o  m

    long multiplier = 1;

    if (value.endsWith("M")) {
        value = StringUtils.substringBeforeLast(value, "M");
        multiplier = SCALE * SCALE;
    } else if (value.endsWith("K")) {
        value = StringUtils.substringBeforeLast(value, "K");
        multiplier = SCALE;
    } else if (value.endsWith("B")) {
        value = StringUtils.substringBeforeLast(value, "B");
    }

    try {
        return new SizeInBytes(Long.parseLong(value) * multiplier);
    } catch (Exception e) {
        throw new IllegalArgumentException("value is not a valid size");
    }
}

From source file:net.servicefixture.parser.TreeParserFactory.java

/**
 * Creates an <code>TreeParser</code> instance. Looks up system property
 * TreeParserFactory.TREE_PARSER_SYSPROP for the class name first. If not 
 * found, an <code>ExpressionTreeParser</code> instance will be created.
 *  /*from w  w w  . j  a  v a2 s . co  m*/
 */
public static TreeParser createTreeParser(String parserClazzName) {
    if (StringUtils.isEmpty(parserClazzName)) {
        parserClazzName = System.getProperty(TREE_PARSER_SYSPROP);
    }

    try {
        if (!StringUtils.isEmpty(parserClazzName)) {
            Class parserClazz = Thread.currentThread().getContextClassLoader().loadClass(parserClazzName);
            return (TreeParser) parserClazz.newInstance();
        }

        return new ExpressionTreeParser();
    } catch (Exception e) {
        throw new ServiceFixtureException("Unable to create TreeParser using class:" + parserClazzName + ".",
                e);
    }
}