jmri.managers
Class DefaultIdTagManager

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

public class DefaultIdTagManager
extends AbstractManager
implements IdTagManager

Concrete implementation for the Internal IdTagManager interface.

Since:
2.11.4
Author:
Bob Jacobsen Copyright (C) 2010, Matthew Harris Copyright (C) 2011

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
DefaultIdTagManager()
           
 
Method Summary
protected  IdTag createNewIdTag(String systemName, String userName)
           
 void deregister(NamedBean s)
          Forget a NamedBean Object created outside the manager.
 IdTag getBySystemName(String name)
          Locate an instance based on a system name.
 IdTag getByTagID(String tagID)
          Locate an instance based on a tag ID.
 IdTag getByUserName(String key)
          Locate an instance based on a user name.
 IdTag getIdTag(String name)
          Locate via tag ID, then by user name, and finally system name if needed.
 String getSystemPrefix()
          Provides access to the system prefix string.
 List<IdTag> getTagsForReporter(Reporter reporter, long threshold)
          Get a list of all IdTags seen by a specified Reporter within a specific time threshold from the most recently seen.
 int getXMLOrder()
           
 void init()
          Perform initialisation
 boolean isFastClockUsed()
          Determines if fast clock times should be recorded for when a given IdTag was last seen
 boolean isInitialised()
          Determines if the manager has been initialised
 boolean isStateStored()
          Determines if the state of known IdTags should be stored
 IdTag newIdTag(String systemName, String userName)
          Return an instance with the specified system and user names.
 void propertyChange(PropertyChangeEvent e)
          The PropertyChangeListener interface in this class is intended to keep track of user name changes to individual NamedBeans.
 IdTag provideIdTag(String name)
          Locate via tag ID, then user name, and finally system name if needed.
 void register(NamedBean s)
          Remember a NamedBean Object created outside the manager.
protected  void registerSelf()
          Don't want to store this information
 void setFastClockUsed(boolean fastClock)
          Define if the manager should use the fast clock when setting the times when a given IdTag was last seen
 void setStateStored(boolean state)
          Define if the manager should persist details of when and where all known IdTags were seen
 char typeLetter()
           
 void writeIdTagDetails()
           
 
Methods inherited from class jmri.managers.AbstractManager
addPropertyChangeListener, dispose, firePropertyChange, getBeanBySystemName, getInstanceBySystemName, getInstanceByUserName, getSystemNameArray, getSystemNameList, makeSystemName, removePropertyChangeListener, systemLetter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.IdTagManager
getSystemNameList
 
Methods inherited from interface jmri.Manager
addPropertyChangeListener, dispose, getBeanBySystemName, getSystemNameArray, makeSystemName, removePropertyChangeListener, systemLetter
 

Constructor Detail

DefaultIdTagManager

public DefaultIdTagManager()
Method Detail

getXMLOrder

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

isInitialised

public boolean isInitialised()
Description copied from interface: IdTagManager
Determines if the manager has been initialised

Specified by:
isInitialised in interface IdTagManager
Returns:
state of initialisation

init

public void init()
Description copied from interface: IdTagManager
Perform initialisation

Specified by:
init in interface IdTagManager

registerSelf

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

Overrides:
registerSelf in class AbstractManager

typeLetter

public char typeLetter()
Specified by:
typeLetter in interface Manager
Returns:
The type 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

provideIdTag

public IdTag provideIdTag(String name)
Description copied from interface: IdTagManager
Locate via tag ID, then user name, and finally system name if needed. If that fails, create a new IdTag. If the name is a valid system name, it will be used for the new IdTag. Otherwise, the makeSystemName method will attempt to turn it into a valid system name.

Specified by:
provideIdTag in interface IdTagManager
Parameters:
name - Tag ID, user name, system name, or address which can be promoted to system name
Returns:
Never null

getIdTag

public IdTag getIdTag(String name)
Description copied from interface: IdTagManager
Locate via tag ID, then by user name, and finally system name if needed. If that fails, return null

Specified by:
getIdTag in interface IdTagManager
Parameters:
name - tag name being requested
Returns:
null if no match found

getBySystemName

public IdTag getBySystemName(String name)
Description copied from interface: IdTagManager
Locate an instance based on a system name. Returns null if no instance already exists.

Specified by:
getBySystemName in interface IdTagManager
Parameters:
name - system name being requested
Returns:
requested IdTag object or null if none exists

getByUserName

public IdTag getByUserName(String key)
Description copied from interface: IdTagManager
Locate an instance based on a user name. Returns null if no instance already exists.

Specified by:
getByUserName in interface IdTagManager
Parameters:
key - user name being requested
Returns:
requested IdTag object or null if none exists

getByTagID

public IdTag getByTagID(String tagID)
Description copied from interface: IdTagManager
Locate an instance based on a tag ID. Returns null if no instance already exists.

Specified by:
getByTagID in interface IdTagManager
Parameters:
tagID - tag ID being requested
Returns:
requested IdTag object or null if none exists

createNewIdTag

protected IdTag createNewIdTag(String systemName,
                               String userName)

newIdTag

public IdTag newIdTag(String systemName,
                      String userName)
Description copied from interface: IdTagManager
Return an instance with the specified system and user names. Note that two calls with the same arguments will get the same instance; there is only one IdTag object representing a given physical IdTag and therefore only one with a specific system or user name.

This will always return a valid object reference; a new object will be created if necessary. In that case:

Note that it is possible to make an inconsistent request if both addresses are provided, but the given values are associated with different objects. This is a problem, and we don't have a good solution except to issue warnings. This will mostly happen if you're creating RfidTags when you should be looking them up.

Specified by:
newIdTag in interface IdTagManager
Returns:
requested IdTag object (never null)

register

public void register(NamedBean s)
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 s)
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

propertyChange

public void propertyChange(PropertyChangeEvent e)
Description copied from class: AbstractManager
The PropertyChangeListener interface in this class is intended to keep track of user name changes to individual NamedBeans. It is not completely implemented yet. In particular, listeners are not added to newly registered objects.

Specified by:
propertyChange in interface PropertyChangeListener
Overrides:
propertyChange in class AbstractManager

writeIdTagDetails

public void writeIdTagDetails()
                       throws IOException
Throws:
IOException

setStateStored

public void setStateStored(boolean state)
Description copied from interface: IdTagManager
Define if the manager should persist details of when and where all known IdTags were seen

Specified by:
setStateStored in interface IdTagManager
Parameters:
state - True to store; False to omit

isStateStored

public boolean isStateStored()
Description copied from interface: IdTagManager
Determines if the state of known IdTags should be stored

Specified by:
isStateStored in interface IdTagManager
Returns:
True to store state; False to discard state

setFastClockUsed

public void setFastClockUsed(boolean fastClock)
Description copied from interface: IdTagManager
Define if the manager should use the fast clock when setting the times when a given IdTag was last seen

Specified by:
setFastClockUsed in interface IdTagManager
Parameters:
fastClock - True to use the fast clock; False to use the system clock

isFastClockUsed

public boolean isFastClockUsed()
Description copied from interface: IdTagManager
Determines if fast clock times should be recorded for when a given IdTag was last seen

Specified by:
isFastClockUsed in interface IdTagManager
Returns:
True to use the fast clock; False to use the system clock

getTagsForReporter

public List<IdTag> getTagsForReporter(Reporter reporter,
                                      long threshold)
Description copied from interface: IdTagManager
Get a list of all IdTags seen by a specified Reporter within a specific time threshold from the most recently seen.

Specified by:
getTagsForReporter in interface IdTagManager
Parameters:
reporter - Reporter to return list for (can be null)
threshold - Time threshold (in ms)
Returns:
List of matching IdTags


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