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.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:
RosterEntry, Roster
  • Constructor Details

  • Method Details

    • titleString

      public String titleString()
      Convert to a canonical text form for ComboBoxes, etc.
      Returns:
      loco title.
    • loadCvModel

      public static void loadCvModel​(Element loco, CvTableModel cvModel, String family)
      Load a CvTableModel from the locomotive element in the File.
      Parameters:
      loco - A JDOM Element containing the locomotive definition
      cvModel - An existing CvTableModel object which will have the CVs from the loco Element appended. It is intended, but not required, that this be empty.
      family - unused.
    • loadVariableModel

      public static void loadVariableModel​(Element loco, VariableTableModel varModel)
      Load a VariableTableModel from the locomotive element in the File
      Parameters:
      loco - A JDOM Element containing the locomotive definition
      varModel - 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 contents
      variableModel - provides the variable names and contents
      r - RosterEntry providing name, etc, information
    • writeFile

      public void writeFile​(File pFile, 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​(File pFile, Element existingElement, 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 contents
      newLocomotive - Element from RosterEntry providing name, etc, information
    • getFileLocation

      public static String getFileLocation()