public class TypedProperties
extends java.util.AbstractMap<java.lang.String,java.lang.Object>
Map to load / store / update untyped or typed properties.
The map is untyped if all properties are strings.
When this is the case, the properties are stored without
any encoding, else all properties are encoded using
the ConfigurationHandler
.
Modifier and Type | Class and Description |
---|---|
private static class |
TypedProperties.DynamicMap |
static interface |
TypedProperties.SubstitutionCallback |
Modifier and Type | Field and Description |
---|---|
private TypedProperties.SubstitutionCallback |
callback |
static java.lang.String |
ENV_PREFIX |
private Properties |
storage |
private boolean |
substitute |
Constructor and Description |
---|
TypedProperties() |
TypedProperties(boolean substitute) |
TypedProperties(TypedProperties.SubstitutionCallback callback) |
TypedProperties(TypedProperties.SubstitutionCallback callback,
boolean substitute) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
private static java.lang.Object |
convertFromString(java.lang.String value) |
private static java.lang.String |
convertToString(java.lang.Object value) |
private void |
ensureTyped() |
java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> |
entrySet() |
java.lang.Object |
get(java.lang.Object key) |
java.util.List<java.lang.String> |
getComments(java.lang.String key) |
java.util.List<java.lang.String> |
getFooter()
Return the comment footer.
|
java.util.List<java.lang.String> |
getHeader()
Return the comment header.
|
java.util.List<java.lang.String> |
getRaw(java.lang.String key) |
void |
load(java.io.File location) |
void |
load(java.io.InputStream is) |
void |
load(java.io.Reader reader) |
void |
load(java.net.URL location) |
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
prepare(java.util.Map<java.lang.String,TypedProperties> properties) |
private java.lang.Object |
put(java.lang.String key,
java.util.List<java.lang.String> commentLines,
java.util.List<java.lang.String> valueLines) |
java.lang.Object |
put(java.lang.String key,
java.util.List<java.lang.String> commentLines,
java.lang.Object value) |
java.lang.Object |
put(java.lang.String key,
java.lang.Object value) |
java.lang.Object |
put(java.lang.String key,
java.lang.String comment,
java.lang.Object value) |
java.lang.Object |
remove(java.lang.Object key) |
void |
save(java.io.File location) |
void |
save(java.io.OutputStream os) |
void |
save(java.io.Writer writer) |
void |
setFooter(java.util.List<java.lang.String> footer)
Set the comment footer.
|
void |
setHeader(java.util.List<java.lang.String> header)
Set the comment header.
|
void |
store(java.io.OutputStream os,
java.lang.String comment)
Store a properties into a output stream, preserving comments, special character, etc.
|
static void |
substitute(java.util.Map<java.lang.String,TypedProperties> properties,
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> dynamic,
TypedProperties.SubstitutionCallback callback,
boolean finalSubstitution) |
void |
substitute(TypedProperties.SubstitutionCallback cb) |
boolean |
update(java.util.Map<java.lang.String,java.lang.Object> props) |
boolean |
update(TypedProperties properties) |
private static TypedProperties.SubstitutionCallback |
wrap(InterpolationHelper.SubstitutionCallback cb) |
clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, toString, values
public static final java.lang.String ENV_PREFIX
private final Properties storage
private final TypedProperties.SubstitutionCallback callback
private final boolean substitute
public TypedProperties()
public TypedProperties(boolean substitute)
public TypedProperties(TypedProperties.SubstitutionCallback callback)
public TypedProperties(TypedProperties.SubstitutionCallback callback, boolean substitute)
public void load(java.io.File location) throws java.io.IOException
java.io.IOException
public void load(java.net.URL location) throws java.io.IOException
java.io.IOException
public void load(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public void load(java.io.Reader reader) throws java.io.IOException
java.io.IOException
public void save(java.io.File location) throws java.io.IOException
java.io.IOException
public void save(java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public void save(java.io.Writer writer) throws java.io.IOException
java.io.IOException
public void store(java.io.OutputStream os, java.lang.String comment) throws java.io.IOException
os
- an output stream.comment
- this parameter is ignored as this Propertiesjava.io.IOException
- If storing failspublic java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
entrySet
in interface java.util.Map<java.lang.String,java.lang.Object>
entrySet
in class java.util.AbstractMap<java.lang.String,java.lang.Object>
public java.lang.Object put(java.lang.String key, java.lang.Object value)
put
in interface java.util.Map<java.lang.String,java.lang.Object>
put
in class java.util.AbstractMap<java.lang.String,java.lang.Object>
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map<java.lang.String,java.lang.Object>
get
in class java.util.AbstractMap<java.lang.String,java.lang.Object>
public java.lang.Object put(java.lang.String key, java.util.List<java.lang.String> commentLines, java.lang.Object value)
public java.lang.Object put(java.lang.String key, java.lang.String comment, java.lang.Object value)
private java.lang.Object put(java.lang.String key, java.util.List<java.lang.String> commentLines, java.util.List<java.lang.String> valueLines)
private void ensureTyped()
public boolean update(java.util.Map<java.lang.String,java.lang.Object> props)
public boolean update(TypedProperties properties)
public java.util.List<java.lang.String> getRaw(java.lang.String key)
public java.util.List<java.lang.String> getComments(java.lang.String key)
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.String,java.lang.Object>
remove
in class java.util.AbstractMap<java.lang.String,java.lang.Object>
public void clear()
clear
in interface java.util.Map<java.lang.String,java.lang.Object>
clear
in class java.util.AbstractMap<java.lang.String,java.lang.Object>
public java.util.List<java.lang.String> getHeader()
public void setHeader(java.util.List<java.lang.String> header)
header
- the header to usepublic java.util.List<java.lang.String> getFooter()
public void setFooter(java.util.List<java.lang.String> footer)
footer
- the footer to usepublic void substitute(TypedProperties.SubstitutionCallback cb)
private static TypedProperties.SubstitutionCallback wrap(InterpolationHelper.SubstitutionCallback cb)
public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> prepare(java.util.Map<java.lang.String,TypedProperties> properties)
public static void substitute(java.util.Map<java.lang.String,TypedProperties> properties, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> dynamic, TypedProperties.SubstitutionCallback callback, boolean finalSubstitution)
private static java.lang.String convertToString(java.lang.Object value)
private static java.lang.Object convertFromString(java.lang.String value)