com.jgoodies.validation.extras
Class DelayedValidationResultModel

java.lang.Object
  extended by com.jgoodies.common.bean.AbstractBean
      extended by com.jgoodies.validation.util.AbstractValidationResultModel
          extended by com.jgoodies.validation.extras.DelayedValidationResultModel
All Implemented Interfaces:
com.jgoodies.common.bean.ObservableBean, com.jgoodies.common.bean.ObservableBean2, ValidationResultModel, Serializable

public final class DelayedValidationResultModel
extends AbstractValidationResultModel

A ValidationResultModel that defers changes for a specified delay. Useful to coalesce frequent validation result changes. For example if a validation requires some heavy computation, you may desire to perform the validation only for a "stable" input state after a series of quick input changes.

Wraps a given subject ValidationResultModel and returns the subject ValidationResult or the ValidationResult to be set as this model's result. Observes subject validation result property changes and forwards them to listeners of this model. If a ValidationResult is set to this model, a Swing Timer is used to delay the ValidationResult commit to the subject. A previously started timer - if any - will be stopped before.

Version:
$Revision: 1.12 $
Author:
Karsten Lentzsch
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.jgoodies.common.bean.AbstractBean
changeSupport
 
Fields inherited from interface com.jgoodies.validation.ValidationResultModel
PROPERTY_ERRORS, PROPERTY_MESSAGES, PROPERTY_RESULT, PROPERTY_SEVERITY, PROPERTYNAME_ERRORS, PROPERTYNAME_MESSAGES, PROPERTYNAME_RESULT, PROPERTYNAME_SEVERITY
 
Constructor Summary
DelayedValidationResultModel(ValidationResultModel subject, int delay)
          Constructs a DelayedValidationResultModel for the given subject ValidationResultModel and the specified Timer delay in milliseconds.
 
Method Summary
 ValidationResult getResult()
          Returns the subject's value or in case of a pending commit, the pending new value.
 void setResult(ValidationResult newResult)
          Sets the given new value after this model's delay.
 
Methods inherited from class com.jgoodies.validation.util.AbstractValidationResultModel
firePropertyChanges, getSeverity, hasErrors, hasMessages
 
Methods inherited from class com.jgoodies.common.bean.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPropertyChangeSupport, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, fireMultiplePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jgoodies.common.bean.ObservableBean2
addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener
 
Methods inherited from interface com.jgoodies.common.bean.ObservableBean
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

DelayedValidationResultModel

public DelayedValidationResultModel(ValidationResultModel subject,
                                    int delay)
Constructs a DelayedValidationResultModel for the given subject ValidationResultModel and the specified Timer delay in milliseconds.

Parameters:
subject - the underlying (or wrapped) ValidationResultModel
delay - the milliseconds to wait before a change shall be committed
Method Detail

getResult

public ValidationResult getResult()
Returns the subject's value or in case of a pending commit, the pending new value.

Returns:
the subject's current or future value.
See Also:
ValidationResultModel.setResult(ValidationResult)

setResult

public void setResult(ValidationResult newResult)
Sets the given new value after this model's delay. Does nothing if the new value and the latest pending value are the same.

Parameters:
newResult - the value to set
Throws:
NullPointerException - if the new result is null
See Also:
ValidationResultModel.getResult()


Copyright © 2003-2011 JGoodies Karsten Lentzsch. All Rights Reserved.