Package jmri.jmrit.consisttool
Class ConsistFile
- java.lang.Object
-
- jmri.jmrit.XmlFile
-
- jmri.jmrit.consisttool.ConsistFile
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
- Direct Known Subclasses:
WiFiConsistFile
public class ConsistFile extends XmlFile implements java.beans.PropertyChangeListener
Handle saving/restoring consist information to XML files. This class manipulates files conforming to the consist-roster-config DTD.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrit.XmlFile
XmlFile.Validate
-
-
Field Summary
Fields Modifier and Type Field Description protected ConsistManager
consistMan
-
Fields inherited from class jmri.jmrit.XmlFile
dtdLocation, xsltLocation
-
-
Constructor Summary
Constructors Constructor Description ConsistFile()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
defaultConsistFilename()
Get the filename for the default Consist file, including location.static java.lang.String
getFileLocation()
GetFile Location.void
propertyChange(java.beans.PropertyChangeEvent evt)
void
readConsistLocoList(org.jdom2.Element consist, Consist newConsist)
void
readFile()
Read all consists from the default file name.void
readFile(java.lang.String fileName)
Read all consists from a file.void
writeFile(java.util.List<LocoAddress> consistList)
Write all consists to the default file name.void
writeFile(java.util.List<LocoAddress> consistList, java.lang.String fileName)
Write all consists to a file.-
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
-
consistMan
protected ConsistManager consistMan
-
-
Constructor Detail
-
ConsistFile
public ConsistFile()
-
-
Method Detail
-
readConsistLocoList
public void readConsistLocoList(org.jdom2.Element consist, Consist newConsist)
-
readFile
public void readFile() throws org.jdom2.JDOMException, java.io.IOException
Read all consists from the default file name.- Throws:
org.jdom2.JDOMException
- if unable to parse consistsjava.io.IOException
- if unable to read file
-
readFile
public void readFile(java.lang.String fileName) throws org.jdom2.JDOMException, java.io.IOException
Read all consists from a file.- Parameters:
fileName
- path to file- Throws:
org.jdom2.JDOMException
- if unable to parse consistsjava.io.IOException
- if unable to read file
-
writeFile
public void writeFile(java.util.List<LocoAddress> consistList) throws java.io.IOException
Write all consists to the default file name.- Parameters:
consistList
- list of consist addresses- Throws:
java.io.IOException
- if unable to write file
-
writeFile
public void writeFile(java.util.List<LocoAddress> consistList, java.lang.String fileName) throws java.io.IOException
Write all consists to a file.- Parameters:
consistList
- list of consist addressesfileName
- path to file- Throws:
java.io.IOException
- if unable to write file
-
getFileLocation
public static java.lang.String getFileLocation()
GetFile Location.- Returns:
- the preferences subdirectory in which Consist Files are kept this is relative to the roster files location.
-
defaultConsistFilename
public static java.lang.String defaultConsistFilename()
Get the filename for the default Consist file, including location.- Returns:
- the filename
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
-