This commit is contained in:
@@ -632,7 +632,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
public short getRequstURILastPath(short defvalue) {
|
||||
String val = getRequstURILastPath();
|
||||
if (val.isEmpty()) return defvalue;
|
||||
return val.isEmpty() ? defvalue : Short.parseShort(val);
|
||||
try {
|
||||
return Short.parseShort(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -648,7 +652,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
public short getRequstURILastPath(int radix, short defvalue) {
|
||||
String val = getRequstURILastPath();
|
||||
if (val.isEmpty()) return defvalue;
|
||||
return val.isEmpty() ? defvalue : Short.parseShort(val, radix);
|
||||
try {
|
||||
return Short.parseShort(val, radix);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -662,7 +670,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public int getRequstURILastPath(int defvalue) {
|
||||
String val = getRequstURILastPath();
|
||||
return val.isEmpty() ? defvalue : Integer.parseInt(val);
|
||||
try {
|
||||
return val.isEmpty() ? defvalue : Integer.parseInt(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -677,7 +689,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public int getRequstURILastPath(int radix, int defvalue) {
|
||||
String val = getRequstURILastPath();
|
||||
return val.isEmpty() ? defvalue : Integer.parseInt(val, radix);
|
||||
try {
|
||||
return val.isEmpty() ? defvalue : Integer.parseInt(val, radix);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -691,7 +707,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public float getRequstURILastPath(float defvalue) {
|
||||
String val = getRequstURILastPath();
|
||||
return val.isEmpty() ? defvalue : Float.parseFloat(val);
|
||||
try {
|
||||
return val.isEmpty() ? defvalue : Float.parseFloat(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -705,7 +725,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public long getRequstURILastPath(long defvalue) {
|
||||
String val = getRequstURILastPath();
|
||||
return val.isEmpty() ? defvalue : Long.parseLong(val);
|
||||
try {
|
||||
return val.isEmpty() ? defvalue : Long.parseLong(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -720,7 +744,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public long getRequstURILastPath(int radix, long defvalue) {
|
||||
String val = getRequstURILastPath();
|
||||
return val.isEmpty() ? defvalue : Long.parseLong(val, radix);
|
||||
try {
|
||||
return val.isEmpty() ? defvalue : Long.parseLong(val, radix);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,7 +762,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public double getRequstURILastPath(double defvalue) {
|
||||
String val = getRequstURILastPath();
|
||||
return val.isEmpty() ? defvalue : Double.parseDouble(val);
|
||||
try {
|
||||
return val.isEmpty() ? defvalue : Double.parseDouble(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -781,7 +813,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public short getRequstURIPath(String prefix, short defvalue) {
|
||||
String val = getRequstURIPath(prefix, null);
|
||||
return val == null ? defvalue : Short.parseShort(val);
|
||||
try {
|
||||
return val == null ? defvalue : Short.parseShort(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -797,7 +833,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public short getRequstURIPath(int radix, String prefix, short defvalue) {
|
||||
String val = getRequstURIPath(prefix, null);
|
||||
return val == null ? defvalue : Short.parseShort(val, radix);
|
||||
try {
|
||||
return val == null ? defvalue : Short.parseShort(val, radix);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -813,7 +853,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public int getRequstURIPath(String prefix, int defvalue) {
|
||||
String val = getRequstURIPath(prefix, null);
|
||||
return val == null ? defvalue : Integer.parseInt(val);
|
||||
try {
|
||||
return val == null ? defvalue : Integer.parseInt(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -830,7 +874,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public int getRequstURIPath(int radix, String prefix, int defvalue) {
|
||||
String val = getRequstURIPath(prefix, null);
|
||||
return val == null ? defvalue : Integer.parseInt(val, radix);
|
||||
try {
|
||||
return val == null ? defvalue : Integer.parseInt(val, radix);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -845,7 +893,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public float getRequstURIPath(String prefix, float defvalue) {
|
||||
String val = getRequstURIPath(prefix, null);
|
||||
return val == null ? defvalue : Float.parseFloat(val);
|
||||
try {
|
||||
return val == null ? defvalue : Float.parseFloat(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -860,7 +912,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public long getRequstURIPath(String prefix, long defvalue) {
|
||||
String val = getRequstURIPath(prefix, null);
|
||||
return val == null ? defvalue : Long.parseLong(val);
|
||||
try {
|
||||
return val == null ? defvalue : Long.parseLong(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -876,7 +932,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public long getRequstURIPath(int radix, String prefix, long defvalue) {
|
||||
String val = getRequstURIPath(prefix, null);
|
||||
return val == null ? defvalue : Long.parseLong(val, radix);
|
||||
try {
|
||||
return val == null ? defvalue : Long.parseLong(val, radix);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -891,7 +951,11 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*/
|
||||
public double getRequstURIPath(String prefix, double defvalue) {
|
||||
String val = getRequstURIPath(prefix, null);
|
||||
return val == null ? defvalue : Double.parseDouble(val);
|
||||
try {
|
||||
return val == null ? defvalue : Double.parseDouble(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -487,12 +487,22 @@ public abstract class AnyValue {
|
||||
|
||||
public byte getByteValue(String name, byte defaultValue) {
|
||||
String value = getValue(name);
|
||||
return value == null || value.length() == 0 ? defaultValue : Byte.decode(value);
|
||||
if (value == null || value.length() == 0) return defaultValue;
|
||||
try {
|
||||
return Byte.decode(value);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public byte getByteValue(int radix, String name, byte defaultValue) {
|
||||
String value = getValue(name);
|
||||
return value == null || value.length() == 0 ? defaultValue : (radix == 10 ? Byte.decode(value) : Byte.parseByte(value, radix));
|
||||
if (value == null || value.length() == 0) return defaultValue;
|
||||
try {
|
||||
return (radix == 10 ? Byte.decode(value) : Byte.parseByte(value, radix));
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public char getCharValue(String name) {
|
||||
@@ -510,12 +520,22 @@ public abstract class AnyValue {
|
||||
|
||||
public short getShortValue(String name, short defaultValue) {
|
||||
String value = getValue(name);
|
||||
return value == null || value.length() == 0 ? defaultValue : Short.decode(value);
|
||||
if (value == null || value.length() == 0) return defaultValue;
|
||||
try {
|
||||
return Short.decode(value);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public short getShortValue(int radix, String name, short defaultValue) {
|
||||
String value = getValue(name);
|
||||
return value == null || value.length() == 0 ? defaultValue : (radix == 10 ? Short.decode(value) : Short.parseShort(value, radix));
|
||||
if (value == null || value.length() == 0) return defaultValue;
|
||||
try {
|
||||
return (radix == 10 ? Short.decode(value) : Short.parseShort(value, radix));
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public int getIntValue(String name) {
|
||||
@@ -524,12 +544,22 @@ public abstract class AnyValue {
|
||||
|
||||
public int getIntValue(String name, int defaultValue) {
|
||||
String value = getValue(name);
|
||||
return value == null || value.length() == 0 ? defaultValue : Integer.decode(value);
|
||||
if (value == null || value.length() == 0) return defaultValue;
|
||||
try {
|
||||
return Integer.decode(value);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public int getIntValue(int radix, String name, int defaultValue) {
|
||||
String value = getValue(name);
|
||||
return value == null || value.length() == 0 ? defaultValue : (radix == 10 ? Integer.decode(value) : Integer.parseInt(value, radix));
|
||||
if (value == null || value.length() == 0) return defaultValue;
|
||||
try {
|
||||
return (radix == 10 ? Integer.decode(value) : Integer.parseInt(value, radix));
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public long getLongValue(String name) {
|
||||
@@ -538,12 +568,22 @@ public abstract class AnyValue {
|
||||
|
||||
public long getLongValue(String name, long defaultValue) {
|
||||
String value = getValue(name);
|
||||
return value == null || value.length() == 0 ? defaultValue : Long.decode(value);
|
||||
if (value == null || value.length() == 0) return defaultValue;
|
||||
try {
|
||||
return Long.decode(value);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public long getLongValue(int radix, String name, long defaultValue) {
|
||||
String value = getValue(name);
|
||||
return value == null || value.length() == 0 ? defaultValue : (radix == 10 ? Long.decode(value) : Long.parseLong(value, radix));
|
||||
if (value == null || value.length() == 0) return defaultValue;
|
||||
try {
|
||||
return (radix == 10 ? Long.decode(value) : Long.parseLong(value, radix));
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public float getFloatValue(String name) {
|
||||
@@ -552,7 +592,12 @@ public abstract class AnyValue {
|
||||
|
||||
public float getFloatValue(String name, float defaultValue) {
|
||||
String value = getValue(name);
|
||||
return value == null || value.length() == 0 ? defaultValue : Float.parseFloat(value);
|
||||
if (value == null || value.length() == 0) return defaultValue;
|
||||
try {
|
||||
return Float.parseFloat(value);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public double getDoubleValue(String name) {
|
||||
@@ -561,7 +606,12 @@ public abstract class AnyValue {
|
||||
|
||||
public double getDoubleValue(String name, double defaultValue) {
|
||||
String value = getValue(name);
|
||||
return value == null || value.length() == 0 ? defaultValue : Double.parseDouble(value);
|
||||
if (value == null || value.length() == 0) return defaultValue;
|
||||
try {
|
||||
return Double.parseDouble(value);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public String getValue(String name, String defaultValue) {
|
||||
|
||||
Reference in New Issue
Block a user