Class DialogSettings

  • All Implemented Interfaces:
    IDialogSettings

    public class DialogSettings
    extends Object
    implements IDialogSettings
    Concrete implementation of a dialog settings (IDialogSettings) using a hash table and XML. The dialog store can be read from and saved to a stream. All keys and values must be strings or array of strings. Primitive types are converted to strings.

    This class was not designed to be subclassed. Here is an example of using a DialogSettings:

     
     DialogSettings settings = new DialogSettings("root");
     settings.put("Boolean1",true);
     settings.put("Long1",100);
     settings.put("Array1",new String[]{"aaaa1","bbbb1","cccc1"});
     DialogSettings section = new DialogSettings("sectionName");
     settings.addSection(section);
     section.put("Int2",200);
     section.put("Float2",1.1);
     section.put("Array2",new String[]{"aaaa2","bbbb2","cccc2"});
     settings.save("c:\\temp\\test\\dialog.xml");
     
     
    Restriction:
    This class is not intended to be subclassed by clients.
    • Constructor Detail

      • DialogSettings

        public DialogSettings​(String sectionName)
        Create an empty dialog settings which loads and saves its content to a file. Use the methods load(String) and store(String) to load and store this dialog settings.
        Parameters:
        sectionName - the name of the section in the settings.
    • Method Detail

      • removeSection

        public void removeSection​(IDialogSettings section)
        Remove a section in the receiver. If the given section does not exist, nothing is done.
        Parameters:
        section - the section to be removed. Must not be null.
        Since:
        3.9
      • removeSection

        public IDialogSettings removeSection​(String sectionName)
        Remove a section by name in the receiver. If the given section does not exist, nothing is done.
        Parameters:
        sectionName - the name of the section to be removed. Must not be null.
        Returns:
        The dialog section removed, or null if it wasn't there.
        Since:
        3.9
      • get

        public String get​(String key)
        Description copied from interface: IDialogSettings
        Returns the value of the given key in this dialog settings.
        Specified by:
        get in interface IDialogSettings
        Parameters:
        key - the key
        Returns:
        the value, or null if none
      • getArray

        public String[] getArray​(String key)
        Description copied from interface: IDialogSettings
        Returns the value, an array of strings, of the given key in this dialog settings.
        Specified by:
        getArray in interface IDialogSettings
        Parameters:
        key - the key
        Returns:
        the array of string, or null if none
      • getBoolean

        public boolean getBoolean​(String key)
        Description copied from interface: IDialogSettings
        Convenience API. Convert the value of the given key in this dialog settings to a boolean and return it.
        Specified by:
        getBoolean in interface IDialogSettings
        Parameters:
        key - the key
        Returns:
        the boolean value, or false if none
      • getOrCreateSection

        public static IDialogSettings getOrCreateSection​(IDialogSettings settings,
                                                         String sectionName)
        Returns a section with the given name in the given dialog settings. If the section doesn't exist yet, then it is first created.
        Parameters:
        settings - the parent settings
        sectionName - the name of the section
        Returns:
        the section
        Since:
        3.7
      • load

        public void load​(Reader r)
        Description copied from interface: IDialogSettings
        Load a dialog settings from a stream and fill the receiver with its content.
        Specified by:
        load in interface IDialogSettings
        Parameters:
        r - a Reader specifying the stream where the settings are read from.
      • load

        public void load​(String fileName)
                  throws IOException
        Description copied from interface: IDialogSettings
        Load a dialog settings from a file and fill the receiver with its content.
        Specified by:
        load in interface IDialogSettings
        Parameters:
        fileName - the name of the file the settings are read from.
        Throws:
        IOException
      • put

        public void put​(String key,
                        String[] value)
        Description copied from interface: IDialogSettings
        Adds the pair key/value to this dialog settings.
        Specified by:
        put in interface IDialogSettings
        Parameters:
        key - the key.
        value - the value to be associated with the key
      • put

        public void put​(String key,
                        double value)
        Description copied from interface: IDialogSettings
        Convenience API. Converts the double value to a string and adds the pair key/value to this dialog settings.
        Specified by:
        put in interface IDialogSettings
        Parameters:
        key - the key.
        value - the value to be associated with the key
      • put

        public void put​(String key,
                        float value)
        Description copied from interface: IDialogSettings
        Convenience API. Converts the float value to a string and adds the pair key/value to this dialog settings.
        Specified by:
        put in interface IDialogSettings
        Parameters:
        key - the key.
        value - the value to be associated with the key
      • put

        public void put​(String key,
                        int value)
        Description copied from interface: IDialogSettings
        Convenience API. Converts the int value to a string and adds the pair key/value to this dialog settings.
        Specified by:
        put in interface IDialogSettings
        Parameters:
        key - the key.
        value - the value to be associated with the key
      • put

        public void put​(String key,
                        long value)
        Description copied from interface: IDialogSettings
        Convenience API. Converts the long value to a string and adds the pair key/value to this dialog settings.
        Specified by:
        put in interface IDialogSettings
        Parameters:
        key - the key.
        value - the value to be associated with the key
      • put

        public void put​(String key,
                        String value)
        Description copied from interface: IDialogSettings
        Adds the pair key/value to this dialog settings.
        Specified by:
        put in interface IDialogSettings
        Parameters:
        key - the key.
        value - the value to be associated with the key
      • put

        public void put​(String key,
                        boolean value)
        Description copied from interface: IDialogSettings
        Convenience API. Converts the boolean value to a string and adds the pair key/value to this dialog settings.
        Specified by:
        put in interface IDialogSettings
        Parameters:
        key - the key.
        value - the value to be associated with the key