Package elki.gui.util
Class SavedSettingsFile
- java.lang.Object
-
- elki.gui.util.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 prefixprivate java.nio.file.Path
file
File to read and writeprivate 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 filevoid
put(java.lang.String key, java.util.ArrayList<java.lang.String> value)
Add/Replace a saved settingvoid
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.
-
-
-
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
-
-
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 foundjava.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 interfacejava.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
- Keyvalue
- (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
-
-