Package elki.gui.util

Class SavedSettingsFile

  • All Implemented Interfaces:
    java.lang.Iterable<Pair<java.lang.String,​java.util.ArrayList<java.lang.String>>>

    public class SavedSettingsFile
    extends java.lang.Object
    implements java.lang.Iterable<Pair<java.lang.String,​java.util.ArrayList<java.lang.String>>>
    Class to manage saved settings in a text file.
    Since:
    0.3
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String COMMENT_PREFIX
      Comment prefix
      private java.nio.file.Path file
      File to read and write
      private java.util.ArrayList<Pair<java.lang.String,​java.util.ArrayList<java.lang.String>>> store
      Data store
    • Constructor Summary

      Constructors 
      Constructor Description
      SavedSettingsFile​(java.lang.String filename)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Remove all saved settings.
      java.util.ArrayList<java.lang.String> get​(java.lang.String key)
      Find a saved setting by key.
      Pair<java.lang.String,​java.util.ArrayList<java.lang.String>> getElementAt​(int index)
      Array access.
      java.util.Iterator<Pair<java.lang.String,​java.util.ArrayList<java.lang.String>>> iterator()  
      void load()
      Read the current file
      void put​(java.lang.String key, java.util.ArrayList<java.lang.String> value)
      Add/Replace a saved setting
      void remove​(java.lang.String key)
      Remove a given key from the file.
      void save()
      Save the current data to the given file.
      int size()
      Return number of saved settings profiles.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • COMMENT_PREFIX

        public static final java.lang.String COMMENT_PREFIX
        Comment prefix
        See Also:
        Constant Field Values
      • file

        private java.nio.file.Path file
        File to read and write
      • store

        private java.util.ArrayList<Pair<java.lang.String,​java.util.ArrayList<java.lang.String>>> store
        Data store
    • Constructor Detail

      • SavedSettingsFile

        public SavedSettingsFile​(java.lang.String filename)
        Constructor.
        Parameters:
        filename - Filename
    • Method Detail

      • save

        public void save()
                  throws java.io.IOException
        Save the current data to the given file.
        Throws:
        java.io.IOException
      • load

        public void load()
                  throws java.nio.file.NoSuchFileException,
                         java.io.IOException
        Read the current file
        Throws:
        java.nio.file.NoSuchFileException - thrown when file not found
        java.io.IOException - thrown on IO errors
      • iterator

        public java.util.Iterator<Pair<java.lang.String,​java.util.ArrayList<java.lang.String>>> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<Pair<java.lang.String,​java.util.ArrayList<java.lang.String>>>
      • remove

        public void remove​(java.lang.String key)
        Remove a given key from the file.
        Parameters:
        key - Key to remove
      • get

        public java.util.ArrayList<java.lang.String> get​(java.lang.String key)
        Find a saved setting by key.
        Parameters:
        key - Key to search for
        Returns:
        saved settings for this key
      • clear

        public void clear()
        Remove all saved settings.
      • put

        public void put​(java.lang.String key,
                        java.util.ArrayList<java.lang.String> value)
        Add/Replace a saved setting
        Parameters:
        key - Key
        value - (New) value.
      • size

        public int size()
        Return number of saved settings profiles.
        Returns:
        Number of saved settings profiles
      • getElementAt

        public Pair<java.lang.String,​java.util.ArrayList<java.lang.String>> getElementAt​(int index)
        Array access.
        Parameters:
        index - settings index
        Returns:
        pair at this index