jmri
Class AbstractMemoryManager

java.lang.Object
  extended by jmri.AbstractManager
      extended by jmri.AbstractMemoryManager
All Implemented Interfaces:
PropertyChangeListener, EventListener, Manager, MemoryManager
Direct Known Subclasses:
DefaultMemoryManager

public abstract class AbstractMemoryManager
extends AbstractManager
implements MemoryManager

Abstract partial implementation of a MemoryManager.

Author:
Bob Jacobsen Copyright (C) 2004

Field Summary
 
Fields inherited from class jmri.AbstractManager
_tsys, _tuser
 
Constructor Summary
AbstractMemoryManager()
           
 
Method Summary
protected abstract  Memory createNewMemory(String systemName, String userName)
          Internal method to invoke the factory, after all the logic for returning an existing method has been invoked.
 Memory getBySystemName(String key)
          Locate an instance based on a system name.
 Memory getByUserName(String key)
          Locate an instance based on a user name.
 Memory getMemory(String name)
          Locate via user name, then system name if needed.
 Memory newMemory(String sysName, String userName)
          Return an instance with the specified system and user names.
 Memory provideMemory(String name)
          Locate via user name, then system name if needed.
 char typeLetter()
           
 
Methods inherited from class jmri.AbstractManager
addPropertyChangeListener, deregister, dispose, firePropertyChange, getInstanceBySystemName, getInstanceByUserName, getSystemNameList, makeSystemName, propertyChange, register, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.MemoryManager
getSystemNameList
 
Methods inherited from interface jmri.Manager
addPropertyChangeListener, deregister, dispose, makeSystemName, register, removePropertyChangeListener, systemLetter
 

Constructor Detail

AbstractMemoryManager

public AbstractMemoryManager()
Method Detail

typeLetter

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

provideMemory

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

Specified by:
provideMemory in interface MemoryManager
Returns:
Never null under normal circumstances

getMemory

public Memory getMemory(String name)
Description copied from interface: MemoryManager
Locate via user name, then system name if needed. If that fails, return null

Specified by:
getMemory in interface MemoryManager
Returns:
null if no match found

getBySystemName

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

Specified by:
getBySystemName in interface MemoryManager
Returns:
requested Memory object or null if none exists

getByUserName

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

Specified by:
getByUserName in interface MemoryManager
Returns:
requested Memory object or null if none exists

newMemory

public Memory newMemory(String sysName,
                        String userName)
Description copied from interface: MemoryManager
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 Memory object representing a given physical Memory 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 Memory objects when you should be looking them up.

Specified by:
newMemory in interface MemoryManager
Returns:
requested Memory object (never null)

createNewMemory

protected abstract Memory createNewMemory(String systemName,
                                          String userName)
Internal method to invoke the factory, after all the logic for returning an existing method has been invoked.

Returns:
never null


Copyright © 1997 - 2008 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: SourceForge_Logo