|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.jface.dialogs.DialogSettings
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");
Constructor Summary | |
DialogSettings(String sectionName)
Create an empty dialog settings which loads and saves its content to a file. |
Method Summary | |
IDialogSettings |
addNewSection(String name)
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 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
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.Method Detail |
public IDialogSettings addNewSection(String name)
IDialogSettings
addNewSection
in interface IDialogSettings
name
- the name of the new section
public void addSection(IDialogSettings section)
IDialogSettings
addSection
in interface IDialogSettings
section
- the section to be addedpublic String get(String key)
IDialogSettings
get
in interface IDialogSettings
key
- the key
null
if nonepublic String[] getArray(String key)
IDialogSettings
getArray
in interface IDialogSettings
key
- the key
null
if nonepublic boolean getBoolean(String key)
IDialogSettings
getBoolean
in interface IDialogSettings
key
- the key
false
if nonepublic double getDouble(String key) throws NumberFormatException
IDialogSettings
getDouble
in interface IDialogSettings
key
- the key
NumberFormatException
if none
NumberFormatException
- if the string value does not contain a
parsable number.Double.valueOf(java.lang.String)
public float getFloat(String key) throws NumberFormatException
IDialogSettings
getFloat
in interface IDialogSettings
key
- the key
NumberFormatException
if none
NumberFormatException
- if the string value does not contain a
parsable number.Float.valueOf(java.lang.String)
public int getInt(String key) throws NumberFormatException
IDialogSettings
getInt
in interface IDialogSettings
key
- the key
NumberFormatException
if none
NumberFormatException
- if the string value does not contain a
parsable number.Integer.valueOf(java.lang.String)
public long getLong(String key) throws NumberFormatException
IDialogSettings
getLong
in interface IDialogSettings
key
- the key
NumberFormatException
if none
NumberFormatException
- if the string value does not contain a
parsable number.Long.valueOf(java.lang.String)
public String getName()
IDialogSettings
getName
in interface IDialogSettings
public IDialogSettings getSection(String sectionName)
IDialogSettings
getSection
in interface IDialogSettings
null
if nonepublic IDialogSettings[] getSections()
IDialogSettings
getSections
in interface IDialogSettings
null
if nonepublic void load(Reader r)
IDialogSettings
load
in interface IDialogSettings
r
- a Reader specifying the stream where the settings are read from.public void load(String fileName) throws IOException
IDialogSettings
load
in interface IDialogSettings
fileName
- the name of the file the settings are read from.
IOException
public void put(String key, String[] value)
IDialogSettings
key/value
to this dialog settings.
put
in interface IDialogSettings
key
- the key.value
- the value to be associated with the key
public void put(String key, double value)
IDialogSettings
value
to a string and adds
the pair key/value
to this dialog settings.
put
in interface IDialogSettings
key
- the key.value
- the value to be associated with the key
public void put(String key, float value)
IDialogSettings
value
to a string and adds
the pair key/value
to this dialog settings.
put
in interface IDialogSettings
key
- the key.value
- the value to be associated with the key
public void put(String key, int value)
IDialogSettings
value
to a string and adds
the pair key/value
to this dialog settings.
put
in interface IDialogSettings
key
- the key.value
- the value to be associated with the key
public void put(String key, long value)
IDialogSettings
value
to a string and adds
the pair key/value
to this dialog settings.
put
in interface IDialogSettings
key
- the key.value
- the value to be associated with the key
public void put(String key, String value)
IDialogSettings
key/value
to this dialog settings.
put
in interface IDialogSettings
key
- the key.value
- the value to be associated with the key
public void put(String key, boolean value)
IDialogSettings
value
to a string and adds
the pair key/value
to this dialog settings.
put
in interface IDialogSettings
key
- the key.value
- the value to be associated with the key
public void save(Writer writer) throws IOException
IDialogSettings
save
in interface IDialogSettings
writer
- a Writer specifying the stream the settings are written in.
IOException
public void save(String fileName) throws IOException
IDialogSettings
save
in interface IDialogSettings
fileName
- the name of the file the settings are written in.
IOException
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |