jmri.implementation
Class AbstractNamedBean

Show UML class diagram
java.lang.Object
  extended by jmri.implementation.AbstractNamedBean
All Implemented Interfaces:
Serializable, NamedBean
Direct Known Subclasses:
AbstractAudio, AbstractIdTag, AbstractLight, AbstractMemory, AbstractReporter, AbstractSensor, AbstractSignalHead, AbstractSignalMast, AbstractTurnout, Block, DefaultConditional, DefaultLogix, DefaultRoute, DefaultSignalAppearanceMap, DefaultSignalGroup, DefaultSignalSystem, DestinationPoints, LayoutBlock, Portal, Section, SimpleTimebase, Transit, Warrant

public abstract class AbstractNamedBean
extends Object
implements NamedBean, Serializable

Abstract base for the NamedBean interface.

Implements the parameter binding support.

See Also:
Serialized Form

Field Summary
(package private)  Hashtable<PropertyChangeListener,String> listenerRefs
           
(package private) static org.slf4j.Logger log
           
protected  String mSystemName
           
protected  String mUserName
           
(package private)  HashMap<Object,Object> parameters
           
(package private)  PropertyChangeSupport pcs
           
(package private)  Hashtable<PropertyChangeListener,String> register
           
 
Fields inherited from interface jmri.NamedBean
INCONSISTENT, UNKNOWN
 
Constructor Summary
protected AbstractNamedBean(String sys)
           
protected AbstractNamedBean(String sys, String user)
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
           
 void addPropertyChangeListener(PropertyChangeListener l, String beanRef, String listenerRef)
          Request a call-back when a bound property changes.
 void dispose()
          Deactivate this object, so that it releases as many resources as possible and no longer effects others.
protected  void firePropertyChange(String p, Object old, Object n)
           
 String getComment()
          Get associated comment text.
 String getDisplayName()
           
 String getListenerRef(PropertyChangeListener l)
          Get the textual reference for the specific listener
 ArrayList<String> getListenerRefs()
          Returns a list of all the listerners references
 int getNumPropertyChangeListeners()
          Number of current listeners.
 Object getProperty(Object key)
          Retrieve the value associated with a key.
 PropertyChangeListener[] getPropertyChangeListeners()
           
 ArrayList<PropertyChangeListener> getPropertyChangeListeners(String name)
          Get a list of all the property change listeners that are registered using a specific name
 Set<Object> getPropertyKeys()
          Retrieve the complete current set of keys.
 String getSystemName()
          Get a system-specific name.
 String getUserName()
           
 void removeProperty(Object key)
          Remove the key/value pair against the NamedBean.
 void removePropertyChangeListener(PropertyChangeListener l)
          Remove a request for a call-back when a bound property changes.
 void setComment(String comment)
          Set associated comment text.
 void setProperty(Object key, Object value)
          Attach a key/value pair to the NamedBean, which can be retrieved later.
 void setUserName(String s)
           
 void updateListenerRef(PropertyChangeListener l, String newName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.NamedBean
getState, setState
 

Field Detail

pcs

PropertyChangeSupport pcs

register

Hashtable<PropertyChangeListener,String> register

listenerRefs

Hashtable<PropertyChangeListener,String> listenerRefs

mUserName

protected String mUserName

mSystemName

protected String mSystemName

parameters

HashMap<Object,Object> parameters

log

static org.slf4j.Logger log
Constructor Detail

AbstractNamedBean

protected AbstractNamedBean(String sys)

AbstractNamedBean

protected AbstractNamedBean(String sys,
                            String user)
Method Detail

getComment

public String getComment()
Get associated comment text.

Specified by:
getComment in interface NamedBean

setComment

public void setComment(String comment)
Set associated comment text.

Comments can be any valid text.

Specified by:
setComment in interface NamedBean
Parameters:
comment - Null means no comment associated.

getDisplayName

public String getDisplayName()
Specified by:
getDisplayName in interface NamedBean

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l,
                                      String beanRef,
                                      String listenerRef)
