|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Dictionary<K,V>
java.util.Hashtable<java.lang.Object,java.lang.Object>
java.util.Properties
com.emarsys.ecommon.prefs.config.backend.PropertiesConfigurationBackend
public class PropertiesConfigurationBackend
A ConfigurationBackend
with a Properties
object
as configuration store.
PropertiesConfigurationBackend
is simply an adapter
or a bridge from the Configuration
API to plain
old Properties
whilest being both an instance of
Properties
and ConfigurationBackend
.
Therefore a PropertiesConfigurationBackend
for instance
can be used to create a ConfigurationBackend
that wraps System.getProperties()
.
NOTE: that the PropertiesConfigurationBackend
does
reflect changes in the original, wrapped
Properties
object used to initialize itself!
But this is not the case if the ISetting
s of
another ConfigurationBackend
have been
copied
.
Because the ISetting
s are actually stored in a
Properties
instance a PropertiesConfigurationBackend
is not capable of conserving anything but the bare name
and value of the settings, thus there's for instance
always an unspecified
SettingMode
for instances retrieved.
But said specific
limitation can be "fixed" by wrapping the a
PropertiesConfigurationBackend
into a
ModeSettingConfigurationBackend
.
Field Summary | |
---|---|
protected java.util.Properties |
props
The storage backend for the ISetting 's
names and values. |
Fields inherited from class java.util.Properties |
---|
defaults |
Constructor Summary | |
---|---|
|
PropertiesConfigurationBackend()
Creates a new, empty PropertiesConfigurationBackend . |
protected |
PropertiesConfigurationBackend(java.util.Properties props)
Creates a new PropertiesConfigurationBackend that
uses the passed properties as its storage, see props . |
Method Summary | |
---|---|
void |
clear()
|
java.lang.Object |
clone()
|
boolean |
contains(java.lang.Object value)
|
boolean |
containsKey(java.lang.Object key)
|
boolean |
containsValue(java.lang.Object value)
|
static PropertiesConfigurationBackend |
copy(ConfigurationBackend backend)
Creates a new PropertiesConfigurationBackend
instance that contains all ISetting s from the
passed backend. |
java.util.Enumeration<java.lang.Object> |
elements()
|
java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>> |
entrySet()
|
boolean |
equals(java.lang.Object o)
|
java.lang.Object |
get(java.lang.Object key)
|
ISetting |
get(java.lang.String name)
Retrieves the ISetting with the passed name. |
java.lang.String |
getProperty(java.lang.String key)
|
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue)
|
java.util.List<ISetting> |
getSettings()
Retrieves all ISetting s from this backend. |
int |
hashCode()
|
boolean |
isEmpty()
|
java.util.Enumeration<java.lang.Object> |
keys()
|
java.util.Set<java.lang.Object> |
keySet()
|
void |
list(java.io.PrintStream out)
|
void |
list(java.io.PrintWriter out)
|
void |
load(java.io.InputStream inStream)
|
void |
loadFromXML(java.io.InputStream in)
|
java.util.Enumeration<?> |
propertyNames()
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
|
void |
putAll(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> t)
|
java.lang.Object |
remove(java.lang.Object key)
|
void |
save(java.io.OutputStream out,
java.lang.String comments)
Deprecated. |
void |
set(ISetting setting)
Sets the passed setting which must not be null
in this configuration backend, if a setting with the given
name is already present it will be overridden. |
java.lang.Object |
setProperty(java.lang.String key,
java.lang.String value)
|
int |
size()
|
void |
store(java.io.OutputStream out,
java.lang.String comments)
|
void |
storeToXML(java.io.OutputStream os,
java.lang.String comment)
|
void |
storeToXML(java.io.OutputStream os,
java.lang.String comment,
java.lang.String encoding)
|
java.lang.String |
toString()
|
java.util.Collection<java.lang.Object> |
values()
|
static PropertiesConfigurationBackend |
wrap(java.util.Properties props)
Creates a new PropertiesConfigurationBackend that uses
the passed Properties to store its ISetting 's
names and values. |
Methods inherited from class java.util.Properties |
---|
load, store, stringPropertyNames |
Methods inherited from class java.util.Hashtable |
---|
rehash |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Properties props
ISetting
's
names and values.
Constructor Detail |
---|
protected PropertiesConfigurationBackend(java.util.Properties props) throws java.lang.IllegalArgumentException
Creates a new PropertiesConfigurationBackend
that
uses the passed properties as its storage, see props
.
Changes to the created instance will thus be reflected
in the passed Properties
.
props
- - the Properties
instance to be
wrapped
java.lang.IllegalArgumentException
- -
if the passed properties are null
.public PropertiesConfigurationBackend()
Creates a new, empty PropertiesConfigurationBackend
.
Creates a new, empty Properties
object which is used as
the backing store the new PropertiesConfigurationBackend
instance.
PropertiesConfigurationBackend(Properties)
Method Detail |
---|
public static PropertiesConfigurationBackend copy(ConfigurationBackend backend) throws java.lang.IllegalArgumentException
Creates a new PropertiesConfigurationBackend
instance that contains all ISetting
s from the
passed backend.
Note that this factory method retrieves the ISetting
s
from the passed backend by calling
ConfigurationBackend.getSettings()
which will be copied into the newly created
PropertiesConfigurationBackend
and therefore
changes will not be relfected in the original, passed
ConfigurationBackend
.
Note that the described semantic of
copy(ConfigurationBackend)
differs from the one in
wrap(Properties)
.
backend
- - the ConfigurationBackend
whose
ISetting
s should be copied;
must not be null
.
PropertiesConfigurationBackend
instance,
never null
.
java.lang.IllegalArgumentException
PropertiesConfigurationBackend()
public static PropertiesConfigurationBackend wrap(java.util.Properties props)
Creates a new PropertiesConfigurationBackend
that uses
the passed Properties
to store its ISetting
's
names and values.
The wrap factory method is just a more verbose wrapped to
PropertiesConfigurationBackend(Properties)
. The returned
ConfigurationBackend
will therefore propagate changes
to the passed Properties
instance.
props
- - the Properties
to be wrapped into a
ConfigurationBackend
.
PropertiesConfigurationBackend
instance,
never null
.PropertiesConfigurationBackend(Properties)
public ISetting get(java.lang.String name) throws java.lang.IllegalArgumentException
ConfigurationBackend
ISetting
with the passed name.
get
in interface ConfigurationBackend
ISetting
with the
passed name or null
if not present.
java.lang.IllegalArgumentException
- - if the passed name is
null
.com.emarsys.core.setting.backend.ConfigurationBackend#get(java.lang.String)
public void set(ISetting setting) throws java.lang.IllegalArgumentException
ConfigurationBackend
null
in this configuration backend, if a setting with the given
name is already present it will be overridden.
The next call to ConfigurationBackend.get(String)
with the passed
setting's name will return the passed setting.
set
in interface ConfigurationBackend
java.lang.IllegalArgumentException
- - if the passed setting,
its name or value is null
.com.emarsys.core.setting.backend.ConfigurationBackend#set(ISetting)
public java.util.List<ISetting> getSettings()
ConfigurationBackend
Retrieves all ISetting
s from this backend.
What exactly "all" means in the context of the concrete
ConfigurationBackend
is up to the implementation.
For instance the List
may or may not contain
default values or fallbacked ISetting
s or might
even return a cached list.
The only requirement for this method is to be logically in
synch with ConfigurationBackend.get(String)
and ConfigurationBackend.set(ISetting)
.
Thus if a Setting is inserted/updated/deleted and nothing
is changed in the meantime the next call to
ConfigurationBackend.getSettings()
has to reflect the changes made.
getSettings
in interface ConfigurationBackend
List
of ISetting
s,
never null
.com.emarsys.core.setting.backend.ConfigurationBackend#getSettings()
public void clear()
clear
in interface java.util.Map<java.lang.Object,java.lang.Object>
clear
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Hashtable.clear()
public java.lang.Object clone()
clone
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Hashtable.clone()
public boolean contains(java.lang.Object value)
contains
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
value
-
Hashtable.contains(java.lang.Object)
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<java.lang.Object,java.lang.Object>
containsKey
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
key
-
Hashtable.containsKey(java.lang.Object)
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<java.lang.Object,java.lang.Object>
containsValue
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
value
-
Hashtable.containsValue(java.lang.Object)
public java.util.Enumeration<java.lang.Object> elements()
elements
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Hashtable.elements()
public java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>> entrySet()
entrySet
in interface java.util.Map<java.lang.Object,java.lang.Object>
entrySet
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Hashtable.entrySet()
public boolean equals(java.lang.Object o)
equals
in interface java.util.Map<java.lang.Object,java.lang.Object>
equals
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
o
-
Hashtable.equals(java.lang.Object)
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map<java.lang.Object,java.lang.Object>
get
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
key
-
Hashtable.get(java.lang.Object)
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
getProperty
in class java.util.Properties
key
- defaultValue
-
Properties.getProperty(java.lang.String, java.lang.String)
public java.lang.String getProperty(java.lang.String key)
getProperty
in class java.util.Properties
key
-
Properties.getProperty(java.lang.String)
public int hashCode()
hashCode
in interface java.util.Map<java.lang.Object,java.lang.Object>
hashCode
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Hashtable.hashCode()
public boolean isEmpty()
isEmpty
in interface java.util.Map<java.lang.Object,java.lang.Object>
isEmpty
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Hashtable.isEmpty()
public java.util.Enumeration<java.lang.Object> keys()
keys
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Hashtable.keys()
public java.util.Set<java.lang.Object> keySet()
keySet
in interface java.util.Map<java.lang.Object,java.lang.Object>
keySet
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Hashtable.keySet()
public void list(java.io.PrintStream out)
list
in class java.util.Properties
out
- Properties.list(java.io.PrintStream)
public void list(java.io.PrintWriter out)
list
in class java.util.Properties
out
- Properties.list(java.io.PrintWriter)
public void load(java.io.InputStream inStream) throws java.io.IOException
load
in class java.util.Properties
inStream
-
java.io.IOException
Properties.load(java.io.InputStream)
public void loadFromXML(java.io.InputStream in) throws java.io.IOException, java.util.InvalidPropertiesFormatException
loadFromXML
in class java.util.Properties
in
-
java.io.IOException
java.util.InvalidPropertiesFormatException
Properties.loadFromXML(java.io.InputStream)
public java.util.Enumeration<?> propertyNames()
propertyNames
in class java.util.Properties
Properties.propertyNames()
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map<java.lang.Object,java.lang.Object>
put
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
key
- value
-
Hashtable.put(java.lang.Object, java.lang.Object)
public void putAll(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> t)
putAll
in interface java.util.Map<java.lang.Object,java.lang.Object>
putAll
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
t
- Hashtable.putAll(java.util.Map)
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.Object,java.lang.Object>
remove
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
key
-
Hashtable.remove(java.lang.Object)
public void save(java.io.OutputStream out, java.lang.String comments)
save
in class java.util.Properties
out
- comments
- Properties.save(java.io.OutputStream, java.lang.String)
public java.lang.Object setProperty(java.lang.String key, java.lang.String value)
setProperty
in class java.util.Properties
key
- value
-
Properties.setProperty(java.lang.String, java.lang.String)
public int size()
size
in interface java.util.Map<java.lang.Object,java.lang.Object>
size
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Hashtable.size()
public void store(java.io.OutputStream out, java.lang.String comments) throws java.io.IOException
store
in class java.util.Properties
out
- comments
-
java.io.IOException
Properties.store(java.io.OutputStream, java.lang.String)
public void storeToXML(java.io.OutputStream os, java.lang.String comment, java.lang.String encoding) throws java.io.IOException
storeToXML
in class java.util.Properties
os
- comment
- encoding
-
java.io.IOException
Properties.storeToXML(java.io.OutputStream, java.lang.String, java.lang.String)
public void storeToXML(java.io.OutputStream os, java.lang.String comment) throws java.io.IOException
storeToXML
in class java.util.Properties
os
- comment
-
java.io.IOException
Properties.storeToXML(java.io.OutputStream, java.lang.String)
public java.lang.String toString()
toString
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Hashtable.toString()
public java.util.Collection<java.lang.Object> values()
values
in interface java.util.Map<java.lang.Object,java.lang.Object>
values
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Hashtable.values()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |