public static boolean isInScope(String scope, String value) {
Pattern pattern = Pattern.compile("^(\\(|\\[)\\d+,\\s*\\d+(\\)|\\])$");
Matcher matcher = pattern.matcher(scope);
if (!matcher.find() && StringHelper.isNumeric(value)) {
return false;
}
String[] scopes = scope.split(",");
Float valueF = Float.valueOf(value);
Float min = Float.valueOf(scopes[0].substring(1));
if ("(".equals(String.valueOf(scopes[0].charAt(0)))) {
if (valueF <= min)
return false;
} else if ("[".equals(String.valueOf(scopes[0].charAt(0)))) {
if (valueF < min)
return false;
}
Float max = Float.valueOf(scopes[1].substring(0, scopes[1].length() - 1));
if (")".equals(String.valueOf(scopes[1].charAt(scopes[1].length() - 1)))) {
if (valueF >= max)
return false;
} else if ("]".equals(String.valueOf(scopes[1].charAt(scopes[1].length() - 1)))) {
if (valueF > max)
return false;
}
return true;
} |