| java.lang.Object com.jgoodies.validation.ValidationResult
ValidationResult | final public class ValidationResult implements Serializable(Code) | | Describes a validation result as a list of ValidationMessages.
You can add single validation messages, single text messages,
lists of messages, and all messages from another ValidationResult.
author: Karsten Lentzsch version: $Revision: 1.16 $ See Also: ValidationMessage See Also: Validator |
Field Summary | |
final public static ValidationResult | EMPTY A constant for an empty and unmodifiable validation result. |
Constructor Summary | |
public | ValidationResult() Constructs an empty modifiable ValidationResult. |
Method Summary | |
public void | add(ValidationMessage validationMessage) Adds a new ValidationMessage to the list of messages. | public void | addAll(List<ValidationMessage> messages) Adds all messages from the given list to this validation result. | public void | addAllFrom(ValidationResult validationResult) Adds all messages from the given ValidationResult
to the list of messages that this validation result holds. | public void | addError(String text) Creates and adds an error message to the list of validation messages
using the given text. | public void | addWarning(String text) Creates and adds a warning message to the list of validation messages
using the given text. | public boolean | contains(ValidationMessage message) Checks and answers whether this result contains the specified message. | public boolean | equals(Object o) Compares the specified object with this validation result for equality.
Returns true if and only if the specified object is also
a validation result, both results have the same size, and all
corresponding pairs of validation messages in the two validation results
are equal. | public List<ValidationMessage> | getErrors() Returns an unmodifiable List of the validation messages
that indicate errors. | public List<ValidationMessage> | getMessages() Returns an unmodifiable List of all validation messages. | public String | getMessagesText() Returns a string representation of the message list. | public Severity | getSeverity() Returns the highest severity of this result's messages,
Severity.OK if there are no messages. | public List<ValidationMessage> | getWarnings() Returns an unmodifiable List of the validation messages
that indicate warnings. | public boolean | hasErrors() Checks and answers whether this validation result
contains a message of type ERROR . | public boolean | hasMessages() Checks and answers whether this validation result has messages or not. | public boolean | hasWarnings() Checks and answers whether this validation result
contains a message of type WARNING .
Note that this method checks for warning messages only. | public int | hashCode() Returns the hash code value for this validation result. | public boolean | isEmpty() Checks and answers whether this validation result contains no messages. | public boolean | isModifiable() Returns if this validation result is modifiable or not. | public Map<Object, ValidationResult> | keyMap() Creates and returns an unmodifiable Map that maps the message keys
of this validation result to unmodifiable sub results that share the key.
More formally:
for each key key in the created map map ,
map.get(key) returns a ValidationResult
result , such that for each ValidationMessage
message in result we have:
message.key().equals(key) . | public int | size() Returns the number of messages in this result. | public ValidationResult | subResult(int fromIndex, int toIndex) Returns an unmodifiable view of the portion of this result between
the specified fromIndex , inclusive, and toIndex ,
exclusive. | public ValidationResult | subResult(Object messageKey) Returns an unmodifiable sub result of this result that consists of
all messages that share the specified message key. | public ValidationResult | subResult(Object[] messageKeys) Returns an unmodifiable sub result of this result that consists of
all messages that share the specified message keys. | public String | toString() Returns a string representation intended for debugging purposes. | public static ValidationResult | unmodifiableResult(ValidationResult validationResult) Returns an unmodifiable view of the given ValidationResult.
Useful to provide users with "read-only" access to internal results,
or to indicate to other validation result processors that a result
is not intended to be modified. |
EMPTY | final public static ValidationResult EMPTY(Code) | | A constant for an empty and unmodifiable validation result.
|
ValidationResult | public ValidationResult()(Code) | | Constructs an empty modifiable ValidationResult.
|
contains | public boolean contains(ValidationMessage message)(Code) | | Checks and answers whether this result contains the specified message.
More formally, returns true if and only if this result
contains at least one message m such that
(message.equals(m)) .
Parameters: message - message whose presence in this result is to be tested true if this result contains the specified message throws: NullPointerException - if the specified message isnull |
equals | public boolean equals(Object o)(Code) | | Compares the specified object with this validation result for equality.
Returns true if and only if the specified object is also
a validation result, both results have the same size, and all
corresponding pairs of validation messages in the two validation results
are equal. (Two validation messages m1 and
m2 are equal if (m1==null ? m2==null :
m1.equals(m2)) .) In other words, two validation results
are defined to be equal if and only if they contain the same
validation messages in the same order.
This implementation first checks if the specified object is this
validation result. If so, it returns true ;
if not, it checks if the specified object is a validation result.
If not, it returns false ; if so, it checks and returns
if the lists of messages in both results are equal.
Parameters: o - the object to be compared for equality with this validation result. true if the specified object is equalto this validation result. See Also: List.equals(java.lang.Object) See Also: Object.equals(java.lang.Object) |
getMessagesText | public String getMessagesText()(Code) | | Returns a string representation of the message list.
a string representation of the message list |
hasWarnings | public boolean hasWarnings()(Code) | | Checks and answers whether this validation result
contains a message of type WARNING .
Note that this method checks for warning messages only.
It'll return false, if there are errors but no warnings.
If you want to test whether this result contains
warning and/or errors, use #hasMessages instead.
true if there are warnings, false if not See Also: ValidationResult.getSeverity() See Also: ValidationResult.hasMessages() See Also: ValidationResult.hasErrors() |
hashCode | public int hashCode()(Code) | | Returns the hash code value for this validation result. This
implementation returns the hash from the List of messages.
the hash code value for this validation result. See Also: List.hashCode See Also: Object.hashCode |
isModifiable | public boolean isModifiable()(Code) | | Returns if this validation result is modifiable or not.
Can be used to cache data from unmodifiable result.
true if modifiable, false if unmodifiable |
keyMap | public Map<Object, ValidationResult> keyMap()(Code) | | Creates and returns an unmodifiable Map that maps the message keys
of this validation result to unmodifiable sub results that share the key.
More formally:
for each key key in the created map map ,
map.get(key) returns a ValidationResult
result , such that for each ValidationMessage
message in result we have:
message.key().equals(key) .
a mapping from message key to an associated validation resultthat consist only of messages with this key See Also: ValidationMessage.key |
size | public int size()(Code) | | Returns the number of messages in this result.
the number of elements in this list |
subResult | public ValidationResult subResult(int fromIndex, int toIndex)(Code) | | Returns an unmodifiable view of the portion of this result between
the specified fromIndex , inclusive, and toIndex ,
exclusive.
(If fromIndex and toIndex are equal,
the returned result is empty.) The returned result is a copy,
so changes in the returned result won't affect this result,
and vice-versa.
Parameters: fromIndex - low end point (inclusive) of the subResult Parameters: toIndex - high end point (exclusive) of the subResult a view of the specified range within this result. throws: IndexOutOfBoundsException - for an illegal end point index value(fromIndex < 0 || toIndex > size || fromIndex > toIndex). See Also: ValidationResult.subResult(Object) |
subResult | public ValidationResult subResult(Object messageKey)(Code) | | Returns an unmodifiable sub result of this result that consists of
all messages that share the specified message key. If the specified key
is null , this method returns an empty result.
The returned result is a copy, so changes in this result won't affect it.
Parameters: messageKey - the key to look for, can be null a sub result containing all messages that share thespecified key, or the empty result if the key is null See Also: ValidationResult.subResult(int,int) |
subResult | public ValidationResult subResult(Object[] messageKeys)(Code) | | Returns an unmodifiable sub result of this result that consists of
all messages that share the specified message keys. If the array of keys
is null , this method returns an empty result.
The returned result is a copy, so changes in this result won't affect it.
Parameters: messageKeys - the keys to look for, can be null a sub result containing all messages that share the specifiedkeys, or the empty result if the key array is null See Also: ValidationResult.subResult(int,int) since: 1.4 |
toString | public String toString()(Code) | | Returns a string representation intended for debugging purposes.
a string representation intended for debugging See Also: Object.toString |
unmodifiableResult | public static ValidationResult unmodifiableResult(ValidationResult validationResult)(Code) | | Returns an unmodifiable view of the given ValidationResult.
Useful to provide users with "read-only" access to internal results,
or to indicate to other validation result processors that a result
is not intended to be modified. Attempts to modify the returned
validation result throw an UnsupportedOperationException .
Parameters: validationResult - the result for which an unmodifiable view is to be returned an unmodifiable view of the specified validation result |
|
|