org.millstone.base.data
Interface Validatable

All Known Subinterfaces:
BufferedValidatable
All Known Implementing Classes:
AbstractField

public interface Validatable

Interface for validatable objects. Defines methods to verify if the object's value is valid or not, and to add, remove and list registered validators of the object.

Since:
3.0
Version:
3.0.3
Author:
IT Mill Ltd.
See Also:
Validator

Method Summary
 void addValidator(Validator validator)
          Adds a new validator for this object.
 java.util.Collection getValidators()
          List all validators currently registered for the object.
 boolean isInvalidAllowed()
          Does the validabtable object accept invalid values.
 boolean isValid()
          Tests the current value of the object against all registered validators.
 void removeValidator(Validator validator)
          Removes a previously registered validator from the object.
 void setInvalidAllowed(boolean invalidValueAllowed)
          Should the validabtable object accept invalid values.
 void validate()
          Checks the validity of the validatable.
 

Method Detail

addValidator

public void addValidator(Validator validator)
Adds a new validator for this object. The validator's Validator.validate(Object) method is activated every time the object's value needs to be verified, that is, when the isValid() method is called. This usually happens when the object's value changes.

Parameters:
validator - the new validator

removeValidator

public void removeValidator(Validator validator)
Removes a previously registered validator from the object. The specified validator is removed from the object and its validate method is no longer called in isValid().

Parameters:
validator - the validator to remove

getValidators

public java.util.Collection getValidators()
List all validators currently registered for the object. If no validators are registered, returns null.

Returns:
collection of validators or null

isValid

public boolean isValid()
Tests the current value of the object against all registered validators. The registered validators are iterated and for each the Validator.validate(Object) method is called. If any validator throws the Validator.InvalidValueException this method returns false.

Returns:
true if the registered validators concur that the value is valid, false otherwise

validate

public void validate()
              throws Validator.InvalidValueException
Checks the validity of the validatable. If the validatable is valid this method should do nothing, and if it's not valid, it should throw Validator.InvalidValueException

Throws:
Validator.InvalidValueException - if the value is not valid

isInvalidAllowed

public boolean isInvalidAllowed()
Does the validabtable object accept invalid values. The default is true.


setInvalidAllowed

public void setInvalidAllowed(boolean invalidValueAllowed)
                       throws java.lang.UnsupportedOperationException
Should the validabtable object accept invalid values. Supporting this configuration possibility is optional. By default invalid values are alloved.

java.lang.UnsupportedOperationException


Copyright © 2000,2001,2002 IT Mill Ltd. All Rights Reserved.