de.lmu.ifi.dbs.elki.gui.util
Class SavedSettingsFile

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.gui.util.SavedSettingsFile
All Implemented Interfaces:
Iterable<Pair<String,ArrayList<String>>>

public class SavedSettingsFile
extends Object
implements Iterable<Pair<String,ArrayList<String>>>

Class to manage saved settings in a text file.


Field Summary
static String COMMENT_PREFIX
          Comment prefix
private  File file
          File to read and write
private  ArrayList<Pair<String,ArrayList<String>>> store
          Data store
 
Constructor Summary
SavedSettingsFile(String filename)
          Constructor.
 
Method Summary
 void clear()
          Remove all saved settings.
 ArrayList<String> get(String key)
          Find a saved setting by key.
 Pair<String,ArrayList<String>> getElementAt(int index)
          Array access.
 Iterator<Pair<String,ArrayList<String>>> iterator()
           
 void load()
          Read the current file
 void put(String key, ArrayList<String> value)
          Add/Replace a saved setting
 void remove(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
 

Field Detail

COMMENT_PREFIX

public static final String COMMENT_PREFIX
Comment prefix

See Also:
Constant Field Values

file

private File file
File to read and write


store

private ArrayList<Pair<String,ArrayList<String>>> store
Data store

Constructor Detail

SavedSettingsFile

public SavedSettingsFile(String filename)
Constructor.

Parameters:
filename - Filename
Method Detail

save

public void save()
          throws IOException
Save the current data to the given file.

Throws:
IOException - thrown on output errors.

load

public void load()
          throws FileNotFoundException,
                 IOException
Read the current file

Throws:
FileNotFoundException - thrown when file not found
IOException - thrown on IO errprs

iterator

public Iterator<Pair<String,ArrayList<String>>> iterator()
Specified by:
iterator in interface Iterable<Pair<String,ArrayList<String>>>

remove

public void remove(String key)
Remove a given key from the file.

Parameters:
key - Key to remove

get

public ArrayList<String> get(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(String key,
                ArrayList<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<String,ArrayList<String>> getElementAt(int index)
Array access.

Parameters:
index - settings index
Returns:
pair at this index

Release 0.4.0 (2011-09-20_1324)