Description copied from interface: NamedBean
Request a call-back when a bound property changes. Bound properties are the known state, commanded state, user and system names.

Specified by:
addPropertyChangeListener in interface NamedBean
Parameters:
l - - Listener
beanRef - - The name (either system or user) that the listener uses for this namedBean, this parameter is used to help determine when which listeners should be moved when the username is moved from one bean to another.
listenerRef - - A textual reference for the listener, that can be presented to the user when a delete is called

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Specified by:
addPropertyChangeListener in interface NamedBean

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Description copied from interface: NamedBean
Remove a request for a call-back when a bound property changes.

Specified by:
removePropertyChangeListener in interface NamedBean

getPropertyChangeListeners

public ArrayList<PropertyChangeListener> getPropertyChangeListeners(String name)
Description copied from interface: NamedBean
Get a list of all the property change listeners that are registered using a specific name

Specified by:
getPropertyChangeListeners in interface NamedBean
Parameters:
name - - The name (either system or user) that the listener has registered as referencing this namedBean

getListenerRefs

public ArrayList<String> getListenerRefs()
Description copied from interface: NamedBean
Returns a list of all the listerners references

Specified by:
getListenerRefs in interface NamedBean

updateListenerRef

public void updateListenerRef(PropertyChangeListener l,
                              String newName)
Specified by:
updateListenerRef in interface NamedBean

getListenerRef

public String getListenerRef(PropertyChangeListener l)
Description copied from interface: NamedBean
Get the textual reference for the specific listener

Specified by:
getListenerRef in interface NamedBean

getNumPropertyChangeListeners

public int getNumPropertyChangeListeners()
Number of current listeners. May return -1 if the information is not available for some reason.

Specified by:
getNumPropertyChangeListeners in interface NamedBean

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners()

getSystemName

public String getSystemName()
Description copied from interface: NamedBean
Get a system-specific name. This encodes the hardware addressing information.

Specified by:
getSystemName in interface NamedBean

getUserName

public String getUserName()
Specified by:
getUserName in interface NamedBean

setUserName

public void setUserName(String s)
Specified by:
setUserName in interface NamedBean

firePropertyChange

protected void firePropertyChange(String p,
                                  Object old,
                                  Object n)

dispose

public void dispose()
Description copied from interface: NamedBean
Deactivate this object, so that it releases as many resources as possible and no longer effects others.

For example, if this object has listeners, after a call to this method it should no longer notify those listeners. Any native or system-wide resources it maintains should be released, including threads, files, etc.

It is an error to invoke any other methods on this object once dispose() has been called. Note, however, that there is no guarantee about behavior in that case.

Afterwards, references to this object may still exist elsewhere, preventing its garbage collection. But it's formally dead, and shouldn't be keeping any other objects alive. Therefore, this method should null out any references to other objects that this NamedBean contained.

Specified by:
dispose in interface NamedBean

setProperty

public void setProperty(Object key,
                        Object value)
Description copied from interface: NamedBean
Attach a key/value pair to the NamedBean, which can be retrieved later. These are not bound properties as yet, and don't throw events on modification. Key must not be null.

Specified by:
setProperty in interface NamedBean

getProperty

public Object getProperty(Object key)
Description copied from interface: NamedBean
Retrieve the value associated with a key. If no value has been set for that key, returns null.

Specified by:
getProperty in interface NamedBean

getPropertyKeys

public Set<Object> getPropertyKeys()
Description copied from interface: NamedBean
Retrieve the complete current set of keys.

Specified by:
getPropertyKeys in interface NamedBean

removeProperty

public void removeProperty(Object key)
Description copied from interface: NamedBean
Remove the key/value pair against the NamedBean.

Specified by:
removeProperty in interface NamedBean


Copyright © 1997-2014 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