Package jmri.beans
Class ConstrainedBean
java.lang.Object
jmri.beans.UnboundBean
jmri.beans.Bean
jmri.beans.ConstrainedBean
- All Implemented Interfaces:
BeanInterface,PropertyChangeFirer,PropertyChangeProvider,VetoableChangeProvider
- Direct Known Subclasses:
ConstrainedArbitraryBean,Scale
A Bean with support for
VetoableChangeListeners.-
Field Summary
FieldsFields inherited from class jmri.beans.Bean
propertyChangeSupport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd aVetoableChangeListenerto the listener list.voidaddVetoableChangeListener(String propertyName, VetoableChangeListener listener) Add aVetoableChangeListenerfor a specific property.voidFire a vetoable property change on the current thread.voidfireVetoableChange(String propertyName, boolean oldValue, boolean newValue) Fire a vetoable property change on the current thread.voidfireVetoableChange(String propertyName, int oldValue, int newValue) Fire a vetoable property change on the current thread.voidfireVetoableChange(String propertyName, Object oldValue, Object newValue) Fire a vetoable property change on the current thread.protected ObjectgetIndexedPropertyOrNull(String key, int index) Get the indexed property or return null if the index is invalid.Get allVetoableChangeListeners currently attached to this object.getVetoableChangeListeners(String propertyName) Get allVetoableChangeListeners currently listening to changes to the specified property.voidRemove the specified listener from this object.voidremoveVetoableChangeListener(String propertyName, VetoableChangeListener listener) Remove the specified listener of the specified property from this object.voidsetIndexedProperty(String key, int index, Object value) Set element at index of property array key to value.voidsetProperty(String key, Object value) Set property key to value.Methods inherited from class jmri.beans.Bean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, isNotifyOnEDT, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class jmri.beans.UnboundBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty
-
Field Details
-
vetoableChangeSupport
-
-
Constructor Details
-
ConstrainedBean
public ConstrainedBean()
-
-
Method Details
-
setProperty
Description copied from class:UnboundBeanSet property key to value.This implementation calls a write method for the property using JavaBeans introspection.
- Specified by:
setPropertyin interfaceBeanInterface- Overrides:
setPropertyin classUnboundBean- Parameters:
key- name of the propertyvalue- the value to set the property to- See Also:
-
setIndexedProperty
Description copied from class:UnboundBeanSet element at index of property array key to value.This implementation calls a write method for the indexed property using JavaBeans introspection, and assumes, based on JavaBeans coding patterns, that the write method has the following two parameters in order:
index,value.- Specified by:
setIndexedPropertyin interfaceBeanInterface- Overrides:
setIndexedPropertyin classUnboundBean- Parameters:
key- name of the propertyindex- index of the property element to changevalue- the value to set the property to- See Also:
-
addVetoableChangeListener
Description copied from interface:VetoableChangeProviderAdd aVetoableChangeListenerto the listener list.- Specified by:
addVetoableChangeListenerin interfaceVetoableChangeProvider- Parameters:
listener- The VetoableChangeListener to be added
-
addVetoableChangeListener
Description copied from interface:VetoableChangeProviderAdd aVetoableChangeListenerfor a specific property.- Specified by:
addVetoableChangeListenerin interfaceVetoableChangeProvider- Parameters:
propertyName- The name of the property to listen on.listener- The VetoableChangeListener to be added
-
getVetoableChangeListeners
Description copied from interface:VetoableChangeProviderGet allVetoableChangeListeners currently attached to this object.- Specified by:
getVetoableChangeListenersin interfaceVetoableChangeProvider- Returns:
- An array of VetoableChangeListeners.
-
getVetoableChangeListeners
Description copied from interface:VetoableChangeProviderGet allVetoableChangeListeners currently listening to changes to the specified property.- Specified by:
getVetoableChangeListenersin interfaceVetoableChangeProvider- Parameters:
propertyName- The name of the property of interest- Returns:
- An array of VetoableChangeListeners.
-
removeVetoableChangeListener
Description copied from interface:VetoableChangeProviderRemove the specified listener from this object.- Specified by:
removeVetoableChangeListenerin interfaceVetoableChangeProvider- Parameters:
listener- TheVetoableChangeListenerto remove.
-
removeVetoableChangeListener
Description copied from interface:VetoableChangeProviderRemove the specified listener of the specified property from this object.- Specified by:
removeVetoableChangeListenerin interfaceVetoableChangeProvider- Parameters:
propertyName- The name of the property to stop listening to.listener- TheVetoableChangeListenerto remove.
-
fireVetoableChange
Fire a vetoable property change on the current thread. UseVetoableChangeSupport.fireVetoableChange(java.beans.PropertyChangeEvent)directly to fire this notification on another thread. If a PropertyVetoException is thrown, ensure the property change does not complete.- Parameters:
event-PropertyChangeEventto be fired- Throws:
PropertyVetoException- if property update vetoed
-
fireVetoableChange
public void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws PropertyVetoException Fire a vetoable property change on the current thread. UseVetoableChangeSupport.fireVetoableChange(java.lang.String, java.lang.Object, java.lang.Object)directly to fire this notification on another thread. If a PropertyVetoException is thrown, ensure the property change does not complete.- Parameters:
propertyName- property that is about to changeoldValue- old value of the propertynewValue- new value of the property- Throws:
PropertyVetoException- if property update vetoed
-
fireVetoableChange
public void fireVetoableChange(String propertyName, int oldValue, int newValue) throws PropertyVetoException Fire a vetoable property change on the current thread. UseVetoableChangeSupport.fireVetoableChange(java.lang.String, int, int)directly to fire this notification on another thread. If a PropertyVetoException is thrown, ensure the property change does not complete.- Parameters:
propertyName- property that is about to changeoldValue- old value of the propertynewValue- new value of the property- Throws:
PropertyVetoException- if property update vetoed
-
fireVetoableChange
public void fireVetoableChange(String propertyName, boolean oldValue, boolean newValue) throws PropertyVetoException Fire a vetoable property change on the current thread. UseVetoableChangeSupport.fireVetoableChange(java.lang.String, boolean, boolean)directly to fire this notification on another thread. If a PropertyVetoException is thrown, ensure the property change does not complete.- Parameters:
propertyName- property that is about to changeoldValue- old value of the propertynewValue- new value of the property- Throws:
PropertyVetoException- if property update vetoed
-
getIndexedPropertyOrNull
Get the indexed property or return null if the index is invalid. Used to get the old value when setting an indexed property where the index may not previously have been set.- Parameters:
key- the property nameindex- the index- Returns:
- the value at index or null
-