Class RosterEntry
- All Implemented Interfaces:
BasicRosterEntry,BeanInterface,PropertyChangeFirer,PropertyChangeProvider,RosterObject
The RosterEntry is the central place to find information about a locomotive's configuration, including CV and "programming variable" information. RosterEntry handles persistence through the LocoFile class. Creating a RosterEntry does not necessarily read the corresponding file (which might not even exist), please see readFile(), writeFile() member functions.
All the data attributes have a content, not null. FileName, however, is special. A null value for it indicates that no physical file is (yet) associated with this entry.
When the filePath attribute is non-null, the user has decided to organize the roster into directories.
Each entry can have one or more "Attributes" associated with it. These are (key, value) pairs. The key has to be unique, and currently both objects have to be Strings.
All properties, including the "Attributes", are bound.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected intprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected LocoAddress.Protocolprotected Stringprotected Stringprotected RosterSpeedProfileprotected Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Datestatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String(package private) String(package private) int(package private) booleanstatic final Stringstatic final Stringstatic final Stringstatic final String(package private) String(package private) intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class jmri.beans.ArbitraryBean
arbitraryPropertySupportFields inherited from class jmri.beans.Bean
propertyChangeSupport -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a blank object.RosterEntry(String fileName) Constructor based on a given file name.RosterEntry(RosterEntry pEntry, String pID) Constructor based on a given RosterEntry object and name/ID.RosterEntry(org.jdom2.Element e) Construct this Entry from XML. -
Method Summary
Modifier and TypeMethodDescriptionvoidMark the date updated, e.g. from storing this roster entry.voiddeleteAttribute(String key) voidEnsure the entry has a valid filename.static RosterEntryCreate a RosterEntry from a file.getAttribute(String key) String[]Provide access to the set of attributes.Get the date this entry was last modified.Get the formatted single-line String for displaying the object.getFunctionImage(int fn) getFunctionLabel(int fn) If a label has been defined for a specific function, return it, otherwise return null.booleangetFunctionLockable(int fn) Return the lockable/latchable state of a specific function.getFunctionSelectedImage(int fn) booleangetFunctionVisible(int fn) Return the UI visibility of a specific function button.List the roster groups this entry is a member of, returning existingRosterGroups from the defaultRosterif they exist.List the roster groups this entry is a member of, returning existingRosterGroups from the specifiedRosterif they exist.getId()intGet the highest valid Fn key number for this roster entry.intgetMfg()getModel()getOwner()Get the modes as defined in a roster entry's decoder definition.getSoundLabel(int fn) If a label has been defined for a specific sound, return it, otherwise return null.getURL()booleanbooleanisOpen()voidloadAttributes(org.jdom2.Element e3) Load attribute key/value pairs from a JDOM element.voidloadCvModel(VariableTableModel varModel, CvTableModel cvModel) Load pre-existing Variable and CvTableModel object with the contents of this entry.voidloadFunctions(org.jdom2.Element e3) Load function names from a JDOM element.voidloadFunctions(org.jdom2.Element e3, String source) Loads function names from a JDOM element.voidloadSounds(org.jdom2.Element e3, String source) Loads sound names from a JDOM element.voidvoidPrint the roster entry information.voidUltra-compact list view of roster entries.voidputAttribute(String key, String value) voidreadFile()Read a file containing the contents of this RosterEntry.voidsetComment(String s) voidsetDateModified(String date) Set the date modified given a string representing a date.voidsetDateModified(Date date) protected voidSet the date last updated.voidvoidvoidvoidvoidvoidSet the file name for this roster entry.voidsetFunctionImage(int fn, String s) voidsetFunctionLabel(int fn, String label) Set the label for a specific function.voidsetFunctionLockable(int fn, boolean lockable) Define whether a specific function is lockable.voidsetFunctionSelectedImage(int fn, String s) voidsetFunctionVisible(int fn, boolean visible) Define whether a specific function button is visible.voidvoidSet the roster ID for this roster entry.voidvoidsetLongAddress(boolean b) voidvoidvoidsetMaxSpeedPCT(int maxSpeedPCT) voidvoidvoidsetOpen(boolean boo) voidvoidvoidSet programming modes as defined in a roster entry's decoder definition.voidsetProtocol(LocoAddress.Protocol protocol) voidvoidvoidvoidsetSoundLabel(int fn, String label) Define label for a specific sound.voidvoidorg.jdom2.Elementstore()Create an XML element to represent this Entry.toString()voidWrite the contents of this RosterEntry back to a file, preserving all existing decoder CV content.protected voidwarnShortLong(String id) Warn user that the roster entry needs to be resaved.wrapComment(String comment, int textSpace) Line wrap a comment.voidwriteFile(CvTableModel cvModel, VariableTableModel variableModel) Write the contents of this RosterEntry to a file.Methods inherited from class jmri.beans.ArbitraryBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setPropertyMethods inherited from class jmri.beans.Bean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, isNotifyOnEDT, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.BasicRosterEntry
addPropertyChangeListener, removePropertyChangeListenerMethods inherited from interface jmri.beans.BeanInterface
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setProperty
-
Field Details
-
ID
- See Also:
-
FILENAME
- See Also:
-
ROADNAME
- See Also:
-
MFG
- See Also:
-
MODEL
- See Also:
-
OWNER
- See Also:
-
DCC_ADDRESS
- See Also:
-
LONG_ADDRESS
- See Also:
-
PROTOCOL
- See Also:
-
COMMENT
- See Also:
-
DECODER_MODEL
- See Also:
-
DECODER_DEVELOPERID
- See Also:
-
DECODER_MANUFACTURERID
- See Also:
-
DECODER_PRODUCTID
- See Also:
-
PROGRAMMING
- See Also:
-
DECODER_FAMILY
- See Also:
-
DECODER_MODES
- See Also:
-
DECODER_COMMENT
- See Also:
-
DECODER_MAXFNNUM
- See Also:
-
DEFAULT_MAXFNNUM
- See Also:
-
IMAGE_FILE_PATH
- See Also:
-
ICON_FILE_PATH
- See Also:
-
URL
- See Also:
-
DATE_UPDATED
- See Also:
-
FUNCTION_IMAGE
- See Also:
-
FUNCTION_LABEL
- See Also:
-
FUNCTION_LOCKABLE
- See Also:
-
FUNCTION_SELECTED_IMAGE
- See Also:
-
ATTRIBUTE_UPDATED
- See Also:
-
ATTRIBUTE_DELETED
- See Also:
-
MAX_SPEED
- See Also:
-
SHUNTING_FUNCTION
- See Also:
-
SPEED_PROFILE
- See Also:
-
SOUND_LABEL
- See Also:
-
ATTRIBUTE_OPERATING_DURATION
- See Also:
-
ATTRIBUTE_LAST_OPERATED
- See Also:
-
_fileName
-
_id
-
_roadName
-
_roadNumber
-
_mfg
-
_owner
-
_model
-
_dccAddress
-
_protocol
-
_comment
-
_decoderModel
-
_decoderFamily
-
_decoderComment
-
_maxFnNum
-
_dateUpdated
-
dateModified
-
_maxSpeedPCT
-
_developerID
-
_manufacturerID
-
_productID
-
_programmingModes
-
functionLabels
-
soundLabels
-
functionSelectedImages
-
functionImages
-
functionLockables
-
functionVisibles
-
_isShuntingOn
-
attributePairs
-
_imageFilePath
-
_iconFilePath
-
_URL
-
_sp
-
openCounter
int openCounter -
loadedOnce
boolean loadedOnce -
indent
-
indentWidth
int indentWidth -
newLine
-
-
Constructor Details
-
RosterEntry
public RosterEntry()Construct a blank object. -
RosterEntry
Constructor based on a given file name.- Parameters:
fileName- xml file name for the user's Roster entry
-
RosterEntry
Constructor based on a given RosterEntry object and name/ID.- Parameters:
pEntry- RosterEntry objectpID- unique name/ID for the roster entry
-
RosterEntry
Construct this Entry from XML.This member has to remain synchronized with the detailed schema in xml/schema/locomotive-config.xsd.
- Parameters:
e- Locomotive XML element
-
-
Method Details
-
getMaxFnNumAsInt
Get the highest valid Fn key number for this roster entry.- The default value (28) can be overridden by a "maxFnNum" attribute in the "model" element of a decoder definition file
- A European standard (RCN-212) extends NMRA S9.2.1 up to F68.
- ESU LokSound 5 already uses up to F31.
- Returns:
- the highest function number (Fn) supported by this roster entry.
- See Also:
-
- "http://normen.railcommunity.de/RCN-212.pdf"
-
setId
Set the roster ID for this roster entry.- Parameters:
s- new ID
-
getId
- Specified by:
getIdin interfaceBasicRosterEntry
-
setFileName
Set the file name for this roster entry.- Parameters:
s- the new roster entry file name
-
getFileName
-
getPathName
-
ensureFilenameExists
Ensure the entry has a valid filename.If none exists, create one based on the ID string. Does _not_ enforce any particular naming; you have to check separately for "<none>" or whatever your convention is for indicating an invalid name. Does replace the space, period, colon, slash and backslash characters so that the filename will be generally usable.
-
setRoadName
-
getRoadName
-
setRoadNumber
-
getRoadNumber
-
setMfg
-
getMfg
-
setModel
-
getModel
-
setOwner
-
getOwner
-
setDccAddress
-
getDccAddress
- Specified by:
getDccAddressin interfaceBasicRosterEntry
-
setLongAddress
-
getSpeedProfile
-
setSpeedProfile
-
isLongAddress
- Specified by:
isLongAddressin interfaceBasicRosterEntry
-
setProtocol
-
getProtocol
-
getProtocolAsString
-
setComment
-
getComment
-
setDecoderModel
-
getDecoderModel
-
setDeveloperID
-
getDeveloperID
-
setManufacturerID
-
getManufacturerID
-
setProductID
-
getProductID
-
setProgrammingModes
Set programming modes as defined in a roster entry's decoder definition.- Parameters:
s- a comma separated string of predefined mode elements
-
getProgrammingModes
Get the modes as defined in a roster entry's decoder definition.- Returns:
- a comma separated string of predefined mode elements
-
setDecoderFamily
-
getDecoderFamily
-
setDecoderComment
-
getDecoderComment
-
setMaxFnNum
-
getMaxFnNum
-
getDccLocoAddress
- Specified by:
getDccLocoAddressin interfaceBasicRosterEntry
-
setImagePath
-
getImagePath
-
setIconPath
-
getIconPath
-
setShuntingFunction
-
getShuntingFunction
- Specified by:
getShuntingFunctionin interfaceBasicRosterEntry
-
setURL
-
getURL
-
setDateModified
-
setDateModified
Set the date modified given a string representing a date.Tries ISO 8601 and the current Java defaults as formats for parsing a date.
- Parameters:
date- the string to parse into a date- Throws:
ParseException- if the date cannot be parsed
-
getDateModified
-
setDateUpdated
Set the date last updated.- Parameters:
s- the string to parse into a date
-
getDateUpdated
Get the date this entry was last modified. Returns the value ofgetDateModified()in ISO 8601 format if that is not null, otherwise returns the raw value for the last modified date from the XML file for the roster entry.Use getDateModified() if control over formatting is required
- Returns:
- the string representation of the date last modified
-
setOpen
- Specified by:
setOpenin interfaceBasicRosterEntry
-
isOpen
- Specified by:
isOpenin interfaceBasicRosterEntry
-
loadFunctions
Load function names from a JDOM element.Does not change values that are already present!
- Parameters:
e3- the XML element containing functions
-
loadFunctions
Loads function names from a JDOM element. Does not change values that are already present!- Parameters:
e3- the XML element containing the functionssource- "family" if source is the decoder definition, or "model" if source is the roster entry itself
-
loadSounds
Loads sound names from a JDOM element. Does not change values that are already present!- Parameters:
e3- the XML element containing sound namessource- "family" if source is the decoder definition, or "model" if source is the roster entry itself
-
loadAttributes
Load attribute key/value pairs from a JDOM element.- Parameters:
e3- XML element containing roster entry attributes
-
setFunctionLabel
Set the label for a specific function.- Parameters:
fn- function number, starting with 0label- the label to use
-
getFunctionLabel
If a label has been defined for a specific function, return it, otherwise return null.- Parameters:
fn- function number, starting with 0- Returns:
- function label or null if not defined
-
setSoundLabel
Define label for a specific sound.- Parameters:
fn- sound number, starting with 0label- display label for the sound function
-
getSoundLabel
If a label has been defined for a specific sound, return it, otherwise return null.- Parameters:
fn- sound number, starting with 0- Returns:
- sound label or null
-
setFunctionImage
-
getFunctionImage
-
setFunctionSelectedImage
-
getFunctionSelectedImage
-
setFunctionLockable
Define whether a specific function is lockable.- Parameters:
fn- function number, starting with 0lockable- true if function is continuous; false if momentary
-
getFunctionLockable
Return the lockable/latchable state of a specific function. Defaults to true.- Parameters:
fn- function number, starting with 0- Returns:
- true if function is lockable/latchable
-
setFunctionVisible
Define whether a specific function button is visible.- Parameters:
fn- function number, starting with 0visible- true if function button is visible; false to hide
-
getFunctionVisible
Return the UI visibility of a specific function button. Defaults to true.- Parameters:
fn- function number, starting with 0- Returns:
- true if function button is visible
-
putAttribute
- Specified by:
putAttributein interfaceBasicRosterEntry
-
getAttribute
- Specified by:
getAttributein interfaceBasicRosterEntry
-
deleteAttribute
- Specified by:
deleteAttributein interfaceBasicRosterEntry
-
getAttributes
Provide access to the set of attributes.This is directly backed access, so e.g. removing an item from this Set removes it from the RosterEntry too.
- Returns:
- a set of attribute keys
-
getAttributeList
- Specified by:
getAttributeListin interfaceBasicRosterEntry
-
getGroups
List the roster groups this entry is a member of, returning existingRosterGroups from the defaultRosterif they exist.- Returns:
- list of roster groups
-
getGroups
List the roster groups this entry is a member of, returning existingRosterGroups from the specifiedRosterif they exist.- Parameters:
roster- the roster to get matching groups from- Returns:
- list of roster groups
-
getMaxSpeedPCT
- Specified by:
getMaxSpeedPCTin interfaceBasicRosterEntry
-
setMaxSpeedPCT
-
warnShortLong
Warn user that the roster entry needs to be resaved.- Parameters:
id- roster ID to warn about
-
store
Create an XML element to represent this Entry.This member has to remain synchronized with the detailed schema in xml/schema/locomotive-config.xsd.
- Specified by:
storein interfaceBasicRosterEntry- Returns:
- Contents in a JDOM Element
-
titleString
- Specified by:
titleStringin interfaceBasicRosterEntry
-
toString
- Specified by:
toStringin interfaceBasicRosterEntry- Overrides:
toStringin classObject
-
updateFile
Write the contents of this RosterEntry back to a file, preserving all existing decoder CV content.This writes the file back in place, with the same decoder-specific content.
-
writeFile
Write the contents of this RosterEntry to a file.Information on the contents is passed through the parameters, as the actual XML creation is done in the LocoFile class.
- Parameters:
cvModel- CV contents to include in filevariableModel- Variable contents to include in file
-
changeDateUpdated
Mark the date updated, e.g. from storing this roster entry. -
loadCvModel
Load pre-existing Variable and CvTableModel object with the contents of this entry.- Parameters:
varModel- the variable model to loadcvModel- CV contents to load
-
printEntryLine
Ultra-compact list view of roster entries. Shows text from fields as initially visible in the Roster frame table.Header is created in
PrintListAction.actionPerformed(java.awt.event.ActionEvent)so keep column widths identical with values of colWidth below.- Parameters:
w- writer providing output
-
printEntry
-
printEntryDetails
Print the roster entry information.Updated to allow for multiline comment and decoder comment fields. Separate write statements for text and line feeds to work around the HardcopyWriter bug that misplaces borders.
- Parameters:
w- the HardcopyWriter used to print
-
wrapComment
Line wrap a comment.- Parameters:
comment- the comment to wrap at word boundariestextSpace- the width of the space to print- Returns:
- comment wrapped to fit given width
-
readFile
Read a file containing the contents of this RosterEntry.This has to be done before a call to loadCvModel, for example.
-
fromFile
Create a RosterEntry from a file.- Parameters:
file- The file containing the RosterEntry- Returns:
- a new RosterEntry
- Throws:
org.jdom2.JDOMException- if unable to parse fileIOException- if unable to read file
-
getDisplayName
Description copied from interface:RosterObjectGet the formatted single-line String for displaying the object.- Specified by:
getDisplayNamein interfaceRosterObject- Returns:
- a formatted name
-