java.lang.Object | |
↳ | com.microstrategy.utils.ValidationHelper |
This is a simple helper class with methods to validate strings.
The methods provided helps validating if a string is a valid integer/real/date.
It also provides a method to check if a String is empty.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ValidationHelper() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static boolean | fixBoolean(String stringToValidate, boolean defaultValue) | ||||||||||
static int | fixInt(String stringToValidate, int defaultValue) | ||||||||||
static Number |
getValidInt(String value)
Identical to
isValidInt(String) , except this returns
the validated value, which may be different from the original
input value since the validation procedure may strip out
whitespace and other redundant symbols. | ||||||||||
static Number |
getValidReal(String value, Locale locale)
Identical to
isValidReal(String, Locale) , except this returns
the validated value, which may be different from the original
input value since the validation procedure may strip out
whitespace and other redundant symbols. | ||||||||||
static boolean |
isNonEmptyString(String value)
Validates that the given is not empty.
| ||||||||||
static boolean |
isValidDate(String value, Locale locale, Date min, Date max)
Validates that the given string value is a valid date within the given range.
| ||||||||||
static boolean |
isValidDate(String value, Locale locale)
Validates that the given string value is a valid date.
| ||||||||||
static boolean |
isValidInt(String value, int min, int max)
Validates that the given string value is an integer in the specified range.
| ||||||||||
static boolean |
isValidInt(String value)
Validates that the given string value is an integer.
| ||||||||||
static boolean |
isValidReal(String value, Locale locale)
Validates that the given string value is a valid real number.
| ||||||||||
static boolean |
isValidReal(String value, Locale locale, double min, double max)
Validates that the given string value is a valid real number within the given range.
| ||||||||||
static boolean |
validateValueDataType(String value, int dataType, Locale locale)
Validates that the given value is valid, in accordance to the data type specified.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Identical to isValidInt(String)
, except this returns
the validated value, which may be different from the original
input value since the validation procedure may strip out
whitespace and other redundant symbols.
value | unvalidated value |
---|
ParseException | if there was a problem parsing value |
---|---|
NullPointerException | if value is null |
IllegalArgumentException | Thrown when system default locale is null. |
Identical to isValidReal(String, Locale)
, except this returns
the validated value, which may be different from the original
input value since the validation procedure may strip out
whitespace and other redundant symbols.
value | unvalidated value |
---|---|
locale | locale |
ParseException | if there was a problem parsing value |
---|---|
NullPointerException | if value is null |
IllegalArgumentException | Thrown when locale is null. |
Validates that the given is not empty. It checks for null, for empty strings and for strings with only white spaces
value | the string to validate |
---|
Validates that the given string value is a valid date within the given range. The value must be
formatted based on the given locale using SHORT date format (i.e. mm/dd/yyyy).
It uses a DateFormat
to validate the value.
value | a String representing a date. |
---|---|
locale | the locale in which the strings is expected to be formatted. |
min | the minimum date |
max | the maximum date |
Validates that the given string value is a valid date. The value must be
formatted based on the given locale using SHORT date format (i.e. mm/dd/yyyy).
It uses a DateFormat
to validate the value.
value | a String representing a date. |
---|---|
locale | the locale in which the strings is expected to be formatted. |
Validates that the given string value is an integer in the specified range. The value should be a
non-formatted integer (i.e. no grouping of thousands), therefore the locale
is not necessary. It uses Integer.parseInt
to validate the value
value | a non-formated String representation of an integer. |
---|---|
min | the minimum value |
max | the max value |
Validates that the given string value is an integer. The value should be a
non-formatted integer (i.e. no grouping of thousands), therefore the locale
is not necessary. It uses Integer.parseInt
to validate the value
value | a non-formated String representation of an integer. |
---|
Validates that the given string value is a valid real number. The value could be
formatted based on the given locale. It uses a NumberFormatter
to validate the value
value | a String representing a real value. |
---|---|
locale | the locale in which the strings is expected to be formatted. |
Validates that the given string value is a valid real number within the given range. The value could be
formatted based on the given locale. It uses a NumberFormat
to validate the value
value | a String representing a real value. |
---|---|
locale | the locale in which the strings is expected to be formatted. |
min | the minimum value |
max | the max value |
Validates that the given value is valid, in accordance to the data type specified.
Data type should be a value taken from EnumDSSXMLDataType
value | the value to validate. |
---|---|
dataType | the date type used to validate the value. |
locale | locale |