Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.jgoodies.binding.value
Class Trigger

    java.lang.Object
      com.jgoodies.common.bean.AbstractBean
          com.jgoodies.binding.beans.Model
              com.jgoodies.binding.value.AbstractValueModel
                  com.jgoodies.binding.value.Trigger

All Implemented Interfaces:
  ValueModel, com.jgoodies.common.bean.ObservableBean, com.jgoodies.common.bean.ObservableBean2, Serializable

    public final class Trigger

extends AbstractValueModel

A ValueModel implementation that is intended to be used as trigger channel for instances of BufferedValueModel. API users shall trigger commit and flush events using `#triggerCommit` and `#triggerFlush`.

This Trigger class works around an inconvenient situation when using a general ValueHolder as trigger channel of a BufferedValueModel. BufferedValueHolder performs commit and flush events only if the trigger channel value reports a change. And a ValueHolder doesn't report a change if `#setValue` tries to set the current value. For example if you set `Boolean.TRUE` twice, the latter doesn't fire a property change event. The methods `#triggerCommit` and `#triggerFlush` check for the current state and guarantee that the appropriate `PropertyChangeEvent` is fired. On the other hand, the implementation minimizes the number of events necessary to commit or flush buffered values.

Constraints: The value is of type `Boolean`.

The following example delays the commit of a buffered value:

     ValueModel subject = new ValueHolder();
     Trigger trigger = new Trigger();
     BufferedValueModel buffer = new BufferedValueModel(subject, trigger);

     buffer.setValue("value");
     ...
     trigger.triggerCommit();

Version:
  $Revision: 1.10 $
Author:
  Karsten Lentzsch
See Also:
  `BufferedValueModel`, Serialized Form

Field Summary

Fields inherited from class com.jgoodies.binding.value.AbstractValueModel
`PROPERTYNAME_VALUE`

Fields inherited from class com.jgoodies.common.bean.AbstractBean
`changeSupport`

Constructor Summary
`Trigger()` Constructs a Trigger set to neutral.

Method Summary
`Object` | `getValue()` Returns a Boolean that indicates the current trigger state.
`void` | `setValue(Object newValue)` Sets a new Boolean value and rejects all non-Boolean values.
`void` | `triggerCommit()` Triggers a commit event in BufferedValueModels that share this Trigger.
`void` | `triggerFlush()` Triggers a flush event in BufferedValueModels that share this Trigger.

Methods inherited from class com.jgoodies.binding.value.AbstractValueModel
`addValueChangeListener, booleanValue, doubleValue, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, floatValue, getString, intValue, longValue, paramString, removeValueChangeListener, setValue, setValue, setValue, setValue, setValue, toString, valueString`

Methods inherited from class com.jgoodies.binding.beans.Model
`createPropertyChangeSupport, firePropertyChange`

Methods inherited from class com.jgoodies.common.bean.AbstractBean
`addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, 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, wait, wait, wait`

Constructor Detail

### Trigger

    public Trigger()

  Constructs a Trigger set to neutral.

Method Detail

### getValue

    public Object getValue()

  Returns a Boolean that indicates the current trigger state.

  Returns:
    a Boolean that indicates the current trigger state

### setValue

    public void setValue(Object newValue)

  Sets a new Boolean value and rejects all non-Boolean values. Fires no change event if the new value is equal to the previously set value.

  This method is not intended to be used by API users. Instead you should trigger commit and flush events by invoking `#triggerCommit` or `#triggerFlush`.

  Parameters:
    `newValue` - the Boolean value to be set
  Throws:
    `IllegalArgumentException` - if the newValue is not a Boolean

### triggerCommit

    public void triggerCommit()

  Triggers a commit event in BufferedValueModels that share this Trigger. Sets the value to `Boolean.TRUE` and ensures that listeners are notified about a value change to this new value. If necessary the value is temporarily set to `null`. This way it minimizes the number of PropertyChangeEvents fired by this Trigger.

### triggerFlush

    public void triggerFlush()

  Triggers a flush event in BufferedValueModels that share this Trigger. Sets the value to `Boolean.FALSE` and ensures that listeners are notified about a value change to the new value. If necessary the value is temporarily set to `null`. This way it minimizes the number of PropertyChangeEvents fired by this Trigger.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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