|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.javalid.core.validator.ValidatorSupport
public class ValidatorSupport
Contains a couple of shared methods used by the standard JavalidValidator implementation classes and some other core classes.
Changes for 1.1
| Method Summary | |
|---|---|
static void |
checkIsSingleExpression(java.lang.String value,
java.lang.String propertyName,
java.lang.String currentPath)
Checks if given value is a single expression, see ELSupport.isExpression(java.lang.String). |
static void |
compareCalendars(int validationAnnotation,
java.lang.String pattern,
java.lang.String customCode,
boolean globalMessage,
java.util.Calendar calAnnotation,
java.util.Calendar calValue,
int mode,
java.util.List<ValidationMessage> messages,
java.lang.String validationPath)
Compares two calendars according given mode (mode from @DateCheck). |
static java.util.Calendar |
convertDateToCalendar(java.util.Date value,
int convertType)
Converts given date to a Calendar instance using given convertType (see DateCheck.TYPE_CONVERT_*) |
static java.lang.String |
convertDateToString(java.util.Date date,
java.lang.String pattern)
Converts given date to a string, using given pattern. |
static java.util.Date |
convertStringToDate(java.lang.String date,
java.lang.String pattern)
Converts given string to a date using given pattern, raises JavalidException if conversion fails |
static java.math.BigDecimal |
getAsBigDecimal(java.lang.String value)
Tries to convert value to BigDecimal, returns on success. |
static java.math.BigInteger |
getAsBigInteger(java.lang.String value)
Tries to convert value to BigInteger, returns on success. |
static ValidatorCallInfo |
getValidatorCallInfo()
Deprecated. Usage of this method is deprecated, if you need this info in your validator define it as a complex validator. In a next release this will be removed! |
static double |
getValueAsDouble(java.lang.Object value)
For given value, try to convert it to a double value and return it. |
static boolean |
isBigMathNumber(java.lang.Object value)
Returns true if given value is a big number (BigInteger or BigDecimal). |
static boolean |
isEmptyString(java.lang.String value)
Returns true if given string is either null or has a length of 0. |
static boolean |
isNumericValue(java.lang.Object value)
Returns true if given value is a numeric value (either as wrapper or as real primitive, which is now in a wrapper anyway). |
static boolean |
validateForNotEmptyAnnotation(java.lang.Object value,
boolean trim)
This method validates for the @NotEmpty validation and for instance the EmptyOrNotEmpty annotation. |
static boolean |
validationMustBeAppliedToGroup(java.lang.String[] applyToGroups,
java.lang.String groupName,
java.lang.String[] jvGroupNames)
Checks given applyToGroups array on given group name or JvGroup.GROUP_APPLY_ALL. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static final boolean validationMustBeAppliedToGroup(java.lang.String[] applyToGroups,
java.lang.String groupName,
java.lang.String[] jvGroupNames)
applyToGroups - Contains the array of groups where to apply an annotation togroupName - The name of the group to check for (note JvGroup.GROUP_APPLY_ALL found
in the applyToGroups array will return true if groupName exists in jvGroupNames)
public static final double getValueAsDouble(java.lang.Object value)
value - The value to convert
public static final boolean isNumericValue(java.lang.Object value)
value - the value to check
public static final boolean isBigMathNumber(java.lang.Object value)
value - The value to check
public static final java.math.BigInteger getAsBigInteger(java.lang.String value)
value - The value to convert
public static final java.math.BigDecimal getAsBigDecimal(java.lang.String value)
value - The value to convert
public static final boolean isEmptyString(java.lang.String value)
value - The value to check
@Deprecated public static final ValidatorCallInfo getValidatorCallInfo()
public static final java.util.Date convertStringToDate(java.lang.String date,
java.lang.String pattern)
date - The date to convertpattern - The pattern to use
public static final java.lang.String convertDateToString(java.util.Date date,
java.lang.String pattern)
date - Date to convert to stringpattern - The pattern to use
public static final java.util.Calendar convertDateToCalendar(java.util.Date value,
int convertType)
value - The value to convert to calendarconvertType - The convertType to use
public static final void compareCalendars(int validationAnnotation,
java.lang.String pattern,
java.lang.String customCode,
boolean globalMessage,
java.util.Calendar calAnnotation,
java.util.Calendar calValue,
int mode,
java.util.List<ValidationMessage> messages,
java.lang.String validationPath)
validationAnnotation - Used to determine what error messages must be added: See AnnotationConstants.DATE_DATE_XXXpattern - The conversion pattern to use for dates (when converting them to string on an error)customCode - The customcode to add in a validation message (optional, can be empty)globalMessage - Set to true if a global message must be addedcalAnnotation - The annotation value that was ON the annotationcalValue - The actual value under validation (converted to a calendar)mode - The mode to use (one of the constants on the annotation you call this method for)messages - The messages to add tovalidationPath - The current validation path
public static final void checkIsSingleExpression(java.lang.String value,
java.lang.String propertyName,
java.lang.String currentPath)
ELSupport.isExpression(java.lang.String).
The 2 other parameters are information to make a sensible exception if not. Raises JavalidException if not.
value - The value that must be a single expressionpropertyName - The name of the propertycurrentPath - The current path under validation
public static final boolean validateForNotEmptyAnnotation(java.lang.Object value,
boolean trim)
value - The value to checktrim - True if trim must be applied to strings first
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||