java.beans

Class PropertyChangeEvent

public class PropertyChangeEvent extends EventObject

PropertyChangeEvents are fired in the PropertyChange and VetoableChange event classes. They represent the old and new values as well as the source Bean. If the old or new value is a primitive type, it must be wrapped in the appropriate wrapper type (java.lang.Integer for int, etc., etc.).

If the old or new values are unknown (although why that would be I do not know), they may be null. Also, if the set of properties itself has changed, the name should be null, and the old and new values may also be null. Right now Sun put in a propagationId, reserved for future use. Read the comments on the constructor and on setPropagationId for more information.

Since: 1.1

UNKNOWN: udpated to 1.4

Constructor Summary
PropertyChangeEvent(Object source, String propertyName, Object oldVal, Object newVal)
Create a new PropertyChangeEvent.
Method Summary
ObjectgetNewValue()
Get the property's new value.
ObjectgetOldValue()
Get the property's old value.
ObjectgetPropagationId()
Get the propagation ID.
StringgetPropertyName()
Get the property name.
voidsetPropagationId(Object propagationId)
Set the propagation ID.

Constructor Detail

PropertyChangeEvent

public PropertyChangeEvent(Object source, String propertyName, Object oldVal, Object newVal)
Create a new PropertyChangeEvent. Remember that if you received a PropertyChangeEvent and are sending a new one, you should also set the propagation ID from the old PropertyChangeEvent.

Parameters: source the Bean containing the property propertyName the property's name oldVal the old value of the property newVal the new value of the property

Throws: IllegalArgumentException if source is null

Method Detail

getNewValue

public Object getNewValue()
Get the property's new value. May be null if multiple properties changed.

Returns: the property's new value

getOldValue

public Object getOldValue()
Get the property's old value. May be null if multiple properties changed.

Returns: the property's old value

getPropagationId

public Object getPropagationId()
Get the propagation ID. Right now, it is not used for anything.

Returns: the propagation ID

See Also: setPropagationId

getPropertyName

public String getPropertyName()
Get the property name. May be null if multiple properties changed.

Returns: the property name

setPropagationId

public void setPropagationId(Object propagationId)
Set the propagation ID. This is a way for the event to be passed from hand to hand and retain a little extra state. Right now it is unused, but it should be propagated anyway so that future versions of JavaBeans can use it, for God knows what.

Parameters: propagationId the propagation ID

See Also: getPropagationId