Class Roster

java.lang.Object
jmri.jmrit.XmlFile
jmri.jmrit.roster.Roster
All Implemented Interfaces:
PropertyChangeListener, EventListener, PropertyChangeProvider, RosterGroupSelector

public class Roster
extends XmlFile
implements RosterGroupSelector, PropertyChangeProvider, PropertyChangeListener
Roster manages and manipulates a roster of locomotives.

It works with the "roster-config" XML schema to load and store its information.

This is an in-memory representation of the roster xml file (see below for constants defining name and location). As such, this class is also responsible for the "dirty bit" handling to ensure it gets written. As a temporary reliability enhancement, all changes to this structure are now being written to a backup file, and a copy is made when the file is opened.

Multiple Roster objects don't make sense, so we use an "instance" member to navigate to a single one.

The only bound property is the list of RosterEntrys; a PropertyChangedEvent is fired every time that changes.

The entries are stored in an ArrayList, sorted alphabetically. That sort is done manually each time an entry is added.

The roster is stored in a "Roster Index", which can be read or written. Each individual entry (once stored) contains a filename which can be used to retrieve the locomotive information for that roster entry. Note that the RosterEntry information is duplicated in both the Roster (stored in the roster.xml file) and in the specific file for the entry.

Originally, JMRI managed just one global roster, held in a global Roster object. With the rise of more complicated layouts, code has been added to address multiple rosters, with the primary one now held in Roster.default(). We're moving references to Roster.default() out to the using code, so that eventually we can make those explicit references to other Roster objects as/when needed.

See Also:
RosterEntry