|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.Presets
public class Presets
This is a generic class for handling named presets consisting of multiple
key/value pairs. One instance can handle one default preset and
multiple named ones. Saving and loading is done to/from XML strings. The XML
strings could for example be stored as user settings
(for example with SessionControl.setUserDefaultSetting(String, String)
or as properties of items in the database.
Nested Class Summary | |
---|---|
static class |
Presets.Preset
Represents a single preset. |
Field Summary | |
---|---|
private Presets.Preset |
defaultPreset
|
private static URL |
dtdFile
The DTD which is used to validate the XML data. |
private Map<String,Presets.Preset> |
presets
|
Constructor Summary | |
---|---|
Presets()
Create a new empty presets object. |
Method Summary | |
---|---|
String |
asXml()
Convert the presets to an XML string. |
private Document |
buildDocument()
Convert the presets to a XML document. |
void |
deletePreset(String name)
Delete a named preset. |
Presets.Preset |
getDefault()
Get the default preset. |
Presets.Preset |
getPreset(String name)
Get a named preset. |
Iterator<Presets.Preset> |
iterator()
Iterate over all named presets. |
void |
loadFrom(InputStream in,
String filename)
Load presets from a stream. |
void |
loadFrom(String xml)
Load presets from an XML string. |
private void |
loadPresets(Document dom)
Parse an XML Document and load all presets. |
void |
writeTo(OutputStream out)
Write the prestes to a stream as an XML file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final URL dtdFile
private Presets.Preset defaultPreset
private Map<String,Presets.Preset> presets
Constructor Detail |
---|
public Presets()
Method Detail |
---|
public Iterator<Presets.Preset> iterator()
iterator
in interface Iterable<Presets.Preset>
public void loadFrom(String xml)
xml
- The XML stringpublic void loadFrom(InputStream in, String filename)
in
- The stream to read fromfilename
- The original filename the stream is loaded
from, or null if not knownpublic void writeTo(OutputStream out)
out
- The stream to write to.public String asXml()
private Document buildDocument()
public Presets.Preset getDefault()
public Presets.Preset getPreset(String name)
name
- The name of the preset
public void deletePreset(String name)
name
- The name of the preset to deleteprivate void loadPresets(Document dom)
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |