Package jmri.jmrit.roster
Class LocoFile
- java.lang.Object
-
- jmri.jmrit.XmlFile
-
- jmri.jmrit.roster.LocoFile
-
public class LocoFile extends XmlFile
Represents and manipulates a locomotive definition, both as a file and in memory. The interal storage is a JDOM tree. See locomotive-config.xsdThis 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:
RosterEntry
,Roster
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
LocoFile.MessageResponse
-
Nested classes/interfaces inherited from class jmri.jmrit.XmlFile
XmlFile.Validate
-
-
Field Summary
-
Fields inherited from class jmri.jmrit.XmlFile
dtdLocation, xsltLocation
-
-
Constructor Summary
Constructors Constructor Description LocoFile()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getFileLocation()
static void
loadCvModel(org.jdom2.Element loco, CvTableModel cvModel, java.lang.String mfgID, java.lang.String family)
Load a CvTableModel from the locomotive element in the File.static void
loadVariableModel(org.jdom2.Element loco, VariableTableModel varModel)
Load a VariableTableModel from the locomotive element in the Fileprotected static LocoFile.MessageResponse
selectMissingVarResponse(java.lang.String var)
Determine if a missing variable in decoder definition should be loggedjava.lang.String
titleString()
Convert to a canonical text form for ComboBoxes, etc.void
writeFile(java.io.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.void
writeFile(java.io.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.void
writeFile(java.io.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.-
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 Detail
-
LocoFile
public LocoFile()
-
-
Method Detail
-
titleString
public java.lang.String titleString()
Convert to a canonical text form for ComboBoxes, etc.- Returns:
- loco title.
-
loadCvModel
public static void loadCvModel(org.jdom2.Element loco, CvTableModel cvModel, java.lang.String mfgID, java.lang.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
public static void loadVariableModel(org.jdom2.Element loco, VariableTableModel varModel)
Load a VariableTableModel from the locomotive element in the File- Parameters:
loco
- A JDOM Element containing the locomotive definitionvarModel
- An existing VariableTableModel object
-
selectMissingVarResponse
protected static LocoFile.MessageResponse selectMissingVarResponse(java.lang.String var)
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(java.io.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
public void writeFile(java.io.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. 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(java.io.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
public static java.lang.String getFileLocation()
-
-