Class 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.
    • Method Detail

      • 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 consists
        java.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 consists
        java.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 addresses
        fileName - 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 interface java.beans.PropertyChangeListener