jmri.beans
Class UnboundBean

Show UML class diagram
java.lang.Object
  extended by jmri.beans.UnboundBean
All Implemented Interfaces:
BeanInterface
Direct Known Subclasses:
Bean

public abstract class UnboundBean
extends Object
implements BeanInterface


Field Summary
protected  HashMap<String,Object> properties
          Store properties in a hashMap for easy access.
 
Constructor Summary
UnboundBean()
           
 
Method Summary
 Object getIndexedProperty(String key, int index)
          Get value of element at index of property array key.
 Object getProperty(String key)
          Get the value of property key.
 Set<String> getPropertyNames()
          Return a list of property names.
 boolean hasProperty(String key)
          Test if a property exists.
 void setIndexedProperty(String key, int index, Object value)
          Set element at index of property array key to value.
 void setProperty(String key, Object value)
          Set property key to value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

properties

protected final HashMap<String,Object> properties
Store properties in a hashMap for easy access.

Note that unless you use the methods in this class to manipulate this variable, you will need to instantiate it, or test that it is not null prior to use.

Constructor Detail

UnboundBean

public UnboundBean()
Method Detail

getIndexedProperty

public Object getIndexedProperty(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.

Specified by:
getIndexedProperty in interface BeanInterface
Parameters:
key -
index -
Returns:
value of element or null

getProperty

public Object getProperty(String key)
Get the value of property key.

If null is a valid (or expected) value for key, you might want to use hasProperty(java.lang.String) to test that the property exists.

This implementation searches properties and uses introspection to get the property.

Specified by:
getProperty in interface BeanInterface
Parameters:
key -
Returns:
value of key or null.
See Also:
BeanInterface.getProperty(java.lang.String)

getPropertyNames

public Set<String> getPropertyNames()
Return a list of property names.

This implementation combines the keys in properties with the results of Beans.getIntrospectedPropertyNames(java.lang.Object).

Specified by:
getPropertyNames in interface BeanInterface
Returns:
a Set of names
See Also:
BeanInterface.getPropertyNames()

hasProperty

public boolean hasProperty(String key)
Test if a property exists.

This implementation searches properties and uses introspection to get the property.

Specified by:
hasProperty in interface BeanInterface
Parameters:
key -
Returns:
true if property exists
See Also:
BeanInterface.hasProperty(java.lang.String)

setIndexedProperty

public void setIndexedProperty(String key,
                               int index,
                               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:
setIndexedProperty in interface BeanInterface
Parameters:
key -
index -
value -
See Also:
BeanInterface.setIndexedProperty(java.lang.String, int, java.lang.Object)

setProperty

public void setProperty(String key,
                        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 in properties only if a write method does not exist. This implementation also fires a PropertyChangeEvent for the property.

Specified by:
setProperty in interface BeanInterface
Parameters:
key -
value -
See Also:
BeanInterface.setProperty(java.lang.String, java.lang.Object)


Copyright © 1997-2013 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads