import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class MapUtil {
public static String getString(Map<?, ?> paramMap, String paramString) {
paramString = paramString.toLowerCase();
Set localSet = paramMap.keySet();
Iterator localIterator = localSet.iterator();
Hashtable localHashtable = new Hashtable();
while (localIterator.hasNext()) {
String localObject = (String) localIterator.next();
localHashtable.put(((String) localObject).toLowerCase(), localObject);
}
paramString = (String) localHashtable.get(paramString);
Object localObject = paramMap.get(paramString);
return localObject != null ? localObject.toString().trim() : "";
}
public static long getLong(Map<?, ?> paramMap, String paramString) {
String str = getString(paramMap, paramString);
if (str.equals("")) {
return -1L;
}
return Long.parseLong(str);
}
public static int getInt(Map<?, ?> paramMap, String paramString) {
String str = getString(paramMap, paramString);
if (str.equals("")) {
return -1;
}
return Integer.parseInt(str);
}
public static float getFloat(Map<?, ?> paramMap, String paramString) {
String str = getString(paramMap, paramString);
if (str.equals("")) {
return -1.0F;
}
return Float.parseFloat(str);
}
public static double getDouble(Map<?, ?> paramMap, String paramString) {
String str = getString(paramMap, paramString);
if (str.equals("")) {
return -1.0D;
}
return Double.parseDouble(str);
}
}
java,map工具类
最新推荐文章于 2024-08-02 18:42:00 发布