/*
This file is part of the software framework JStatCom,
a library for building applications for data based analysis.
Copyright (C) 2000-2005 Markus Kraetzig
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
*/
package com.jstatcom.project;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javolution37.javolution.xml.XmlElement;
import javolution37.javolution.xml.XmlFormat;
/**
* Represents all settings that should be stored permanently between different
* program runs. All settings are stored to an XML file when the program is quit
* and are automatically retrieved at program start. Settings are handled by the
* SettingsManager class.
*
* This class only holds a list with an arbitrary number of
* SettingsElement instances, which are themselves XML
* serializable classes holding specific types of runtime information.
*
* @author Markus Kraetzig
*/
public final class Settings {
private final List settingsList = new ArrayList();
public static final XmlFormat Settings_XML = new XmlFormat(
Settings.class) {
public void format(Settings data, XmlElement xml) {
for (SettingsElement el : data.settingsList)
xml.add(el);
}
public Settings parse(XmlElement xml) {
Settings settings = new Settings();
while (xml.hasNext())
settings.addSettingsElement((SettingsElement) xml.getNext());
return settings;
}
};
public Settings() {
}
/**
* Adds a SettingsElement object to this.
*
* @param el
* an element representing a certain type of runtime information
* @throws IllegalArgumentException
* if (el == null)
*/
public void addSettingsElement(SettingsElement el) {
if (el == null)
throw new IllegalArgumentException("Argument was null.");
settingsList.add(el);
}
/**
* Gets an iterator over all settings elements.
*
* @return settings iterator
*/
Iterator getSettingsIterator() {
return settingsList.iterator();
}
}
Ads help maintain this website.