You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.6 KiB

package com.ucmed.common.util;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
public class DataUtil {
public static Integer getIntegerValue(Map<String, Object> params,
String key, Integer defaultValue) {
try {
return ((Number) params.get(key)).intValue();
} catch (Exception e) {
}
return defaultValue;
}
public static Long getLongValue(Map<String, Object> params, String key,
Long defaultValue) {
try {
return ((Number) params.get(key)).longValue();
} catch (Exception e) {
}
return defaultValue;
}
public static Long getLongValue(Map<String, Object> params, String key) {
return getLongValue(params, key, null);
}
public static Long getLongValue(HttpServletRequest request, String key,
Long defaultValue) {
try {
String p = request.getParameter(key);
return Long.parseLong(p);
} catch (Exception e) {
}
return defaultValue;
}
public static Integer getIntegerValue(HttpServletRequest request, String key,
Integer defaultValue) {
try {
String p = request.getParameter(key);
return Integer.parseInt(p);
} catch (Exception e) {
}
return defaultValue;
}
public static Float getFloatValue(HttpServletRequest request, String key,
Float defaultValue) {
try {
String p = request.getParameter(key);
return Float.parseFloat(p);
} catch (Exception e) {
}
return defaultValue;
}
public static Long getLongValue(HttpServletRequest request, String key) {
return getLongValue(request, key, null);
}
public static Integer getIntegerValue(HttpServletRequest request,
String key) {
return getIntegerValue(request, key, null);
}
}