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
public abstract class ConstrainedBean extends Bean implements VetoableChangeProvider
A Bean with support forVetoableChangeListener
s.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.beans.VetoableChangeSupport
vetoableChangeSupport
-
Fields inherited from class jmri.beans.Bean
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description ConstrainedBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Add aVetoableChangeListener
to the listener list.void
addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)
Add aVetoableChangeListener
for a specific property.void
fireVetoableChange(java.beans.PropertyChangeEvent event)
Fire a vetoable property change on the current thread.void
fireVetoableChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
Fire a vetoable property change on the current thread.void
fireVetoableChange(java.lang.String propertyName, int oldValue, int newValue)
Fire a vetoable property change on the current thread.void
fireVetoableChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
Fire a vetoable property change on the current thread.protected java.lang.Object
getIndexedPropertyOrNull(java.lang.String key, int index)
Get the indexed property or return null if the index is invalid.java.beans.VetoableChangeListener[]
getVetoableChangeListeners()
Get allVetoableChangeListener
s currently attached to this object.java.beans.VetoableChangeListener[]
getVetoableChangeListeners(java.lang.String propertyName)
Get allVetoableChangeListener
s currently listening to changes to the specified property.void
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Remove the specified listener from this object.void
removeVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)
Remove the specified listener of the specified property from this object.void
setIndexedProperty(java.lang.String key, int index, java.lang.Object value)
Set element at index of property array key to value.void
setProperty(java.lang.String key, java.lang.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, removePropertyChangeListener
-
Methods inherited from class jmri.beans.UnboundBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty
-
-
-
-
Field Detail
-
vetoableChangeSupport
protected final java.beans.VetoableChangeSupport vetoableChangeSupport
-
-
Constructor Detail
-
ConstrainedBean
public ConstrainedBean()
-
-
Method Detail
-
setProperty
public void setProperty(java.lang.String key, java.lang.Object value)
Description copied from class:UnboundBean
Set property key to value.This implementation calls a write method for the property using JavaBeans introspection.
- Specified by:
setProperty
in interfaceBeanInterface
- Overrides:
setProperty
in classUnboundBean
- Parameters:
key
- name of the propertyvalue
- the value to set the property to- See Also:
BeanInterface.setProperty(java.lang.String, java.lang.Object)
-
setIndexedProperty
public void setIndexedProperty(java.lang.String key, int index, java.lang.Object value)
Description copied from class:UnboundBean
Set 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:
setIndexedProperty
in interfaceBeanInterface
- Overrides:
setIndexedProperty
in classUnboundBean
- Parameters:
key
- name of the propertyindex
- index of the property element to changevalue
- the value to set the property to- See Also:
BeanInterface.setIndexedProperty(java.lang.String, int, java.lang.Object)
-
addVetoableChangeListener
public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Description copied from interface:VetoableChangeProvider
Add aVetoableChangeListener
to the listener list.- Specified by:
addVetoableChangeListener
in interfaceVetoableChangeProvider
- Parameters:
listener
- The VetoableChangeListener to be added
-
addVetoableChangeListener
public void addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)
Description copied from interface:VetoableChangeProvider
Add aVetoableChangeListener
for a specific property.- Specified by:
addVetoableChangeListener
in interfaceVetoableChangeProvider
- Parameters:
propertyName
- The name of the property to listen on.listener
- The VetoableChangeListener to be added
-
getVetoableChangeListeners
public java.beans.VetoableChangeListener[] getVetoableChangeListeners()
Description copied from interface:VetoableChangeProvider
Get allVetoableChangeListener
s currently attached to this object.- Specified by:
getVetoableChangeListeners
in interfaceVetoableChangeProvider
- Returns:
- An array of VetoableChangeListeners.
-
getVetoableChangeListeners
public java.beans.VetoableChangeListener[] getVetoableChangeListeners(java.lang.String propertyName)
Description copied from interface:VetoableChangeProvider
Get allVetoableChangeListener
s currently listening to changes to the specified property.- Specified by:
getVetoableChangeListeners
in interfaceVetoableChangeProvider
- Parameters:
propertyName
- The name of the property of interest- Returns:
- An array of VetoableChangeListeners.
-
removeVetoableChangeListener
public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Description copied from interface:VetoableChangeProvider
Remove the specified listener from this object.- Specified by:
removeVetoableChangeListener
in interfaceVetoableChangeProvider
- Parameters:
listener
- TheVetoableChangeListener
to remove.
-
removeVetoableChangeListener
public void removeVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)
Description copied from interface:VetoableChangeProvider
Remove the specified listener of the specified property from this object.- Specified by:
removeVetoableChangeListener
in interfaceVetoableChangeProvider
- Parameters:
propertyName
- The name of the property to stop listening to.listener
- TheVetoableChangeListener
to remove.
-
fireVetoableChange
public void fireVetoableChange(java.beans.PropertyChangeEvent event) throws java.beans.PropertyVetoException
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
-PropertyChangeEvent
to be fired- Throws:
java.beans.PropertyVetoException
- if property update vetoed
-
fireVetoableChange
public void fireVetoableChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue) throws java.beans.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:
java.beans.PropertyVetoException
- if property update vetoed
-
fireVetoableChange
public void fireVetoableChange(java.lang.String propertyName, int oldValue, int newValue) throws java.beans.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:
java.beans.PropertyVetoException
- if property update vetoed
-
fireVetoableChange
public void fireVetoableChange(java.lang.String propertyName, boolean oldValue, boolean newValue) throws java.beans.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:
java.beans.PropertyVetoException
- if property update vetoed
-
getIndexedPropertyOrNull
protected java.lang.Object getIndexedPropertyOrNull(java.lang.String key, int index)
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
-
-