jmri.managers
Class ProxyLightManager

java.lang.Object
  extended by jmri.managers.AbstractProxyManager
      extended by jmri.managers.ProxyLightManager
All Implemented Interfaces:
LightManager, Manager

public class ProxyLightManager
extends AbstractProxyManager
implements LightManager

Implementation of a LightManager that can serves as a proxy for multiple system-specific implementations. The first to be added is the "Primary".

Based on ProxySensorManager

Author:
Dave Duchamp Copyright (C) 2004

Constructor Summary
ProxyLightManager()
           
 
Method Summary
 void activateAllLights()
          Activate the control mechanism for each Light controlled by this LightManager.
 String convertSystemNameToAlternate(String systemName)
          Convert a system name to an alternate format Locate a system specfic LightManager based on a system name.
 Light getBySystemName(String systemName)
          Locate an instance based on a system name.
 Light getByUserName(String userName)
          Locate an instance based on a user name.
 Light getLight(String name)
          Locate via user name, then system name if needed.
 Light newLight(String sysName, String userName)
          Return an instance with the specified system and user names.
 String normalizeSystemName(String systemName)
          Normalize a system name Locate a system specfic LightManager based on a system name.
 Light provideLight(String name)
          Locate via user name, then system name if needed.
 boolean validSystemNameConfig(String systemName)
          Validate system name against the hardware configuration Locate a system specfic LightManager based on a system name.
 boolean validSystemNameFormat(String systemName)
          Validate system name format Locate a system specfic LightManager based on a system name.
 
Methods inherited from class jmri.managers.AbstractProxyManager
addManager, addPropertyChangeListener, deregister, dispose, getSystemNameList, makeSystemName, register, removePropertyChangeListener, systemLetter, typeLetter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.LightManager
dispose, getSystemNameList
 
Methods inherited from interface jmri.Manager
addPropertyChangeListener, deregister, makeSystemName, register, removePropertyChangeListener, systemLetter, typeLetter
 

Constructor Detail

ProxyLightManager

public ProxyLightManager()
Method Detail

getLight

public Light getLight(String name)
Locate via user name, then system name if needed.

Specified by:
getLight in interface LightManager
Parameters:
name -
Returns:
Null if nothing by that name exists

provideLight

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

Specified by:
provideLight in interface LightManager
Parameters:
name -
Returns:
Never null under normal circumstances

getBySystemName

public Light getBySystemName(String systemName)
Locate an instance based on a system name. Returns null if no instance already exists.

Specified by:
getBySystemName in interface LightManager
Returns:
requested Light object or null if none exists

getByUserName

public Light getByUserName(String userName)
Locate an instance based on a user name. Returns null if no instance already exists.

Specified by:
getByUserName in interface LightManager
Returns:
requested Turnout object or null if none exists

newLight

public Light newLight(String sysName,
                      String userName)
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 Light object representing a given physical light and therefore only one with a specific system or user name.

This will always return a valid object reference for a valid request; 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 Lights when you should be looking them up.

Specified by:
newLight in interface LightManager
Returns:
requested Light object (never null)

validSystemNameFormat

public boolean validSystemNameFormat(String systemName)
Validate system name format Locate a system specfic LightManager based on a system name. Returns false if no manager exists. If a manager is found, return its determination of validity of system name format

Specified by:
validSystemNameFormat in interface LightManager

validSystemNameConfig

public boolean validSystemNameConfig(String systemName)
Validate system name against the hardware configuration Locate a system specfic LightManager based on a system name. Returns false if no manager exists. If a manager is found, return its determination of validity of system name relative to the hardware configuration

Specified by:
validSystemNameConfig in interface LightManager

normalizeSystemName

public String normalizeSystemName(String systemName)
Normalize a system name Locate a system specfic LightManager based on a system name. Returns "" if no manager exists. If a manager is found, return its determination of a normalized system name

Specified by:
normalizeSystemName in interface LightManager

convertSystemNameToAlternate

public String convertSystemNameToAlternate(String systemName)
Convert a system name to an alternate format Locate a system specfic LightManager based on a system name. Returns "" if no manager exists. If a manager is found, return its determination of an alternate system name

Specified by:
convertSystemNameToAlternate in interface LightManager

activateAllLights

public void activateAllLights()
Activate the control mechanism for each Light controlled by this LightManager. Relay this call to all LightManagers.

Specified by:
activateAllLights in interface LightManager


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