Class MapMenuLoader


  • public class MapMenuLoader
    extends java.lang.Object
    Saves or restores MapMenu contents to Preferences.
    • Constructor Summary

      Constructors 
      Constructor Description
      MapMenuLoader​(@NotNull java.lang.String key, @NotNull PathManager pathManager)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @NotNull MapMenuLoader.Result loadEntry​(int index)
      Loads an entry from preferences.
      int loadNumEntries()
      Returns the number of entries present in the preferences.
      void removeEntry​(int index)
      Removes an entry.
      void saveEntry​(int index, @NotNull java.lang.String title, @NotNull java.lang.String filename, @NotNull java.lang.String directory, @NotNull MapMenuLoader.Type type)
      Saves an entry to preferences.
      void saveNumEntries​(int num)
      Sets the number of entries present in the preferences.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MapMenuLoader

        public MapMenuLoader​(@NotNull
                             @NotNull java.lang.String key,
                             @NotNull
                             @NotNull PathManager pathManager)
        Creates a new instance.
        Parameters:
        key - the preferences key prefix
        pathManager - the global path manager instance
    • Method Detail

      • loadNumEntries

        public int loadNumEntries()
        Returns the number of entries present in the preferences.
        Returns:
        the number of entries
      • saveNumEntries

        public void saveNumEntries​(int num)
        Sets the number of entries present in the preferences.
        Parameters:
        num - the number of entries
      • loadEntry

        @NotNull
        public @NotNull MapMenuLoader.Result loadEntry​(int index)
                                                throws java.io.IOException
        Loads an entry from preferences.
        Parameters:
        index - the preference index
        Returns:
        the entry or null
        Throws:
        java.io.IOException - if the entry cannot be loaded
      • saveEntry

        public void saveEntry​(int index,
                              @NotNull
                              @NotNull java.lang.String title,
                              @NotNull
                              @NotNull java.lang.String filename,
                              @NotNull
                              @NotNull java.lang.String directory,
                              @NotNull
                              @NotNull MapMenuLoader.Type type)
        Saves an entry to preferences.
        Parameters:
        index - the preference index
        title - the entry's title
        filename - the entry's file name
        directory - the entry's directory
        type - the entry's type
      • removeEntry

        public void removeEntry​(int index)
        Removes an entry.
        Parameters:
        index - the preference index