Class FreeColSavegameFile


  • public class FreeColSavegameFile
    extends FreeColDataFile
    Represents a FreeCol savegame.
    • Field Detail

      • VERSION_TAG

        public static final java.lang.String VERSION_TAG
        The tag for the version string in the saved game.
        See Also:
        Constant Field Values
      • SAVEGAME_FILE

        public static final java.lang.String SAVEGAME_FILE
        The name of the file that contains the actual savegame.
        See Also:
        Constant Field Values
      • SAVEGAME_PROPERTIES

        public static final java.lang.String SAVEGAME_PROPERTIES
        The name of a properties file that contains information about the saved game, such as the size of the map, the date and time it was started, and so on. The map size is used in the MapGeneratorOptionsDialog, for example.
        See Also:
        Constant Field Values
      • CLIENT_OPTIONS

        public static final java.lang.String CLIENT_OPTIONS
        The name of the file that contains the ClientOptions saved with the game.
        See Also:
        Constant Field Values
      • THUMBNAIL_FILE

        public static final java.lang.String THUMBNAIL_FILE
        The name of the image file that contains the map thumbnail, i.e. a view of the game map as seen by the owner of the game when saving. The thumbnail image is used by MapGeneratorOptionsDialog..
        See Also:
        Constant Field Values
      • versionList

        private static final java.util.List<java.lang.String> versionList
        Static argument list for getVersion.
    • Constructor Detail

      • FreeColSavegameFile

        public FreeColSavegameFile​(java.io.File file)
                            throws java.io.IOException
        Create a new save game file from a given file.
        Parameters:
        file - The base File.
        Throws:
        java.io.IOException - if the file can not be read.
    • Method Detail

      • peekAttributes

        public java.util.List<java.lang.String> peekAttributes​(java.util.List<java.lang.String> attributes)
                                                        throws java.io.IOException,
                                                               javax.xml.stream.XMLStreamException
        Peek at the attributes in a saved game.
        Parameters:
        attributes - A list of attribute names to peek at.
        Returns:
        A list of corresponding attribute values, or null on error.
        Throws:
        java.io.IOException - if there is a problem reading the attributes.
        javax.xml.stream.XMLStreamException - on stream error.
      • getProperties

        public java.util.Properties getProperties()
                                           throws java.io.IOException
        Get the properties in this save game.
        Returns:
        The Properties found.
        Throws:
        java.io.IOException - if there is a problem reading the properties.
      • getSavegameVersion

        public int getSavegameVersion()
                               throws java.io.IOException,
                                      javax.xml.stream.XMLStreamException
        Gets the save game version from this saved game.
        Returns:
        The saved game version, or negative on error.
        Throws:
        java.io.IOException - if there is a problem reading the attributes.
        javax.xml.stream.XMLStreamException - on stream error.
      • getSavegameInputStream

        public java.io.BufferedInputStream getSavegameInputStream()
                                                           throws java.io.IOException
        Gets the input stream to the saved game data. Only still needed by the validator.
        Returns:
        An InputStream to the save game file within this data file.
        Throws:
        java.io.IOException - if there is a problem opening the input stream.
      • getThumbnailInputStream

        public java.io.BufferedInputStream getThumbnailInputStream()
                                                            throws java.io.IOException
        Gets the input stream to the thumbnail file.
        Returns:
        An InputStream to the thumbnail file within this data file.
        Throws:
        java.io.IOException - if there is a problem opening the input stream.
      • getClientOptionsFreeColXMLReader

        public FreeColXMLReader getClientOptionsFreeColXMLReader()
                                                          throws java.io.IOException,
                                                                 javax.xml.stream.XMLStreamException
        Get a reader for the client options data.
        Returns:
        A reader for the file "client-options.xml" within this file.
        Throws:
        java.io.IOException - if there is a problem opening the input stream.
        javax.xml.stream.XMLStreamException - if there is a problem creating the reader.
      • getSavedGameFreeColXMLReader

        public FreeColXMLReader getSavedGameFreeColXMLReader()
                                                      throws java.io.IOException,
                                                             javax.xml.stream.XMLStreamException
        Get a reader for the saved game data.
        Returns:
        A reader for the file "savegame.xml" within this file.
        Throws:
        java.io.IOException - if there is a problem opening the input stream.
        javax.xml.stream.XMLStreamException - if there is a problem creating the reader.