public abstract class Validator extends Object implements Interceptor
Modifier and Type | Field and Description |
---|---|
protected Controller |
controller |
protected String |
datePattern |
protected static String |
DEFAULT_DATE_PATTERN |
protected static String |
emailAddressPattern |
protected boolean |
invalid |
protected Invocation |
invocation |
protected boolean |
shortCircuit |
Constructor and Description |
---|
Validator() |
Modifier and Type | Method and Description |
---|---|
protected void |
addError(String errorKey,
String errorMessage)
Add message when validate failure.
|
protected String |
getActionKey()
Return the action key of this action.
|
protected Method |
getActionMethod()
Return the method of this action.
|
protected String |
getActionMethodName()
Return the method name of this action.
|
protected Controller |
getController()
Return the controller of this action.
|
protected String |
getControllerKey()
Return the controller key of this action.
|
protected String |
getDatePattern() |
protected String |
getViewPath()
Return view path of this controller.
|
protected abstract void |
handleError(Controller c)
Handle the validate error.
|
void |
intercept(Invocation invocation) |
protected void |
setDatePattern(String datePattern) |
protected void |
setShortCircuit(boolean shortCircuit)
设置短路验证.
|
protected abstract void |
validate(Controller c)
Use validateXxx method to validate the parameters of this action.
|
protected void |
validateBoolean(int index,
String errorKey,
String errorMessage)
validate boolean for urlPara.
|
protected void |
validateBoolean(String field,
String errorKey,
String errorMessage)
validate boolean.
|
protected void |
validateCaptcha(String field,
String errorKey,
String errorMessage) |
protected void |
validateDate(String field,
Date min,
Date max,
String errorKey,
String errorMessage)
Validate date.
|
protected void |
validateDate(String field,
String errorKey,
String errorMessage)
Validate date.
|
protected void |
validateDate(String field,
String min,
String max,
String errorKey,
String errorMessage)
Validate date.
|
protected void |
validateDouble(String field,
double min,
double max,
String errorKey,
String errorMessage)
Validate double.
|
protected void |
validateDouble(String field,
String errorKey,
String errorMessage)
Validate double.
|
protected void |
validateEmail(String field,
String errorKey,
String errorMessage)
Validate email.
|
protected void |
validateEqualField(String field_1,
String field_2,
String errorKey,
String errorMessage)
Validate equal field.
|
protected void |
validateEqualInteger(Integer i1,
Integer i2,
String errorKey,
String errorMessage)
Validate equal integer.
|
protected void |
validateEqualString(String s1,
String s2,
String errorKey,
String errorMessage)
Validate equal string.
|
protected void |
validateInteger(int index,
int min,
int max,
String errorKey,
String errorMessage)
Validate integer for urlPara.
|
protected void |
validateInteger(int index,
String errorKey,
String errorMessage)
Validate integer for urlPara.
|
protected void |
validateInteger(String field,
int min,
int max,
String errorKey,
String errorMessage)
Validate integer.
|
protected void |
validateInteger(String field,
String errorKey,
String errorMessage)
Validate integer.
|
protected void |
validateLong(int index,
long min,
long max,
String errorKey,
String errorMessage)
Validate long for urlPara.
|
protected void |
validateLong(int index,
String errorKey,
String errorMessage)
Validate long for urlPara.
|
protected void |
validateLong(String field,
long min,
long max,
String errorKey,
String errorMessage)
Validate long.
|
protected void |
validateLong(String field,
String errorKey,
String errorMessage)
Validate long.
|
protected void |
validateRegex(String field,
String regExpression,
boolean isCaseSensitive,
String errorKey,
String errorMessage)
Validate regular expression.
|
protected void |
validateRegex(String field,
String regExpression,
String errorKey,
String errorMessage)
Validate regular expression and case sensitive.
|
protected void |
validateRequired(int index,
String errorKey,
String errorMessage)
Validate Required for urlPara.
|
protected void |
validateRequired(String field,
String errorKey,
String errorMessage)
Validate Required.
|
protected void |
validateRequiredString(int index,
String errorKey,
String errorMessage)
Validate required string for urlPara.
|
protected void |
validateRequiredString(String field,
String errorKey,
String errorMessage)
Validate required string.
|
protected void |
validateString(int index,
int minLen,
int maxLen,
String errorKey,
String errorMessage)
Validate string for urlPara
|
protected void |
validateString(String field,
int minLen,
int maxLen,
String errorKey,
String errorMessage)
Validate string.
|
protected void |
validateToken(String errorKey,
String errorMessage)
Validate token created by Controller.createToken().
|
protected void |
validateToken(String tokenName,
String errorKey,
String errorMessage)
Validate token created by Controller.createToken(String).
|
protected void |
validateUrl(String field,
String errorKey,
String errorMessage)
Validate URL.
|
protected Controller controller
protected Invocation invocation
protected boolean shortCircuit
protected boolean invalid
protected String datePattern
protected static final String DEFAULT_DATE_PATTERN
protected static final String emailAddressPattern
protected void setShortCircuit(boolean shortCircuit)
shortCircuit
- true 表示短路型验证protected void setDatePattern(String datePattern)
protected String getDatePattern()
public final void intercept(Invocation invocation)
intercept
in interface Interceptor
protected abstract void validate(Controller c)
protected abstract void handleError(Controller c)
protected void addError(String errorKey, String errorMessage)
protected Controller getController()
protected String getActionKey()
protected String getControllerKey()
protected Method getActionMethod()
protected String getActionMethodName()
protected String getViewPath()
protected void validateRequired(String field, String errorKey, String errorMessage)
protected void validateRequired(int index, String errorKey, String errorMessage)
protected void validateRequiredString(String field, String errorKey, String errorMessage)
protected void validateRequiredString(int index, String errorKey, String errorMessage)
protected void validateInteger(String field, int min, int max, String errorKey, String errorMessage)
protected void validateInteger(int index, int min, int max, String errorKey, String errorMessage)
protected void validateInteger(String field, String errorKey, String errorMessage)
protected void validateInteger(int index, String errorKey, String errorMessage)
protected void validateLong(String field, long min, long max, String errorKey, String errorMessage)
protected void validateLong(int index, long min, long max, String errorKey, String errorMessage)
protected void validateLong(String field, String errorKey, String errorMessage)
protected void validateLong(int index, String errorKey, String errorMessage)
protected void validateDouble(String field, double min, double max, String errorKey, String errorMessage)
protected void validateDouble(String field, String errorKey, String errorMessage)
protected void validateDate(String field, String errorKey, String errorMessage)
protected void validateDate(String field, Date min, Date max, String errorKey, String errorMessage)
protected void validateDate(String field, String min, String max, String errorKey, String errorMessage)
protected void validateEqualField(String field_1, String field_2, String errorKey, String errorMessage)
protected void validateEqualString(String s1, String s2, String errorKey, String errorMessage)
protected void validateEqualInteger(Integer i1, Integer i2, String errorKey, String errorMessage)
protected void validateEmail(String field, String errorKey, String errorMessage)
protected void validateUrl(String field, String errorKey, String errorMessage)
protected void validateRegex(String field, String regExpression, boolean isCaseSensitive, String errorKey, String errorMessage)
protected void validateRegex(String field, String regExpression, String errorKey, String errorMessage)
protected void validateString(String field, int minLen, int maxLen, String errorKey, String errorMessage)
protected void validateString(int index, int minLen, int maxLen, String errorKey, String errorMessage)
protected void validateToken(String tokenName, String errorKey, String errorMessage)
protected void validateToken(String errorKey, String errorMessage)
protected void validateBoolean(String field, String errorKey, String errorMessage)
protected void validateBoolean(int index, String errorKey, String errorMessage)
Copyright © 2018. All rights reserved.