|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgoodies.validation.util.PropertyValidationSupport
public class PropertyValidationSupport
A utility class that minimizes the effort to create instances
of PropertyValidationMessage
in validation code.
You can use an instance of this class as a member field of your
validator implementation and delegate the message creation to it.
PropertyValidationMessage
Constructor Summary | |
---|---|
PropertyValidationSupport(Object target,
String role)
Constructs a PropertyValidationSupport instance for the
given validation target and its validation role. |
|
PropertyValidationSupport(Severity defaultSeverity,
Object target,
String role)
Constructs a PropertyValidationSupport instance for the
given validation target and its validation role. |
|
PropertyValidationSupport(ValidationResult defaultResult,
Severity defaultSeverity,
Object target,
String role)
Constructs a PropertyValidationSupport instance for the
given default result, default severity, validation target and the given
validation role. |
Method Summary | |
---|---|
void |
add(Severity severity,
String property,
String text)
Adds a PropertyValidationMessage to this object's
default ValidationResult . |
void |
add(String property,
String text)
Adds a PropertyValidationMessage to this object's
default ValidationResult . |
void |
add(ValidationResult result,
Severity severity,
String property,
String text)
Adds a PropertyValidationMessage to the specified
ValidationResult . |
void |
add(ValidationResult result,
String property,
String text)
Adds a PropertyValidationMessage to the specified
ValidationResult . |
void |
addError(String property,
String text)
Adds an error PropertyValidationMessage to this object's
default ValidationResult . |
void |
addError(ValidationResult result,
String property,
String text)
Adds an error PropertyValidationMessage to the specified
ValidationResult . |
void |
addWarning(String property,
String text)
Adds a warning PropertyValidationMessage to this object's
default ValidationResult . |
void |
addWarning(ValidationResult result,
String property,
String text)
Adds a warning PropertyValidationMessage to the specified
ValidationResult . |
void |
clearResult()
Sets an empty ValidationResult as default result. |
PropertyValidationMessage |
create(Severity severity,
String property,
String text)
Creates and returns an error PropertyValidationMessage
for the given property and message text using the specified severity. |
PropertyValidationMessage |
create(String property,
String text)
Creates and returns a PropertyValidationMessage
for the given property and message text using the default severity. |
PropertyValidationMessage |
createError(String property,
String text)
Creates and returns an error PropertyValidationMessage
for the given property and message text. |
PropertyValidationMessage |
createWarning(String property,
String text)
Creates and returns a warning PropertyValidationMessage
for the given property and message text. |
ValidationResult |
getResult()
Returns the default ValidationResult . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PropertyValidationSupport(Object target, String role)
PropertyValidationSupport
instance for the
given validation target and its validation role. The default severity
is set to Severity.WARNING
.
target
- the object to be validatedrole
- the validation target's role in the outer context
NullPointerException
- if the target or role is null
public PropertyValidationSupport(Severity defaultSeverity, Object target, String role)
PropertyValidationSupport
instance for the
given validation target and its validation role.
defaultSeverity
- the optional Severity
used for
message creation when no severity is specifiedtarget
- the object to be validatedrole
- the validation target's role in the outer context
NullPointerException
- if the target or role is null
IllegalArgumentException
- if defaultSeverity is Severity.OK
public PropertyValidationSupport(ValidationResult defaultResult, Severity defaultSeverity, Object target, String role)
PropertyValidationSupport
instance for the
given default result, default severity, validation target and the given
validation role.
defaultResult
- the optional ValidationResult
that is used to add ValidationMessage
s todefaultSeverity
- the optional Severity
used for
message creation when no severity is specifiedtarget
- the object to be validatedrole
- the validation target's role in the outer context
NullPointerException
- if the target or role is null
IllegalArgumentException
- if defaultSeverity
is OK
Method Detail |
---|
public final void clearResult()
ValidationResult
as default result.
Useful at the begin of a validation sequence.
public final ValidationResult getResult()
ValidationResult
.
public final PropertyValidationMessage createError(String property, String text)
PropertyValidationMessage
for the given property and message text.
property
- describes the validated propertytext
- the message text
PropertyValidationMessage
with error severity
for the given property and textpublic final PropertyValidationMessage createWarning(String property, String text)
PropertyValidationMessage
for the given property and message text.
property
- describes the validated propertytext
- the message text
PropertyValidationMessage
with warning severity
for the given property and textpublic final PropertyValidationMessage create(String property, String text)
PropertyValidationMessage
for the given property and message text using the default severity.
property
- describes the validated propertytext
- the message text
PropertyValidationMessage
with default severity
for the given property and textpublic PropertyValidationMessage create(Severity severity, String property, String text)
PropertyValidationMessage
for the given property and message text using the specified severity.
Subclasses can override this method to return a custom subclass
of PropertyValidationMessage.
severity
- the Severity
to be usedproperty
- describes the validated propertytext
- the message text
PropertyValidationMessage
with the specified severity
for the given property and text
IllegalArgumentException
- if severity
is OK
public final void addError(String property, String text)
PropertyValidationMessage
to this object's
default ValidationResult
.
Uses the given property and message text.
property
- describes the validated propertytext
- the message textpublic final void addWarning(String property, String text)
PropertyValidationMessage
to this object's
default ValidationResult
.
Uses the given property and message text.
property
- describes the validated propertytext
- the message textpublic final void add(String property, String text)
PropertyValidationMessage
to this object's
default ValidationResult
.
Uses the default severity and the given property and message text.
property
- describes the validated propertytext
- the message textpublic final void add(Severity severity, String property, String text)
PropertyValidationMessage
to this object's
default ValidationResult
. Uses the specified
Severity
and given property and message text.
severity
- the Severity
to be usedproperty
- describes the validated propertytext
- the message textpublic final void addError(ValidationResult result, String property, String text)
PropertyValidationMessage
to the specified
ValidationResult
.
Uses the given property and message text.
result
- the result the message will be added toproperty
- describes the validated propertytext
- the message textpublic final void addWarning(ValidationResult result, String property, String text)
PropertyValidationMessage
to the specified
ValidationResult
.
Uses the given property and message text.
result
- the result the message will be added toproperty
- describes the validated propertytext
- the message textpublic final void add(ValidationResult result, String property, String text)
PropertyValidationMessage
to the specified
ValidationResult
. Uses this object's default severity
and the given property and message text.
result
- the result the message will be added toproperty
- describes the validated propertytext
- the message textpublic final void add(ValidationResult result, Severity severity, String property, String text)
PropertyValidationMessage
to the specified
ValidationResult
. Uses the specified severity
and the given property and message text.
result
- the result the message will be added toseverity
- the severity used for the created messageproperty
- describes the validated propertytext
- the message text
IllegalArgumentException
- if severity
is OK
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |