Config
, Serializable
public interface Accessible extends Config
Allows a Config
object to access the contents of the properties, providing utility methods to perform
consequent operations.
Example:
public interface MyConfig extends Config, Accessible { int someProperty(); } public void doSomething() { MyConfig cfg = ConfigFactory.create(MyConfig.class); cfg.list(System.out); }
These methods will print the list of properties, see Properties.list(java.io.PrintStream)
and
Properties.list(java.io.PrintWriter)
.
Config.ConverterClass, Config.DecryptorClass, Config.DefaultValue, Config.DisableableFeature, Config.DisableFeature, Config.EncryptedValue, Config.HotReload, Config.HotReloadType, Config.Key, Config.LoadPolicy, Config.LoadType, Config.PreprocessorClasses, Config.Separator, Config.Sources, Config.TokenizerClass
Modifier and Type | Method | Description |
---|---|---|
void |
fill(Map map) |
Fills the given
Map with the properties contained by this object. |
String |
getProperty(String key) |
Searches for the property with the specified key in this property list.
|
String |
getProperty(String key,
String defaultValue) |
Searches for the property with the specified key in this property list.
|
void |
list(PrintStream out) |
Prints this property list out to the specified output stream.
|
void |
list(PrintWriter out) |
Prints this property list out to the specified output stream.
|
Set<String> |
propertyNames() |
Returns a set of keys in this property list
including distinct keys in the default property list if a key
of the same name has not already been found from the main
properties list.
|
void |
store(OutputStream out,
String comments) |
Stores the underlying properties into an
OutputStream . |
void |
storeToXML(OutputStream os,
String comment) |
Emits an XML document representing all of the properties contained
in this table.
|
void list(PrintStream out)
out
- an output stream.ClassCastException
- if any key in this property list is not a string.Properties.list(java.io.PrintStream)
void list(PrintWriter out)
out
- an output stream.ClassCastException
- if any key in this property list is not a string.Properties.list(java.io.PrintWriter)
void store(OutputStream out, String comments) throws IOException
OutputStream
.
Notice that method Properties.store(java.io.Writer, String)
is not implemented since it's not
available in JDK 1.5 (while the target of this library is Java 1.5+).
out
- an output stream.comments
- a description of the property list.IOException
- if writing this property list to the specified output stream throws an IOException
.Properties.store(java.io.OutputStream, String)
void fill(Map map)
Map
with the properties contained by this object. Map
.
Notice that you can specify a properties object as parameter instead of a map,
since Properties
implements the Map
interface.
map
- the Map
to fill.String getProperty(String key)
null
if the property is not found.key
- the property key.Properties.getProperty(String)
String getProperty(String key, String defaultValue)
key
- the property key.defaultValue
- a default value.Properties.getProperty(String, String)
void storeToXML(OutputStream os, String comment) throws IOException
An invocation of this method of the form props.storeToXML(os,
comment)
behaves in exactly the same way as the invocation
props.storeToXML(os, comment, "UTF-8");
.
os
- the output stream on which to emit the XML document.comment
- a description of the property list, or null
if no comment is desired.IOException
- if writing to the specified output stream
results in an IOException
.NullPointerException
- if os
is null.ClassCastException
- if this Properties
object
contains any keys or values that are not
Strings
.Set<String> propertyNames()
The returned set is not backed by the Properties
object.
Changes to this Properties
are not reflected in the set,
or vice versa.
ClassCastException
- if any key in this property list
is not a string.Properties.defaults
,
Properties.stringPropertyNames()
,
Properties.propertyNames()
Copyright © 2012–2020 Luigi R. Viggiano. All rights reserved.