Package com.jidesoft.validation
Class ValidationResult
- java.lang.Object
-
- com.jidesoft.validation.ValidationResult
-
- Direct Known Subclasses:
RowValidationResult
public class ValidationResult extends java.lang.Object
ValidationResult is the object that returns from theValidator.validating(ValidationObject)
. There are three things on the result.- valid: whether the result is valid. It can be true or false.
- id: an int value of the result. It's better to reserve value 0 for valid result. For invalid result, you can use whatever value as long as it's consistent across your application.
- message: a String value of result. You can use this string value to put a message to indicate why the validation failed.
FAIL_BEHAVIOR_REVERT
, which means JideTable will not accept the new input and just revert the value in the cell to the old value and stop cell editing as normal.
-
-
Field Summary
Fields Modifier and Type Field Description static int
FAIL_BEHAVIOR_PERSIST
When validation fails, do not stop cell editing until user enters a valid value or press ESCAPE to cancel the editing.static int
FAIL_BEHAVIOR_RESET
When validation fails, reset the value to null.static int
FAIL_BEHAVIOR_REVERT
When validation fails, reverts back to the previous valid value and stop cell editting as normal.static java.lang.Object
NULL_VALUE
If you want to change the new value in the validation result to null, please return NULL_VALUE so that JideTable will be able to change it automatically to null after validation.static ValidationResult
OK
The shared ValidationResult when the validation result is valid.
-
Constructor Summary
Constructors Constructor Description ValidationResult()
Creates an empty ValidationResult.ValidationResult(boolean valid)
Creates an empty ValidationResult.ValidationResult(int id)
Creates an invalid ValidationResult with an id and no message.ValidationResult(int id, boolean valid, int failBehavoir)
Creates an ValidationResult with an id and an error behavior.ValidationResult(int id, boolean valid, int failBehavoir, java.lang.String message)
Creates an ValidationResult with an id, a message and an error behavior.ValidationResult(int id, boolean valid, java.lang.String message)
Creates an ValidationResult with an id and a message.ValidationResult(int id, java.lang.String message)
Creates an invalid ValidationResult with an id and a message.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getFailBehavior()
Gets the behavior if validation fails.int
getId()
Gets the id of the ValidationResult.java.lang.String
getMessage()
Gets the message associated with the ValidationResult.java.lang.Object
getNewValue()
Gets the new value of the ValidationResult.boolean
isValid()
Checks if the validation state is valid.void
setFailBehavior(int failBehavior)
Sets the behavior if validation fails.void
setId(int id)
Sets the id of the ValidationResult.void
setMessage(java.lang.String message)
Sets the message associated with the ValidationResult.void
setNewValue(java.lang.Object newValue)
Sets the new value of the ValidationResult.void
setValid(boolean valid)
Sets the validation state.java.lang.String
toString()
-
-
-
Field Detail
-
NULL_VALUE
public static final java.lang.Object NULL_VALUE
If you want to change the new value in the validation result to null, please return NULL_VALUE so that JideTable will be able to change it automatically to null after validation.- Since:
- 3.4.3
-
FAIL_BEHAVIOR_REVERT
public static final int FAIL_BEHAVIOR_REVERT
When validation fails, reverts back to the previous valid value and stop cell editting as normal.- See Also:
- Constant Field Values
-
FAIL_BEHAVIOR_PERSIST
public static final int FAIL_BEHAVIOR_PERSIST
When validation fails, do not stop cell editing until user enters a valid value or press ESCAPE to cancel the editing.- See Also:
- Constant Field Values
-
FAIL_BEHAVIOR_RESET
public static final int FAIL_BEHAVIOR_RESET
When validation fails, reset the value to null.- See Also:
- Constant Field Values
-
OK
public static final ValidationResult OK
The shared ValidationResult when the validation result is valid.getNewValue()
will always return null even if you ever invokedsetNewValue(Object)
to avoid potential wrong value assignment.
-
-
Constructor Detail
-
ValidationResult
public ValidationResult()
Creates an empty ValidationResult. The valid is set to false.
-
ValidationResult
public ValidationResult(int id)
Creates an invalid ValidationResult with an id and no message.- Parameters:
id
- the result id. You can create the id by your definition
-
ValidationResult
public ValidationResult(boolean valid)
Creates an empty ValidationResult.- Parameters:
valid
- a boolean value to indicate if the value input is valid
-
ValidationResult
public ValidationResult(int id, java.lang.String message)
Creates an invalid ValidationResult with an id and a message.- Parameters:
id
- the result id. You can create the id by your definitionmessage
- the message you want to display to the customer
-
ValidationResult
public ValidationResult(int id, boolean valid, java.lang.String message)
Creates an ValidationResult with an id and a message.- Parameters:
id
- the result id. You can create the id by your definitionvalid
- a boolean value to indicate if the value input is validmessage
- the message you want to display to the customer
-
ValidationResult
public ValidationResult(int id, boolean valid, int failBehavoir)
Creates an ValidationResult with an id and an error behavior.- Parameters:
id
- the result id. You can create the id by your definitionvalid
- a boolean value to indicate if the value input is validfailBehavoir
- the behavior
-
ValidationResult
public ValidationResult(int id, boolean valid, int failBehavoir, java.lang.String message)
Creates an ValidationResult with an id, a message and an error behavior.- Parameters:
id
- the result id. You can create the id by your definitionvalid
- a boolean value to indicate if the value input is validfailBehavoir
- the behaviormessage
- the message you want to display to the customer
-
-
Method Detail
-
getId
public int getId()
Gets the id of the ValidationResult.- Returns:
- the id.
-
setId
public void setId(int id)
Sets the id of the ValidationResult.- Parameters:
id
- the result id. You can create the id by your definition
-
getNewValue
public java.lang.Object getNewValue()
Gets the new value of the ValidationResult.- Returns:
- the new value.
-
setNewValue
public void setNewValue(java.lang.Object newValue)
Sets the new value of the ValidationResult.- Parameters:
newValue
- the new value.
-
isValid
public boolean isValid()
Checks if the validation state is valid.- Returns:
- the validation state. True means valid. Otherwise, false.
-
setValid
public void setValid(boolean valid)
Sets the validation state.- Parameters:
valid
- a boolean value to indicate if the value input is valid
-
getMessage
public java.lang.String getMessage()
Gets the message associated with the ValidationResult.- Returns:
- the message.
-
setMessage
public void setMessage(java.lang.String message)
Sets the message associated with the ValidationResult.- Parameters:
message
- the new message.
-
getFailBehavior
public int getFailBehavior()
Gets the behavior if validation fails.- Returns:
- the behavior if validation fails.
-
setFailBehavior
public void setFailBehavior(int failBehavior)
Sets the behavior if validation fails. Valid values areFAIL_BEHAVIOR_PERSIST
,FAIL_BEHAVIOR_REVERT
, andFAIL_BEHAVIOR_RESET
. If you used a constructor without this parameter, the default value for behavior isFAIL_BEHAVIOR_REVERT
, which means JideTable will not accept the new input and just revert the value in the cell to the old value and stop cell editing as normal.- Parameters:
failBehavior
- the behavior
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-