Package jmri.jmrit.operations.trains
Class TrainManagerXml
- java.lang.Object
-
- jmri.jmrit.XmlFile
-
- jmri.jmrit.operations.OperationsXml
-
- jmri.jmrit.operations.trains.TrainManagerXml
-
- All Implemented Interfaces:
InstanceManagerAutoDefault
,InstanceManagerAutoInitialize
public class TrainManagerXml extends OperationsXml implements InstanceManagerAutoDefault, InstanceManagerAutoInitialize
Loads and stores trains using xml files. Also stores various train parameters managed by the TrainManager.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrit.XmlFile
XmlFile.Validate
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.String
BUILD_STATUS
(package private) static java.lang.String
BUILD_STATUS_BACKUPS
static java.lang.String
CSV_MANIFESTS
static java.lang.String
CSV_SWITCH_LISTS
(package private) static java.lang.String
JSON_MANIFESTS
(package private) static java.lang.String
MANIFESTS
(package private) static java.lang.String
MANIFESTS_BACKUPS
(package private) static java.lang.String
SWITCH_LISTS
(package private) static java.lang.String
SWITCH_LISTS_BACKUPS
-
Fields inherited from class jmri.jmrit.XmlFile
dtdLocation, xsltLocation
-
-
Constructor Summary
Constructors Constructor Description TrainManagerXml()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.File
createCsvSwitchListFile(java.lang.String name)
Store the CSV switch list for a locationvoid
createDefaultCsvManifestDirectory()
void
createDefaultCsvSwitchListDirectory()
java.io.File
createManifestFile(java.lang.String name, java.lang.String ext)
Store the Json manifest for a trainjava.io.File
createSwitchListFile(java.lang.String name)
Store the switch list for a locationjava.io.File
createTrainBuildReportFile(java.lang.String name)
Store the train's build reportjava.io.File
createTrainCsvManifestFile(java.lang.String name)
Store the CSV train manifestjava.io.File
createTrainManifestFile(java.lang.String name)
Creates the train's manifest file.java.lang.String
defaultBuildReportFileName(java.lang.String name)
void
dispose()
java.lang.String
getBackupBuildStatusDirectoryName()
java.lang.String
getBackupBuildStatusDirectoryName(java.lang.String name)
java.lang.String
getBackupBuildStatusFileName(java.lang.String name, java.lang.String lastModified)
java.lang.String
getBackupManifestDirectoryName()
java.lang.String
getBackupManifestDirectoryName(java.lang.String name)
java.lang.String
getBackupManifestFileName(java.lang.String name, java.lang.String lastModified)
java.lang.String
getBackupSwitchListDirectoryName()
java.lang.String
getBackupSwitchListDirectoryName(java.lang.String name)
java.lang.String
getBackupSwitchListFileName(java.lang.String name, java.lang.String lastModified)
java.io.File
getCsvSwitchListFile(java.lang.String name)
java.lang.String
getDefaultCsvManifestFileName(java.lang.String name)
java.lang.String
getDefaultCsvSwitchListDirectoryName()
java.lang.String
getDefaultCsvSwitchListFileName(java.lang.String name)
java.lang.String
getDefaultManifestFileName(java.lang.String name)
java.lang.String
getDefaultSwitchListName(java.lang.String name)
java.io.File
getManifestFile(java.lang.String name, java.lang.String ext)
java.lang.String
getOperationsFileName()
java.io.File
getSwitchListFile(java.lang.String name)
java.io.File
getTrainBuildReportFile(java.lang.String name)
java.io.File
getTrainCsvManifestFile(java.lang.String name)
java.io.File
getTrainManifestFile(java.lang.String name)
void
initialize()
Perform any initialization that occurs after this object has been constructed and made available by the InstanceManager.boolean
isTrainFileLoaded()
void
readFile(java.lang.String name)
Read the contents of a roster XML file into this object.void
savePreviousBuildStatusFile(java.lang.String name)
Save previous train build status file in a separate directory called BuildStatusBackups.void
setOperationsFileName(java.lang.String name)
void
writeFile(java.lang.String name)
-
Methods inherited from class jmri.jmrit.operations.OperationsXml
areFilesDirty, checkFileName, createFile, getDefaultOperationsFilename, getFileLocation, getOperationsDirectoryName, isDirty, load, save, setDirty, setFileLocation, setOperationsDirectoryName, writeFileIfDirty, writeOperationsFile
-
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
-
-
-
-
Field Detail
-
BUILD_STATUS
static final java.lang.String BUILD_STATUS
- See Also:
- Constant Field Values
-
MANIFESTS
static final java.lang.String MANIFESTS
- See Also:
- Constant Field Values
-
SWITCH_LISTS
static final java.lang.String SWITCH_LISTS
- See Also:
- Constant Field Values
-
CSV_MANIFESTS
public static final java.lang.String CSV_MANIFESTS
- See Also:
- Constant Field Values
-
CSV_SWITCH_LISTS
public static final java.lang.String CSV_SWITCH_LISTS
- See Also:
- Constant Field Values
-
JSON_MANIFESTS
static final java.lang.String JSON_MANIFESTS
- See Also:
- Constant Field Values
-
MANIFESTS_BACKUPS
static final java.lang.String MANIFESTS_BACKUPS
- See Also:
- Constant Field Values
-
SWITCH_LISTS_BACKUPS
static final java.lang.String SWITCH_LISTS_BACKUPS
- See Also:
- Constant Field Values
-
BUILD_STATUS_BACKUPS
static final java.lang.String BUILD_STATUS_BACKUPS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TrainManagerXml
public TrainManagerXml()
-
-
Method Detail
-
writeFile
public void writeFile(java.lang.String name) throws java.io.FileNotFoundException, java.io.IOException
- Overrides:
writeFile
in classOperationsXml
- Throws:
java.io.FileNotFoundException
java.io.IOException
-
readFile
public void readFile(java.lang.String name) throws org.jdom2.JDOMException, java.io.IOException
Read the contents of a roster XML file into this object. Note that this does not clear any existing entries.- Specified by:
readFile
in classOperationsXml
- Parameters:
name
- The string file name.- Throws:
org.jdom2.JDOMException
- Due to XML parsing errorjava.io.IOException
- Due to trouble accessing named file
-
isTrainFileLoaded
public boolean isTrainFileLoaded()
-
createTrainBuildReportFile
public java.io.File createTrainBuildReportFile(java.lang.String name)
Store the train's build report- Parameters:
name
- Full path name for train build report- Returns:
- Build report File.
-
getTrainBuildReportFile
public java.io.File getTrainBuildReportFile(java.lang.String name)
-
defaultBuildReportFileName
public java.lang.String defaultBuildReportFileName(java.lang.String name)
-
createTrainManifestFile
public java.io.File createTrainManifestFile(java.lang.String name)
Creates the train's manifest file.- Parameters:
name
- Full path name for manifest file.- Returns:
- Manifest File.
-
getTrainManifestFile
public java.io.File getTrainManifestFile(java.lang.String name)
-
getDefaultManifestFileName
public java.lang.String getDefaultManifestFileName(java.lang.String name)
-
getBackupManifestFileName
public java.lang.String getBackupManifestFileName(java.lang.String name, java.lang.String lastModified)
-
getBackupManifestDirectoryName
public java.lang.String getBackupManifestDirectoryName()
-
getBackupManifestDirectoryName
public java.lang.String getBackupManifestDirectoryName(java.lang.String name)
-
getBackupSwitchListFileName
public java.lang.String getBackupSwitchListFileName(java.lang.String name, java.lang.String lastModified)
-
getBackupSwitchListDirectoryName
public java.lang.String getBackupSwitchListDirectoryName()
-
getBackupSwitchListDirectoryName
public java.lang.String getBackupSwitchListDirectoryName(java.lang.String name)
-
getBackupBuildStatusFileName
public java.lang.String getBackupBuildStatusFileName(java.lang.String name, java.lang.String lastModified)
-
getBackupBuildStatusDirectoryName
public java.lang.String getBackupBuildStatusDirectoryName()
-
getBackupBuildStatusDirectoryName
public java.lang.String getBackupBuildStatusDirectoryName(java.lang.String name)
-
createTrainCsvManifestFile
public java.io.File createTrainCsvManifestFile(java.lang.String name)
Store the CSV train manifest- Parameters:
name
- Full path name to CSV train manifest file.- Returns:
- Train CSV manifest File.
-
getTrainCsvManifestFile
public java.io.File getTrainCsvManifestFile(java.lang.String name)
-
getDefaultCsvManifestFileName
public java.lang.String getDefaultCsvManifestFileName(java.lang.String name)
-
createDefaultCsvManifestDirectory
public void createDefaultCsvManifestDirectory()
-
createManifestFile
public java.io.File createManifestFile(java.lang.String name, java.lang.String ext)
Store the Json manifest for a train- Parameters:
name
- file nameext
- file extension to use- Returns:
- Json manifest File
-
getManifestFile
public java.io.File getManifestFile(java.lang.String name, java.lang.String ext)
-
createSwitchListFile
public java.io.File createSwitchListFile(java.lang.String name)
Store the switch list for a location- Parameters:
name
- The location's name, to become file name.- Returns:
- Switch list File.
-
getSwitchListFile
public java.io.File getSwitchListFile(java.lang.String name)
-
getDefaultSwitchListName
public java.lang.String getDefaultSwitchListName(java.lang.String name)
-
createCsvSwitchListFile
public java.io.File createCsvSwitchListFile(java.lang.String name)
Store the CSV switch list for a location- Parameters:
name
- Location's name, to become file name.- Returns:
- CSV switch list File.
-
getCsvSwitchListFile
public java.io.File getCsvSwitchListFile(java.lang.String name)
-
getDefaultCsvSwitchListFileName
public java.lang.String getDefaultCsvSwitchListFileName(java.lang.String name)
-
getDefaultCsvSwitchListDirectoryName
public java.lang.String getDefaultCsvSwitchListDirectoryName()
-
createDefaultCsvSwitchListDirectory
public void createDefaultCsvSwitchListDirectory()
-
setOperationsFileName
public void setOperationsFileName(java.lang.String name)
- Overrides:
setOperationsFileName
in classOperationsXml
-
getOperationsFileName
public java.lang.String getOperationsFileName()
- Overrides:
getOperationsFileName
in classOperationsXml
-
savePreviousBuildStatusFile
public void savePreviousBuildStatusFile(java.lang.String name)
Save previous train build status file in a separate directory called BuildStatusBackups. Each build status is saved in a unique directory using the train's name.- Parameters:
name
- train's name
-
dispose
public void dispose()
-
initialize
public void initialize()
Description copied from interface:InstanceManagerAutoInitialize
Perform any initialization that occurs after this object has been constructed and made available by the InstanceManager.- Specified by:
initialize
in interfaceInstanceManagerAutoInitialize
-
-