⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 convert.java

📁 j2me下的1套UI框架.包含j2me开发中会应用的各种低级组件
💻 JAVA
字号:
package com.jmobilecore.support;

/**
 * This class contains convertions methods
 *
 * @author 	Greg Gridin
 */
public class Convert {

    /**
     * Converts object to the <code>String</code> value
     * @param  obj the object for convertion
     * @param  defValue the default value used if <code>obj</code> is null
     * @return the <code>String</code> representing <code>obj</code> parameter
     */
    static public String toString(Object obj, String defValue) {

        if (obj == null)
            return defValue;
        return (String) obj;
    }

    /**
     * Converts object to the <code>long</code> value
     * @param  obj the object for convertion
     * @param  defValue the default value used if <code>obj</code> is null
     * @return the <code>long</code> representing <code>obj</code> parameter
     */
    static public long toLong(Object obj, long defValue) {

        if (obj == null)
            return defValue;
        return ((Long)obj).longValue();
    }

    /**
     * Converts object to the <code>int</code> value
     * @param  obj the object for convertion
     * @param  defValue the default value used if <code>obj</code> is null
     * @return the <code>int</code> representing <code>obj</code> parameter
     */
    static public int toInteger(Object obj, int defValue) {

        if (obj == null)
            return defValue;
        return ((Integer)obj).intValue();
    }

    /**
     * Converts object to the <code>boolean</code> value
     * @param  obj the object for convertion
     * @param  defValue the default value used if <code>obj</code> is null
     * @return the <code>int</code> representing <code>obj</code> parameter
     */
    static public boolean toBoolean(Object obj, boolean defValue) {

        if (obj == null)
            return defValue;
        return ((Boolean)obj).booleanValue();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -