Package jmri.implementation
Class AbstractConsistManager
- java.lang.Object
-
- jmri.implementation.AbstractConsistManager
-
- All Implemented Interfaces:
ConsistManager
- Direct Known Subclasses:
DccConsistManager
,EasyDccConsistManager
,InternalConsistManager
,LocoNetConsistManager
,MqttConsistManager
,NceConsistManager
,NmraConsistManager
,XNetConsistManager
public abstract class AbstractConsistManager extends java.lang.Object implements ConsistManager
An Abstract Consist Manager on top of which system specific consist managers can be built.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jmri.ConsistManager
ConsistManager.EnableListener
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<LocoAddress,Consist>
consistTable
-
Constructor Summary
Constructors Constructor Description AbstractConsistManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Consist
addConsist(LocoAddress address)
Add a new Consist with the given address.void
addConsistListListener(ConsistListListener l)
Register a ConsistListListener object with this ConsistManagerjava.lang.String
decodeErrorCode(int errorCode)
Translate Error Codes relieved by a consistListener into Stringsvoid
delConsist(LocoAddress address)
Remove an old Consist.Consist
getConsist(LocoAddress address)
Find a Consist with this consist address, and return it.java.util.ArrayList<LocoAddress>
getConsistList()
Return the list of consists we know about.void
notifyConsistListChanged()
Notify the registered ConsistListListener objects that the ConsistList has changed.void
removeConsistListListener(ConsistListListener l)
Remove a ConsistListListener object with this ConsistManagervoid
requestUpdateFromLayout()
Request an update from the layout, loading Consists from the command station.protected boolean
shouldRequestUpdateFromLayout()
Allow a request for consist updates from the layout.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.ConsistManager
canBeDisabled, csConsistNeedsSeperateAddress, isCommandStationConsistPossible, isEnabled, registerEnableListener, unregisterEnableListener
-
-
-
-
Field Detail
-
consistTable
protected java.util.HashMap<LocoAddress,Consist> consistTable
-
-
Constructor Detail
-
AbstractConsistManager
public AbstractConsistManager()
-
-
Method Detail
-
getConsist
public Consist getConsist(LocoAddress address)
Find a Consist with this consist address, and return it.- Specified by:
getConsist
in interfaceConsistManager
- Parameters:
address
- the consist address- Returns:
- an existing or new consist
-
addConsist
protected abstract Consist addConsist(LocoAddress address)
Add a new Consist with the given address.- Parameters:
address
- consist address- Returns:
- a consist at address; this will be the existing consist if a consist is already known to exist at address
-
delConsist
public void delConsist(LocoAddress address)
Description copied from interface:ConsistManager
Remove an old Consist.- Specified by:
delConsist
in interfaceConsistManager
- Parameters:
address
- the consist address
-
getConsistList
public java.util.ArrayList<LocoAddress> getConsistList()
Return the list of consists we know about.- Specified by:
getConsistList
in interfaceConsistManager
- Returns:
- list of addresses
-
decodeErrorCode
public java.lang.String decodeErrorCode(int errorCode)
Description copied from interface:ConsistManager
Translate Error Codes relieved by a consistListener into Strings- Specified by:
decodeErrorCode
in interfaceConsistManager
- Parameters:
errorCode
- the code- Returns:
- the description
-
requestUpdateFromLayout
public void requestUpdateFromLayout()
Description copied from interface:ConsistManager
Request an update from the layout, loading Consists from the command station.- Specified by:
requestUpdateFromLayout
in interfaceConsistManager
-
shouldRequestUpdateFromLayout
protected boolean shouldRequestUpdateFromLayout()
Allow a request for consist updates from the layout. If not overridden by a concrete subclass, this method always returns true.- Returns:
- true if the request can be made, false if not
-
addConsistListListener
public void addConsistListListener(ConsistListListener l)
Description copied from interface:ConsistManager
Register a ConsistListListener object with this ConsistManager- Specified by:
addConsistListListener
in interfaceConsistManager
- Parameters:
l
- a Consist List Listener object.
-
removeConsistListListener
public void removeConsistListListener(ConsistListListener l)
Description copied from interface:ConsistManager
Remove a ConsistListListener object with this ConsistManager- Specified by:
removeConsistListListener
in interfaceConsistManager
- Parameters:
l
- a Consist List Listener object.
-
notifyConsistListChanged
public void notifyConsistListChanged()
Description copied from interface:ConsistManager
Notify the registered ConsistListListener objects that the ConsistList has changed.- Specified by:
notifyConsistListChanged
in interfaceConsistManager
-
-