Package jmri.managers
Class DeferringProgrammerManager
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.managers.DeferringProgrammerManager
-
- All Implemented Interfaces:
AddressedProgrammerManager
,PropertyChangeFirer
,PropertyChangeProvider
,GlobalProgrammerManager
public class DeferringProgrammerManager extends PropertyChangeSupport implements AddressedProgrammerManager, GlobalProgrammerManager
Defers global programmer operations to the default global Programmer, and addressed programmer operations to the default AddressedProgrammer.The underlying Programmer is looked up for each access to ensure that it is current.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DeferringProgrammerManager.Initializer
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.String
userName
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description DeferringProgrammerManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AddressedProgrammer
getAddressedProgrammer(boolean pLongAddress, int pAddress)
Gain access to a Addressed Mode Programmer without reservation.java.util.List<ProgrammingMode>
getDefaultModes()
Get the list ofProgrammingMode
(generally) supported by Programmers provided by this Manager.Programmer
getGlobalProgrammer()
Gain access to the Global Mode Programmer without reservation.java.lang.String
getUserName()
Provides the human-readable representation for including ProgrammerManagers directly in user interface components, so it should return a user-provided name for this particular one.boolean
isAddressedModePossible()
Default programmer does not provide Ops Modeboolean
isAddressedModePossible(LocoAddress l)
Default programmer doesn't depend on addressboolean
isGlobalProgrammerAvailable()
Allow for implementations that do not support Service mode programmingvoid
releaseAddressedProgrammer(AddressedProgrammer p)
Return access to an Addressed Mode Programmer, so that it can be used elsewhere.void
releaseGlobalProgrammer(Programmer p)
Return access to the Global Mode Programmer, so that it can be used elsewhere.AddressedProgrammer
reserveAddressedProgrammer(boolean pLongAddress, int pAddress)
Gain access to a (the) Addressed Mode Programmer, in the process reserving it for yourself.Programmer
reserveGlobalProgrammer()
Gain access to the Global Mode Programmer, in the process reserving it for yourself.java.lang.String
toString()
Provides the human-readable representation for including ProgrammerManagers directly in user interface components, so it should return a user-provided name for this particular one.-
Methods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.AddressedProgrammerManager
getAddressedProgrammer, reserveAddressedProgrammer
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
userName
java.lang.String userName
-
-
Constructor Detail
-
DeferringProgrammerManager
public DeferringProgrammerManager()
-
-
Method Detail
-
getUserName
public java.lang.String getUserName()
Provides the human-readable representation for including ProgrammerManagers directly in user interface components, so it should return a user-provided name for this particular one.- Specified by:
getUserName
in interfaceAddressedProgrammerManager
- Specified by:
getUserName
in interfaceGlobalProgrammerManager
- Returns:
- the name for the programmer
-
toString
public java.lang.String toString()
Provides the human-readable representation for including ProgrammerManagers directly in user interface components, so it should return a user-provided name for this particular one.- Specified by:
toString
in interfaceAddressedProgrammerManager
- Specified by:
toString
in interfaceGlobalProgrammerManager
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the name for the programmer
-
getGlobalProgrammer
public Programmer getGlobalProgrammer()
Description copied from interface:GlobalProgrammerManager
Gain access to the Global Mode Programmer without reservation.- Specified by:
getGlobalProgrammer
in interfaceGlobalProgrammerManager
- Returns:
- null only if there isn't a Global Mode Programmer available via this Manager.
-
reserveGlobalProgrammer
public Programmer reserveGlobalProgrammer()
Description copied from interface:GlobalProgrammerManager
Gain access to the Global Mode Programmer, in the process reserving it for yourself.- Specified by:
reserveGlobalProgrammer
in interfaceGlobalProgrammerManager
- Returns:
- null if the existing Global Mode programmer is in use
-
releaseGlobalProgrammer
public void releaseGlobalProgrammer(Programmer p)
Description copied from interface:GlobalProgrammerManager
Return access to the Global Mode Programmer, so that it can be used elsewhere.- Specified by:
releaseGlobalProgrammer
in interfaceGlobalProgrammerManager
- Parameters:
p
- the Programmer to release
-
isGlobalProgrammerAvailable
public boolean isGlobalProgrammerAvailable()
Allow for implementations that do not support Service mode programming- Specified by:
isGlobalProgrammerAvailable
in interfaceGlobalProgrammerManager
- Returns:
- false if there's no chance of getting one
-
getAddressedProgrammer
public AddressedProgrammer getAddressedProgrammer(boolean pLongAddress, int pAddress)
Description copied from interface:AddressedProgrammerManager
Gain access to a Addressed Mode Programmer without reservation.- Specified by:
getAddressedProgrammer
in interfaceAddressedProgrammerManager
- Parameters:
pLongAddress
- true if this is a long (14 bit) address, else falsepAddress
- specific decoder address to use- Returns:
- null only if there isn't an Ops Mode Programmer in the system
-
reserveAddressedProgrammer
public AddressedProgrammer reserveAddressedProgrammer(boolean pLongAddress, int pAddress)
Description copied from interface:AddressedProgrammerManager
Gain access to a (the) Addressed Mode Programmer, in the process reserving it for yourself.- Specified by:
reserveAddressedProgrammer
in interfaceAddressedProgrammerManager
- Parameters:
pLongAddress
- true if this is a long (14 bit) address, else falsepAddress
- Specific decoder address to use- Returns:
- null if the address is in use by a reserved programmer
-
releaseAddressedProgrammer
public void releaseAddressedProgrammer(AddressedProgrammer p)
Description copied from interface:AddressedProgrammerManager
Return access to an Addressed Mode Programmer, so that it can be used elsewhere.- Specified by:
releaseAddressedProgrammer
in interfaceAddressedProgrammerManager
- Parameters:
p
- the programmer to release
-
isAddressedModePossible
public boolean isAddressedModePossible()
Default programmer does not provide Ops Mode- Specified by:
isAddressedModePossible
in interfaceAddressedProgrammerManager
- Returns:
- false if there's no chance of getting one
-
isAddressedModePossible
public boolean isAddressedModePossible(LocoAddress l)
Default programmer doesn't depend on address- Specified by:
isAddressedModePossible
in interfaceAddressedProgrammerManager
- Parameters:
l
- the address to get a programmer for- Returns:
- false if there's no chance of getting one
-
getDefaultModes
public java.util.List<ProgrammingMode> getDefaultModes()
Description copied from interface:AddressedProgrammerManager
Get the list ofProgrammingMode
(generally) supported by Programmers provided by this Manager.Use this to enquire about modes before you're ready to request a specific programmer.
If the order is significant, earlier modes are better.
- Specified by:
getDefaultModes
in interfaceAddressedProgrammerManager
- Returns:
- the programming modes or an empty list
-
-