Interface IDialogSettings

  • All Known Implementing Classes:
    DialogSettings

    public interface IDialogSettings
    An interface to a storage mechanism for making dialog settings persistent. The store manages a collection of key/value pairs. The keys must be strings and the values can be either, strings or array of strings. Convenience API to convert primitive types to strings is provided.

    To load/store/cache dialog settings without the assumption of how they should be stored, clients should implement IDialogSettingsProvider.

    See Also:
    DialogSettings
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      IDialogSettings addNewSection​(java.lang.String name)
      Create a new section in the receiver and return it.
      void addSection​(IDialogSettings section)
      Add a section in the receiver.
      java.lang.String get​(java.lang.String key)
      Returns the value of the given key in this dialog settings.
      java.lang.String[] getArray​(java.lang.String key)
      Returns the value, an array of strings, of the given key in this dialog settings.
      boolean getBoolean​(java.lang.String key)
      Convenience API.
      double getDouble​(java.lang.String key)
      Convenience API.
      float getFloat​(java.lang.String key)
      Convenience API.
      int getInt​(java.lang.String key)
      Convenience API.
      long getLong​(java.lang.String key)
      Convenience API.
      java.lang.String getName()
      Returns the IDialogSettings name.
      IDialogSettings getSection​(java.lang.String sectionName)
      Returns the section with the given name in this dialog settings.
      IDialogSettings[] getSections()
      Returns all the sections in this dialog settings.
      void load​(java.io.Reader reader)
      Load a dialog settings from a stream and fill the receiver with its content.
      void load​(java.lang.String fileName)
      Load a dialog settings from a file and fill the receiver with its content.
      void put​(java.lang.String key, boolean value)
      Convenience API.
      void put​(java.lang.String key, double value)
      Convenience API.
      void put​(java.lang.String key, float value)
      Convenience API.
      void put​(java.lang.String key, int value)
      Convenience API.
      void put​(java.lang.String key, long value)
      Convenience API.
      void put​(java.lang.String key, java.lang.String value)
      Adds the pair key/value to this dialog settings.
      void put​(java.lang.String key, java.lang.String[] value)
      Adds the pair key/value to this dialog settings.
      void save​(java.io.Writer writer)
      Save a dialog settings to a stream
      void save​(java.lang.String fileName)
      Save a dialog settings to a file.
    • Method Detail

      • addSection

        void addSection​(IDialogSettings section)
        Add a section in the receiver.
        Parameters:
        section - the section to be added
      • get

        java.lang.String get​(java.lang.String key)
        Returns the value of the given key in this dialog settings.
        Parameters:
        key - the key
        Returns:
        the value, or null if none
      • getArray

        java.lang.String[] getArray​(java.lang.String key)
        Returns the value, an array of strings, of the given key in this dialog settings.
        Parameters:
        key - the key
        Returns:
        the array of string, or null if none
      • getBoolean

        boolean getBoolean​(java.lang.String key)
        Convenience API. Convert the value of the given key in this dialog settings to a boolean and return it.
        Parameters:
        key - the key
        Returns:
        the boolean value, or false if none
      • getDouble

        double getDouble​(java.lang.String key)
                  throws java.lang.NumberFormatException
        Convenience API. Convert the value of the given key in this dialog settings to a double and return it.
        Parameters:
        key - the key
        Returns:
        the value coverted to double, or throws NumberFormatException if none
        Throws:
        java.lang.NumberFormatException - if the string value does not contain a parsable number.
        See Also:
        Double.valueOf(java.lang.String)
      • getFloat

        float getFloat​(java.lang.String key)
                throws java.lang.NumberFormatException
        Convenience API. Convert the value of the given key in this dialog settings to a float and return it.
        Parameters:
        key - the key
        Returns:
        the value coverted to float, or throws NumberFormatException if none
        Throws:
        java.lang.NumberFormatException - if the string value does not contain a parsable number.
        See Also:
        Float.valueOf(java.lang.String)
      • getInt

        int getInt​(java.lang.String key)
            throws java.lang.NumberFormatException
        Convenience API. Convert the value of the given key in this dialog settings to a int and return it.
        Parameters:
        key - the key
        Returns:
        the value coverted to int, or throws NumberFormatException if none
        Throws:
        java.lang.NumberFormatException - if the string value does not contain a parsable number.
        See Also:
        Integer.valueOf(java.lang.String)
      • getLong

        long getLong​(java.lang.String key)
              throws java.lang.NumberFormatException
        Convenience API. Convert the value of the given key in this dialog settings to a long and return it.
        Parameters:
        key - the key
        Returns:
        the value coverted to long, or throws NumberFormatException if none
        Throws:
        java.lang.NumberFormatException - if the string value does not contain a parsable number.
        See Also:
        Long.valueOf(java.lang.String)
      • getName

        java.lang.String getName()
        Returns the IDialogSettings name.
        Returns:
        the name
      • getSections

        IDialogSettings[] getSections()
        Returns all the sections in this dialog settings.
        Returns:
        the section, or null if none
      • load

        void load​(java.io.Reader reader)
           throws java.io.IOException
        Load a dialog settings from a stream and fill the receiver with its content.
        Parameters:
        reader - a Reader specifying the stream where the settings are read from.
        Throws:
        java.io.IOException - on IO problem while loading
      • load

        void load​(java.lang.String fileName)
           throws java.io.IOException
        Load a dialog settings from a file and fill the receiver with its content.
        Parameters:
        fileName - the name of the file the settings are read from.
        Throws:
        java.io.IOException - on IO problem while loading
      • put

        void put​(java.lang.String key,
                 java.lang.String[] value)
        Adds the pair key/value to this dialog settings.
        Parameters:
        key - the key.
        value - the value to be associated with the key
      • put

        void put​(java.lang.String key,
                 double value)
        Convenience API. Converts the double value to a string and adds the pair key/value to this dialog settings.
        Parameters:
        key - the key.
        value - the value to be associated with the key
      • put

        void put​(java.lang.String key,
                 float value)
        Convenience API. Converts the float value to a string and adds the pair key/value to this dialog settings.
        Parameters:
        key - the key.
        value - the value to be associated with the key
      • put

        void put​(java.lang.String key,
                 int value)
        Convenience API. Converts the int value to a string and adds the pair key/value to this dialog settings.
        Parameters:
        key - the key.
        value - the value to be associated with the key
      • put

        void put​(java.lang.String key,
                 long value)
        Convenience API. Converts the long value to a string and adds the pair key/value to this dialog settings.
        Parameters:
        key - the key.
        value - the value to be associated with the key
      • put

        void put​(java.lang.String key,
                 java.lang.String value)
        Adds the pair key/value to this dialog settings.
        Parameters:
        key - the key.
        value - the value to be associated with the key
      • put

        void put​(java.lang.String key,
                 boolean value)
        Convenience API. Converts the boolean value to a string and adds the pair key/value to this dialog settings.
        Parameters:
        key - the key.
        value - the value to be associated with the key
      • save

        void save​(java.io.Writer writer)
           throws java.io.IOException
        Save a dialog settings to a stream
        Parameters:
        writer - a Writer specifying the stream the settings are written in.
        Throws:
        java.io.IOException - on IO problem while saving
      • save

        void save​(java.lang.String fileName)
           throws java.io.IOException
        Save a dialog settings to a file.
        Parameters:
        fileName - the name of the file the settings are written in.
        Throws:
        java.io.IOException - on IO problem while saving