📄 convert.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 + -