jmri
Class NamedBeanHandleManager

java.lang.Object
  extended by jmri.managers.AbstractManager
      extended by jmri.NamedBeanHandleManager
All Implemented Interfaces:
PropertyChangeListener, Serializable, EventListener, Manager

public class NamedBeanHandleManager
extends AbstractManager
implements Serializable

Instance for controlling the issuing of NamedBeanHandles.


The NamedBeanHandleManager, deals with controlling and updating NamedBeans across JMRI. When a piece of code requires persistent access to a bean, it should use a NamedBeanHandle, the NamedBeanHandle stores not only the bean that has been requested but also the named that was used to request it (either User or System Name).

This Manager will only issue out one NamedBeanHandle per Bean/Name request. The Manager also deals with updates and changes to the names of Beans, along with moving usernames between different beans.

If a beans username is changed by the user, then the name will be updated in the NamedBeanHandle. If a username is moved from one bean to another, then the bean reference will be updated and the propertyChangeListener attached to that bean will also be moved, so long as the correct method of adding the listener has been used.


This file is part of JMRI.

JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Author:
Kevin Dickerson Copyright (C) 2011
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jmri.managers.AbstractManager
_tsys, _tuser
 
Fields inherited from interface jmri.Manager
AUDIO, BLOCKBOSS, BLOCKS, CONDITIONALS, IDTAGS, LAYOUTBLOCKS, LIGHTS, LOGIXS, MEMORIES, OBLOCKS, PANELFILES, REPORTERS, ROUTES, SECTIONS, SENSORGROUPS, SENSORS, SIGNALGROUPS, SIGNALHEADS, SIGNALMASTLOGICS, SIGNALMASTS, TIMEBASE, TRANSITS, TURNOUTS, WARRANTS
 
Constructor Summary
NamedBeanHandleManager()
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
          At a minimum, subclasses must notify of changes to the list of available NamedBeans; they may have other properties that will also notify.
 void deregister(NamedBean n)
          Forget a NamedBean Object created outside the manager.
 void dispose()
          Free resources when no longer used.
protected  void firePropertyChange(String p, Object old, Object n)
           
<T> NamedBeanHandle<T>
getNamedBeanHandle(String name, T bean)
           
 String[] getSystemNameArray()
           
 List<String> getSystemNameList()
           
 String getSystemPrefix()
          Provides access to the system prefix string.
 int getXMLOrder()
           
<T> boolean
inUse(String name, T bean)
           
 String makeSystemName(String s)
           
<T> void
moveBean(T oldBean, T newBean, String name)
          A method to effectivily move a name from one bean to another.
<T> NamedBeanHandle<T>
newNamedBeanHandle(String name, T bean, Class<T> type)
           
 void register(NamedBean n)
          Remember a NamedBean Object created outside the manager.
protected  void registerSelf()
          Don't want to store this information
 void removePropertyChangeListener(PropertyChangeListener l)
          At a minimum, subclasses must notify of changes to the list of available NamedBeans; they may have other properties that will also notify.
<T> void
renameBean(String oldName, String newName, T bean)
          A Method to update the name on a bean.
 char systemLetter()
          Provide access to deprecated method temporarilly
 char typeLetter()
           
 void updateBeanFromSystemToUser(NamedBean bean)
           
 void updateBeanFromUserToSystem(NamedBean bean)
           
 
Methods inherited from class jmri.managers.AbstractManager
getBeanBySystemName, getInstanceBySystemName, getInstanceByUserName, propertyChange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedBeanHandleManager

public NamedBeanHandleManager()
Method Detail

getNamedBeanHandle

public <T> NamedBeanHandle<T> getNamedBeanHandle(String name,
                                                 T bean)

renameBean

public <T> void renameBean(String oldName,
                           String newName,
                           T bean)
A Method to update the name on a bean. Note this does not change the name on the bean, it only changes the references


moveBean

public <T> void moveBean(T oldBean,
                         T newBean,
                         String name)
A method to effectivily move a name from one bean to another. This method only updates the references to point to the new bean It does not move the name provided from one bean to another.


updateBeanFromUserToSystem

public void updateBeanFromUserToSystem(NamedBean bean)

updateBeanFromSystemToUser

public void updateBeanFromSystemToUser(NamedBean bean)
                                throws JmriException
Throws:
JmriException

inUse

public <T> boolean inUse(String name,
                         T bean)

newNamedBeanHandle

public <T> NamedBeanHandle<T> newNamedBeanHandle(String name,
                                                 T bean,
                                                 Class<T> type)

dispose

public void dispose()
Description copied from interface: Manager
Free resources when no longer used. Specifically, remove all references to and from this object, so it can be garbage-collected.

Specified by:
dispose in interface Manager
Overrides:
dispose in class AbstractManager

registerSelf

protected void registerSelf()
Don't want to store this information

Overrides:
registerSelf in class AbstractManager

systemLetter

public char systemLetter()
Description copied from class: AbstractManager
Provide access to deprecated method temporarilly

Specified by:
systemLetter in interface Manager
Overrides:
systemLetter in class AbstractManager
Returns:
The system-specific prefix letter for a specific implementation

getSystemPrefix

public String getSystemPrefix()
Description copied from interface: Manager
Provides access to the system prefix string. This was previously called the "System letter"

Specified by:
getSystemPrefix in interface Manager

typeLetter

public char typeLetter()
Specified by:
typeLetter in interface Manager
Returns:
The type letter for a specific implementation

makeSystemName

public String makeSystemName(String s)
Specified by:
makeSystemName in interface Manager
Overrides:
makeSystemName in class AbstractManager
Returns:
A system name from a user input, typically a number.

getSystemNameArray

public String[] getSystemNameArray()
Specified by:
getSystemNameArray in interface Manager
Overrides:
getSystemNameArray in class AbstractManager

getSystemNameList

public List<String> getSystemNameList()
Specified by:
getSystemNameList in interface Manager
Overrides:
getSystemNameList in class AbstractManager

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Description copied from interface: Manager
At a minimum, subclasses must notify of changes to the list of available NamedBeans; they may have other properties that will also notify.

Specified by:
addPropertyChangeListener in interface Manager
Overrides:
addPropertyChangeListener in class AbstractManager

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Description copied from interface: Manager
At a minimum, subclasses must notify of changes to the list of available NamedBeans; they may have other properties that will also notify.

Specified by:
removePropertyChangeListener in interface Manager
Overrides:
removePropertyChangeListener in class AbstractManager

firePropertyChange

protected void firePropertyChange(String p,
                                  Object old,
                                  Object n)
Overrides:
firePropertyChange in class AbstractManager

register

public void register(NamedBean n)
Description copied from class: AbstractManager
Remember a NamedBean Object created outside the manager.

The non-system-specific SignalHeadManagers use this method extensively.

Specified by:
register in interface Manager
Overrides:
register in class AbstractManager

deregister

public void deregister(NamedBean n)
Description copied from class: AbstractManager
Forget a NamedBean Object created outside the manager.

The non-system-specific RouteManager uses this method.

Specified by:
deregister in interface Manager
Overrides:
deregister in class AbstractManager

getXMLOrder

public int getXMLOrder()
Specified by:
getXMLOrder in interface Manager
Specified by:
getXMLOrder in class AbstractManager


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