|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.uwyn.rife.site.Validation<B,P>
public class Validation<B extends ConstrainedBean,P extends ConstrainedProperty>
| Constructor Summary | |
|---|---|
Validation()
|
|
| Method Summary | |
|---|---|
protected void |
activateValidation()
This method is called at least once and maximum once when any method related to Validated rules, subjects and group or Constrained properties are used. |
List<PropertyValidationRule> |
addConstrainedPropertyRules(P constrainedProperty)
Adds the validation rules that are related to a particular ConstrainedProperty. |
void |
addConstraint(B constrainedBean)
Add a new constrained bean. |
void |
addConstraint(P constrainedProperty)
Add a new constrained property. |
ValidationGroup<P> |
addGroup(String name)
Adds a new validation group. |
void |
addRule(ValidationRule rule)
Adds a new validation rule. |
void |
addValidationError(ValidationError newError)
Add a new validation error explicitly to the collection of already existing errors. |
Object |
clone()
|
void |
constraintSet(ConstrainedProperty property,
String name,
Object constraintData)
This method is called on a registered listener when a constraint has been set to a particular value. |
int |
countValidationErrors()
Counts the number of stored ValidationErrors. |
void |
focusGroup(String name)
Focuses on one particular validation group, showing only the ValidationErrors that were generated by its
ValidationRules. |
List<PropertyValidationRule> |
generateConstrainedPropertyRules(P constrainedProperty)
Generates the validation rules that are related to a particular ConstrainedProperty. |
B |
getConstrainedBean()
Retrieves the constrained bean that has been set for this Constrained instance. |
Collection<P> |
getConstrainedProperties()
Returns a collection with all the constrained properties that have been registered. |
P |
getConstrainedProperty(String propertyName)
Retrieve a registered ConstrainedProperty according to
its name. |
static String |
getErrorIndication(Validated validated,
String subject,
String valid,
String error)
|
ValidationGroup<P> |
getGroup(String name)
Retrieve a particular validation group. |
Collection<ValidationGroup<P>> |
getGroups()
Retrieves all validation groups. |
Collection<String> |
getLoadingErrors(String propertyName)
Returns the collection of error messages that occurred during the loading of the content of a certain property. |
List<ValidationRule> |
getRules()
Retrieves that validation rules that have been registered. |
List<String> |
getValidatedSubjects()
Returns the list of subjects that this object is able to validate internally through the validate() method. |
Set<ValidationError> |
getValidationErrors()
Returns a set with all the stored ValidationErrors. |
boolean |
hasPropertyConstraint(String name)
Indicates whether this constrained bean contains a particular constraint on at least one of its properties. |
boolean |
isSubjectValid(String subject)
Checks if a subject is valid. |
void |
limitSubjectErrors(String subject)
Limits the number of errors for a particular subject so that maximum one ValidationError can be stored for it. |
void |
makeErrorValid(String identifier,
String subject)
Makes errors for a particular subject and identifier valid. |
void |
makeSubjectValid(String subject)
Makes a subject valid. |
void |
provideValidatedBean(Validated bean)
Provide the bean instance that will be validated. |
void |
replaceValidationErrors(Set<ValidationError> errors)
Replaces the stored ValidationErrors with a new set of
errors. |
void |
resetGroup(String name)
Removed all the ValidationErrors of a particular
validation group. |
void |
resetValidation()
Resets the validation by removing all validation errors that are currently present. |
Validated |
retrieveValidatedBean()
Retrieves the bean instance that will be validated. |
void |
unlimitSubjectErrors(String subject)
Unlimits the number of errors for a particular subject so that any number of ValidationErrors can be stored for it. |
boolean |
validate()
Validates the internal subjects. |
boolean |
validate(ValidationContext context)
Validates the internal subjects and also validates the bean within the provided ValidationContext |
boolean |
validateGroup(String name)
Validate the ValidationRules of a particular validation
group. |
boolean |
validateGroup(String name,
ValidationContext context)
Validate the ValidationRules of a particular validation
group and also validates the entire bean within the provided
ValidationContext |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Validation()
| Method Detail |
|---|
protected void activateValidation()
By overriding this method, you can thus isolate all the validation setup code code and don't enforce a performance penalty at each object construction when doing it in the default constructor.
public void provideValidatedBean(Validated bean)
ValidatedBy default 'this' will be used.
provideValidatedBean in interface Validatedbean - the bean instance that will be validatedpublic Validated retrieveValidatedBean()
Validated
retrieveValidatedBean in interface Validatedpublic ValidationGroup<P> addGroup(String name)
ValidatedConstrained
addGroup in interface ValidatedConstrained<P extends ConstrainedProperty>name - the name of the validation group that needs to be created
and added
ValidationGrouppublic void focusGroup(String name)
ValidatedConstrainedValidationErrors that were generated by its
ValidationRules.
focusGroup in interface ValidatedConstrained<P extends ConstrainedProperty>name - the name of the validation group that will be focusedpublic void resetGroup(String name)
ValidatedConstrainedValidationErrors of a particular
validation group.
resetGroup in interface ValidatedConstrained<P extends ConstrainedProperty>name - the name of the validation group that will be focusedpublic void addRule(ValidationRule rule)
ValidatedAdds a new validation rule.
The collection of rules is what is supposed to perform the validation, though any other additional method could be used. At least those rules that have been registered will be evaluated.
addRule in interface Validatedrule - the rule that will be addedValidated.validate(),
Validated.getRules()public List<PropertyValidationRule> generateConstrainedPropertyRules(P constrainedProperty)
ValidatedConstrainedConstrainedProperty.
generateConstrainedPropertyRules in interface ValidatedConstrained<P extends ConstrainedProperty>constrainedProperty - the ConstrainedProperty that will be
inspected
ValidationRulespublic List<PropertyValidationRule> addConstrainedPropertyRules(P constrainedProperty)
ValidatedConstrainedConstrainedProperty.
If the rules of this property name have already been added before
through another ConstrainedProperty instance, its existing
ValidationRules will be erased and the previous
constraints will be merged into the new
ConstrainedProperty before adding its validation rules.
addConstrainedPropertyRules in interface ValidatedConstrained<P extends ConstrainedProperty>constrainedProperty - the ConstrainedProperty that will be
inspected
ValidationRulespublic void addConstraint(P constrainedProperty)
ConstrainedWhen several of the same constrained properties are added, they are merged at constraint-level. This means for instance that a previous inList constraint will be replaced by the one of the new constrained bean, they will not be combined.
addConstraint in interface Constrained<B extends ConstrainedBean,P extends ConstrainedProperty>constrainedProperty - the ConstrainedProperty
instance that has to be addedConstrainedPropertypublic void addConstraint(B constrainedBean)
ConstrainedWhen several constrained beans are added, they are merged at constraint-level. This means for instance that all previous unique constraints will be replaced by those of the new constrained bean, they will not be combined.
addConstraint in interface Constrained<B extends ConstrainedBean,P extends ConstrainedProperty>constrainedBean - the ConstrainedBean instance
that has to be addedConstrainedBeanpublic void addValidationError(ValidationError newError)
ValidatedNote that this method should respect subjects with a limited error amount and only store the first error for these subjects.
addValidationError in interface ValidatednewError - the ValidationError to addValidated.limitSubjectErrors(String),
Validated.unlimitSubjectErrors(String)public List<ValidationRule> getRules()
Validated
getRules in interface ValidatedValidated.validate(),
Validated.addRule(com.uwyn.rife.site.ValidationRule)public Collection<P> getConstrainedProperties()
Constrained
getConstrainedProperties in interface Constrained<B extends ConstrainedBean,P extends ConstrainedProperty>Collection with all the
ConstrainedProperty objects that are registered. If no
constrained properties are available, an empty collection will be
returned, not null.ConstrainedPropertypublic boolean hasPropertyConstraint(String name)
Constrained
hasPropertyConstraint in interface Constrained<B extends ConstrainedBean,P extends ConstrainedProperty>true if this constraint is present on at least one
of the properties; or
false otherwise
ConstrainedPropertypublic P getConstrainedProperty(String propertyName)
ConstrainedConstrainedProperty according to
its name.
getConstrainedProperty in interface Constrained<B extends ConstrainedBean,P extends ConstrainedProperty>propertyName - the name of the
ConstrainedProperty that has to be retrieved
ConstrainedProperty; or
null if no such ConstrainedProperty is
available.
ConstrainedPropertypublic Collection<ValidationGroup<P>> getGroups()
ValidatedConstrained
getGroups in interface ValidatedConstrained<P extends ConstrainedProperty>public ValidationGroup<P> getGroup(String name)
ValidatedConstrained
getGroup in interface ValidatedConstrained<P extends ConstrainedProperty>name - the name of the validation group that will be retrieved
ValidationGroup; or
null if no such validation group exists
public B getConstrainedBean()
ConstrainedConstrained instance.
getConstrainedBean in interface Constrained<B extends ConstrainedBean,P extends ConstrainedProperty>ConstrainedBean; or
null if no ConstrainedBean is
available.
ConstrainedPropertypublic boolean validate()
ValidatedThis method is not suppossed to reset the validation errors or to start the validation from scratch, but it's intended to add additional errors to an existing collection.
validate in interface Validatedtrue if no validation errors are present after the
validation; or
false if validation errors are available.
Validated.validate(ValidationContext),
Validated.resetValidation()public boolean validate(ValidationContext context)
ValidatedValidationContext
This method is not suppossed to reset the validation errors or to start the validation from scratch, but it's intended to add additional errors to an existing collection.
validate in interface Validatedcontext - the ValidationContext in which this bean
instance will be additionally validated
true if no validation errors are present after the
validation; or
false if validation errors are available.
Validated.validate(),
Validated.resetValidation()public boolean validateGroup(String name)
ValidatedConstrainedValidationRules of a particular validation
group.
validateGroup in interface ValidatedConstrained<P extends ConstrainedProperty>name - the name of the validation group that will be retrieved
true if no validation errors were generated; or
false otherwise
public boolean validateGroup(String name,
ValidationContext context)
ValidatedConstrainedValidationRules of a particular validation
group and also validates the entire bean within the provided
ValidationContext
validateGroup in interface ValidatedConstrained<P extends ConstrainedProperty>name - the name of the validation groupcontext - the ValidationContext in which this bean
instance will be additionally validated
true if no validation errors were generated; or
false otherwise
public int countValidationErrors()
ValidatedValidationErrors.
countValidationErrors in interface ValidatedValidationErrors.public void resetValidation()
ValidatedResets the validation by removing all validation errors that are currently present.
This method is typically used to start a new validation from scratch or to re-validate until all errors have been solved.
resetValidation in interface ValidatedValidated.validate()public Set<ValidationError> getValidationErrors()
ValidatedValidationErrors.
getValidationErrors in interface ValidatedSet instance with all the stored
ValidationErrors. Note that when no errors are available
an empty set is returned, not null.public void replaceValidationErrors(Set<ValidationError> errors)
ValidatedValidationErrors with a new set of
errors.
replaceValidationErrors in interface Validatederrors - the Set instance that contains all the
ValidationErrors that have to be stored.public void limitSubjectErrors(String subject)
ValidatedValidationError can be stored for it.
limitSubjectErrors in interface Validatedsubject - the name of the subject that has to be limited.public void unlimitSubjectErrors(String subject)
ValidatedValidationErrors can be stored for it.
unlimitSubjectErrors in interface Validatedsubject - the name of the subject that has to be unlimited.public boolean isSubjectValid(String subject)
ValidatedThis is determined by verifying if there are
ValidationErrors present for it. This method will thus not
execute a validation action.
isSubjectValid in interface Validatedsubject - the name of the subject that has to be checked.
true when no errors could be found for the
subject; or
false when errors are present for the subject.
Validated.validate()public void makeSubjectValid(String subject)
ValidatedThis is done by removing all ValidationErrors that are
stored for it.
makeSubjectValid in interface Validatedsubject - the name of the subject that has to be made valid.
public void makeErrorValid(String identifier,
String subject)
ValidatedThis is done by removing all ValidationErrors that are
stored with this identifier and subject.
makeErrorValid in interface Validatedidentifier - the name of the error identifier that has to be madesubject - the name of the subject that has to be made valid.
valid.public List<String> getValidatedSubjects()
Validatedvalidate() method.
getValidatedSubjects in interface Validated
public static String getErrorIndication(Validated validated,
String subject,
String valid,
String error)
public Collection<String> getLoadingErrors(String propertyName)
ValidatedConstrained
getLoadingErrors in interface ValidatedConstrained<P extends ConstrainedProperty>propertyName - the name of the property whose loading errors
should be obtained
the requested collection of error messages
public void constraintSet(ConstrainedProperty property,
String name,
Object constraintData)
ConstrainedPropertyListener
constraintSet in interface ConstrainedPropertyListenerproperty - the ConstrainedProperty instance where the
constraint has been setname - the name of the constraintconstraintData - the data that the constraint has been set to
public Object clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||