public class PropertyValidationSupport extends Object
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 and Description |
---|
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. |
Modifier and Type | Method and Description |
---|---|
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 . |
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 contextNullPointerException
- 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 contextNullPointerException
- 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 contextNullPointerException
- if the target or role is null
IllegalArgumentException
- if defaultSeverity
is OK
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 textPropertyValidationMessage
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 textPropertyValidationMessage
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 textPropertyValidationMessage
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 textPropertyValidationMessage
with the specified severity
for the given property and textIllegalArgumentException
- 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 textIllegalArgumentException
- if severity
is OK
Copyright © 2003-2011 JGoodies Karsten Lentzsch. All Rights Reserved.