Class UnboundArbitraryBean
- java.lang.Object
-
- jmri.beans.UnboundBean
-
- jmri.beans.UnboundArbitraryBean
-
- All Implemented Interfaces:
BeanInterface
public abstract class UnboundArbitraryBean extends UnboundBean
Generic implementation ofBeanInterfacethat supports arbitrary properties defined at runtime.NOTE This class does not implement
PropertyChangeSupport. SubclassBeanif you need to support property change listeners.
-
-
Field Summary
Fields Modifier and Type Field Description protected ArbitraryPropertySupportarbitraryPropertySupport
-
Constructor Summary
Constructors Constructor Description UnboundArbitraryBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgetIndexedProperty(java.lang.String key, int index)Get value of element at index of property array key.java.lang.ObjectgetProperty(java.lang.String key)Get the value of property key.java.util.Set<java.lang.String>getPropertyNames()Return a list of property names.booleanhasIndexedProperty(java.lang.String key)Test that a property exists and is indexed.booleanhasProperty(java.lang.String key)Test if a property exists.voidsetIndexedProperty(java.lang.String key, int index, java.lang.Object value)Set element at index of property array key to value.voidsetProperty(java.lang.String key, java.lang.Object value)Set property key to value.
-
-
-
Field Detail
-
arbitraryPropertySupport
protected final ArbitraryPropertySupport arbitraryPropertySupport
-
-
Constructor Detail
-
UnboundArbitraryBean
public UnboundArbitraryBean()
-
-
Method Detail
-
getIndexedProperty
public java.lang.Object getIndexedProperty(java.lang.String key, int index)
Get value of element at index of property array key.This implementation calls a read method for the indexed property using JavaBeans introspection, and assumes, based on JavaBeans coding patterns, that the read method has the following parameter:
index. Note that this method returns null instead of throwingArrayIndexOutOfBoundsExceptionif the index is invalid since the Java introspection methods provide no reliable way to get the size of the indexed property.- Specified by:
getIndexedPropertyin interfaceBeanInterface- Overrides:
getIndexedPropertyin classUnboundBean- Parameters:
key- Property array to parse.index- Element to retrieve.- Returns:
- value of element or null
-
getProperty
public java.lang.Object getProperty(java.lang.String key)
Get the value of property key.If null is a valid (or expected) value for key, you might want to use
UnboundBean.hasProperty(java.lang.String)to test that the property exists.This implementation searches the internal property collection and uses introspection to get the property.
- Specified by:
getPropertyin interfaceBeanInterface- Overrides:
getPropertyin classUnboundBean- Parameters:
key- Property to retrieve.- Returns:
- value of key or null.
- See Also:
BeanInterface.getProperty(java.lang.String)
-
getPropertyNames
public java.util.Set<java.lang.String> getPropertyNames()
Return a list of property names.This implementation combines the keys in
ArbitraryPropertySupport.getPropertyNames()with the results ofBeanUtil.getIntrospectedPropertyNames(java.lang.Object).- Specified by:
getPropertyNamesin interfaceBeanInterface- Overrides:
getPropertyNamesin classUnboundBean- Returns:
- a Set of names
- See Also:
BeanInterface.getPropertyNames()
-
hasProperty
public boolean hasProperty(java.lang.String key)
Test if a property exists.This implementation searches the internal property collection and uses introspection to get the property.
- Specified by:
hasPropertyin interfaceBeanInterface- Overrides:
hasPropertyin classUnboundBean- Parameters:
key- Property to inspect.- Returns:
- true if property exists
- See Also:
BeanInterface.hasProperty(java.lang.String)
-
hasIndexedProperty
public boolean hasIndexedProperty(java.lang.String key)
Description copied from interface:BeanInterfaceTest that a property exists and is indexed.NOTE Implementing method must not call
Bean.hasIndexedProperty(), as doing so will cause a stack overflow. Implementing methods may callBeans.hasIntrospectedIndexedProperty()instead.- Specified by:
hasIndexedPropertyin interfaceBeanInterface- Overrides:
hasIndexedPropertyin classUnboundBean- Parameters:
key- name of the property- Returns:
- true is property key exists and is indexed
-
setIndexedProperty
public void setIndexedProperty(java.lang.String key, int index, java.lang.Object value)
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:
setIndexedPropertyin interfaceBeanInterface- Overrides:
setIndexedPropertyin classUnboundBean- Parameters:
key- Property array to use.index- Element to write.value- Value to set.- See Also:
BeanInterface.setIndexedProperty(java.lang.String, int, java.lang.Object)
-
setProperty
public void setProperty(java.lang.String key, java.lang.Object value)
Set property key to value.This implementation checks that a write method is not available for the property using JavaBeans introspection, and stores the property using
ArbitraryPropertySupport.setProperty(String, Object)only if a write method does not exist. This implementation also fires a PropertyChangeEvent for the property.- Specified by:
setPropertyin interfaceBeanInterface- Overrides:
setPropertyin classUnboundBean- Parameters:
key- Property to use.value- Value to store.- See Also:
BeanInterface.setProperty(java.lang.String, java.lang.Object)
-
-