public class DialogSettings extends Object implements IDialogSettings
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");
| Constructor and Description |
|---|
DialogSettings(String sectionName)
Create an empty dialog settings which loads and saves its
content to a file.
|
| Modifier and Type | Method and Description |
|---|---|
IDialogSettings |
addNewSection(String sectionName)
Create a new section in the receiver and return it.
|
void |
addSection(IDialogSettings section)
Add a section in the receiver.
|
String |
get(String key)
Returns the value of the given key in this dialog settings.
|
String[] |
getArray(String key)
Returns the value, an array of strings, of the given key in this dialog
settings.
|
boolean |
getBoolean(String key)
Convenience API.
|
double |
getDouble(String key)
Convenience API.
|
float |
getFloat(String key)
Convenience API.
|
int |
getInt(String key)
Convenience API.
|
long |
getLong(String key)
Convenience API.
|
String |
getName()
Returns the IDialogSettings name.
|
IDialogSettings |
getSection(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(Reader r)
Load a dialog settings from a stream and fill the receiver with its
content.
|
void |
load(String fileName)
Load a dialog settings from a file and fill the receiver with its
content.
|
void |
put(String key,
boolean value)
Convenience API.
|
void |
put(String key,
double value)
Convenience API.
|
void |
put(String key,
float value)
Convenience API.
|
void |
put(String key,
int value)
Convenience API.
|
void |
put(String key,
long value)
Convenience API.
|
void |
put(String key,
String value)
Adds the pair
key/value to this dialog settings. |
void |
put(String key,
String[] value)
Adds the pair
key/value to this dialog settings. |
void |
save(String fileName)
Save a dialog settings to a file.
|
void |
save(Writer writer)
Save a dialog settings to a stream
|
public DialogSettings(String sectionName)
load(String) and store(String)
to load and store this dialog settings.sectionName - the name of the section in the settings.public IDialogSettings addNewSection(String sectionName)
IDialogSettingsaddNewSection in interface IDialogSettingssectionName - the name of the new sectionpublic void addSection(IDialogSettings section)
IDialogSettingsaddSection in interface IDialogSettingssection - the section to be addedpublic String get(String key)
IDialogSettingsget in interface IDialogSettingskey - the keynull if nonepublic String[] getArray(String key)
IDialogSettingsgetArray in interface IDialogSettingskey - the keynull if nonepublic boolean getBoolean(String key)
IDialogSettingsgetBoolean in interface IDialogSettingskey - the keyfalse if nonepublic double getDouble(String key) throws NumberFormatException
IDialogSettingsgetDouble in interface IDialogSettingskey - the keyNumberFormatException if noneNumberFormatException - if the string value does not contain a parsable number.Double.valueOf(java.lang.String)public float getFloat(String key) throws NumberFormatException
IDialogSettingsgetFloat in interface IDialogSettingskey - the keyNumberFormatException if noneNumberFormatException - if the string value does not contain a parsable number.Float.valueOf(java.lang.String)public int getInt(String key) throws NumberFormatException
IDialogSettingsgetInt in interface IDialogSettingskey - the keyNumberFormatException if noneNumberFormatException - if the string value does not contain a parsable number.Integer.valueOf(java.lang.String)public long getLong(String key) throws NumberFormatException
IDialogSettingsgetLong in interface IDialogSettingskey - the keyNumberFormatException if noneNumberFormatException - if the string value does not contain a parsable number.Long.valueOf(java.lang.String)public String getName()
IDialogSettingsgetName in interface IDialogSettingspublic IDialogSettings getSection(String sectionName)
IDialogSettingsgetSection in interface IDialogSettingssectionName - the keynull if nonepublic IDialogSettings[] getSections()
IDialogSettingsgetSections in interface IDialogSettingsnull if nonepublic void load(Reader r)
IDialogSettingsload in interface IDialogSettingsr - a Reader specifying the stream where the settings are read
from.public void load(String fileName) throws IOException
IDialogSettingsload in interface IDialogSettingsfileName - the name of the file the settings are read from.IOExceptionpublic void put(String key, String[] value)
IDialogSettingskey/value to this dialog settings.put in interface IDialogSettingskey - the key.value - the value to be associated with the keypublic void put(String key, double value)
IDialogSettingsvalue to a string and
adds the pair key/value to this dialog settings.put in interface IDialogSettingskey - the key.value - the value to be associated with the keypublic void put(String key, float value)
IDialogSettingsvalue to a string and
adds the pair key/value to this dialog settings.put in interface IDialogSettingskey - the key.value - the value to be associated with the keypublic void put(String key, int value)
IDialogSettingsvalue to a string and
adds the pair key/value to this dialog settings.put in interface IDialogSettingskey - the key.value - the value to be associated with the keypublic void put(String key, long value)
IDialogSettingsvalue to a string and
adds the pair key/value to this dialog settings.put in interface IDialogSettingskey - the key.value - the value to be associated with the keypublic void put(String key, String value)
IDialogSettingskey/value to this dialog settings.put in interface IDialogSettingskey - the key.value - the value to be associated with the keypublic void put(String key, boolean value)
IDialogSettingsvalue to a string
and adds the pair key/value to this dialog settings.put in interface IDialogSettingskey - the key.value - the value to be associated with the keypublic void save(Writer writer) throws IOException
IDialogSettingssave in interface IDialogSettingswriter - a Writer specifying the stream the settings are written in.IOExceptionpublic void save(String fileName) throws IOException
IDialogSettingssave in interface IDialogSettingsfileName - the name of the file the settings are written in.IOExceptionGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.