Package jmri.jmrit.roster
Class LocoFile
java.lang.Object
jmri.jmrit.XmlFile
jmri.jmrit.roster.LocoFile
Represents and manipulates a locomotive definition, both as a file and in
memory. The internal storage is a JDOM tree. See locomotive-config.xsd
This class is intended for use by RosterEntry only; you should not use it directly. That's why this is not a public class.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class jmri.jmrit.XmlFile
XmlFile.Validate -
Field Summary
Fields inherited from class jmri.jmrit.XmlFile
dtdLocation, xsltLocation -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic voidloadCvModel(org.jdom2.Element loco, CvTableModel cvModel, String mfgID, String family) Load a CvTableModel from the locomotive element in the File.static voidloadVariableModel(org.jdom2.Element loco, VariableTableModel varModel) Load a VariableTableModel from the locomotive element in the Fileprotected static LocoFile.MessageResponseDetermine if a missing variable in decoder definition should be loggedConvert to a canonical text form for ComboBoxes, etc.voidwriteFile(File file, CvTableModel cvModel, VariableTableModel variableModel, RosterEntry r) Write an XML version of this object, including also the RosterEntry information, and memory-resident decoder contents.voidwriteFile(File pFile, org.jdom2.Element pRootElement, RosterEntry pEntry) Write an XML version of this object from an existing XML tree, updating only the ID string.voidWrite an XML version of this object, updating the RosterEntry information, from an existing XML tree.Methods inherited from class jmri.jmrit.XmlFile
addDefaultInfo, backupFileName, checkFile, createFileNameWithDate, dumpElement, findFile, getBuilder, getDefaultDtdLocation, getDefaultValidate, getDtdLocation, getProcessingInstructionHRef, getProcessingInstructionType, getRoot, getValidate, makeBackupFile, makeBackupFile, newDocument, newDocument, revertBackupFile, rootFromFile, rootFromInputStream, rootFromName, rootFromURL, setDefaultDtdLocation, setDefaultValidate, setDtdLocation, setValidate, userFileChooser, userFileChooser, writeXML, xmlDir
-
Constructor Details
-
LocoFile
public LocoFile()
-
-
Method Details
-
titleString
Convert to a canonical text form for ComboBoxes, etc.- Returns:
- loco title.
-
loadCvModel
public static void loadCvModel(org.jdom2.Element loco, CvTableModel cvModel, String mfgID, String family) Load a CvTableModel from the locomotive element in the File.- Parameters:
loco- A JDOM Element containing the locomotive definitioncvModel- An existing CvTableModel object which will have the CVs from the loco Element appended. It is intended, but not required, that this be empty.mfgID- Decoder manufacturer. Used to check if there's need for special treatment.family- Decoder family. Used to check if there's need for special treatment.
-
loadVariableModel
Load a VariableTableModel from the locomotive element in the File- Parameters:
loco- A JDOM Element containing the locomotive definitionvarModel- An existing VariableTableModel object
-
selectMissingVarResponse
Determine if a missing variable in decoder definition should be logged- Parameters:
var- Name of missing variable- Returns:
- Decision on how to handle
-
writeFile
public void writeFile(File file, CvTableModel cvModel, VariableTableModel variableModel, RosterEntry r) Write an XML version of this object, including also the RosterEntry information, and memory-resident decoder contents. Does not do an automatic backup of the file, so that should be done elsewhere.- Parameters:
file- Destination file. This file is overwritten if it exists.cvModel- provides the CV numbers and contentsvariableModel- provides the variable names and contentsr- RosterEntry providing name, etc, information
-
writeFile
Write an XML version of this object from an existing XML tree, updating only the ID string.Does not do an automatic backup of the file, so that should be done elsewhere. This is intended for copy and import operations, where the tree has been read from an existing file. Hence, only the "ID" information in the roster entry is updated. Note that any multi-line comments are not changed here.
- Parameters:
pFile- Destination file. This file is overwritten if it exists.pRootElement- Root element of the JDOM tree to write. This should be of type "locomotive-config", and should not be in use elsewhere (clone it first!)pEntry- RosterEntry providing name, etc, information
-
writeFile
public void writeFile(File pFile, org.jdom2.Element existingElement, org.jdom2.Element newLocomotive) Write an XML version of this object, updating the RosterEntry information, from an existing XML tree.Does not do an automatic backup of the file, so that should be done elsewhere. This is intended for writing out changes to the RosterEntry information only.
- Parameters:
pFile- Destination file. This file is overwritten if it exists.existingElement- Root element of the existing JDOM tree containing the CV and variable contentsnewLocomotive- Element from RosterEntry providing name, etc, information
-
getFileLocation
-