public class PropertyLoader extends Properties
defaults
Constructor and Description |
---|
PropertyLoader(ClassLoader classLoader,
String propertiesFile) |
PropertyLoader(String propertiesFile) |
Modifier and Type | Method and Description |
---|---|
String |
get(Object key) |
boolean |
getBoolean(String key,
boolean dfault)
Gets a
boolean value
Returns "true" if the retrieved value is "true", otherwise "false"
Uses the getResolvedProperty(String) method. |
double |
getDouble(String key,
double dfault)
Gets a
double value
Uses the getResolvedProperty(String) method. |
int |
getInt(String key,
int dfault)
Gets an
int value
Uses the getResolvedProperty(String) method. |
List<String> |
getListProperty(String key)
Retrieves a list property value associated with the specified key.
|
List<String> |
getListProperty(String key,
String defaults)
Retrieves a list property value associated with the specified key.
|
long |
getLong(String key,
long dfault)
Gets a
long value
Uses the getResolvedProperty(String) method. |
String |
getProperty(String key) |
protected String |
getResolvedProperty(String key)
the method is like the
Properties.getProperty , but provides functionality to resolve ${variable}
Syntaxes. |
String |
getString(String key,
String dfault)
Gets a
String value
Uses the getResolvedProperty(String) method. |
String |
getUnresolvedProperty(String key) |
protected void |
load(ClassLoader classLoader,
String filename)
Load the contents of a properties file.
|
Object |
put(Object key,
Object value)
Deprecated.
Use
Properties.setProperty(String, String) instead! |
getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, getOrDefault, hashCode, isEmpty, keys, keySet, merge, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, values
public PropertyLoader(String propertiesFile)
public PropertyLoader(ClassLoader classLoader, String propertiesFile)
public String getProperty(String key)
getProperty
in class Properties
protected final String getResolvedProperty(String key)
Properties.getProperty
, but provides functionality to resolve ${variable}
Syntaxes. It uses the property values and system values to resolve the variables, and does so recursively.StringResolver
@Nonnull public List<String> getListProperty(@Nonnull String key)
getResolvedProperty(String)
method. If the resolved property value is null, an empty list is returned.key
- the key of the property value to retrieve@Nonnull public List<String> getListProperty(@Nonnull String key, @Nullable String defaults)
getResolvedProperty(String)
method. If the resolved property value is null, it returns the list of string
values provided as "defaults".key
- the key of the property value to retrievedefaults
- the default list of string values to return if the resolved property is null@Deprecated public Object put(Object key, Object value)
Properties.setProperty(String, String)
instead!Properties.setProperty(String, String)
if you want to set the property globally!
This method is used by Properties.load(InputStream)
to add all properties found (in a file/stream)
to the underlying Hashtable
.
protected void load(ClassLoader classLoader, String filename)
Optionally, this may be a comma-separated list of files to load, e.g.
which will cause both files to be loaded in the listed order.
log4j2.properties,DeploymentSpecifics.properties
public String getString(String key, String dfault)
String
value
Uses the getResolvedProperty(String)
method.key
- the Keydfault
- the default valuepublic boolean getBoolean(String key, boolean dfault)
boolean
value
Returns "true" if the retrieved value is "true", otherwise "false"
Uses the getResolvedProperty(String)
method.key
- the Keydfault
- the default valuepublic int getInt(String key, int dfault)
int
value
Uses the getResolvedProperty(String)
method.key
- the Keydfault
- the default valuepublic long getLong(String key, long dfault)
long
value
Uses the getResolvedProperty(String)
method.key
- the Keydfault
- the default valuepublic double getDouble(String key, double dfault)
double
value
Uses the getResolvedProperty(String)
method.key
- the Keydfault
- the default valueCopyright © 2023 Frank!Framework. All rights reserved.