Package org.frankframework.util
Class PropertyLoader
- All Implemented Interfaces:
Serializable,Cloneable,Map<Object,Object>
- Direct Known Subclasses:
AppConstants,CredentialConstants
Load properties from a file on classpath. The file can be in
.properties format, or yaml format.
When getting a property, if the value contains any string substitution expressions these are first evaluated. See StringResolver
for more information on the format.- See Also:
-
Field Summary
Fields inherited from class java.util.Properties
defaults -
Constructor Summary
ConstructorsConstructorDescriptionPropertyLoader(File propertiesFile, Properties defaults) PropertyLoader(ClassLoader classLoader, String propertiesFile) PropertyLoader(String propertiesFile) -
Method Summary
Modifier and TypeMethodDescriptionfinal booleancontainsKey(Object objKey) booleangetBoolean(String key, boolean dfault) Gets abooleanvalue Returns "true" if the retrieved value is "true", otherwise "false" Uses thegetResolvedProperty(String)method.doubleGets adoublevalue Uses thegetResolvedProperty(String)method.intGets anintvalue Uses thegetResolvedProperty(String)method.getListProperty(String key) Retrieves a list property value associated with the specified key.getListProperty(String key, String defaults) Retrieves a list property value associated with the specified key.longGets alongvalue Uses thegetResolvedProperty(String)method.<T extends Enum<T>>
TgetOrDefault(String key, T dfault) getProperty(String key) protected final Stringthe method is like theProperties.getProperty, but provides functionality to resolve${variable}Syntaxes.Gets aStringvalue Uses thegetResolvedProperty(String)method.protected voidload(ClassLoader classLoader, String filename) Load the contents of a properties file.Deprecated.Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsValue, elements, entrySet, equals, forEach, getOrDefault, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Constructor Details
-
PropertyLoader
- Throws:
IOException
-
PropertyLoader
-
PropertyLoader
-
-
Method Details
-
get
-
getProperty
- Overrides:
getPropertyin classProperties
-
getUnresolvedProperty
-
containsKey
- Specified by:
containsKeyin interfaceMap<Object,Object> - Overrides:
containsKeyin classProperties
-
getResolvedProperty
the method is like theProperties.getProperty, but provides functionality to resolve${variable}Syntaxes. It uses the property values and system values to resolve the variables, and does so recursively.- See Also:
-
getOrDefault
-
getListProperty
Retrieves a list property value associated with the specified key. The method first resolves the property value using thegetResolvedProperty(String)method. If the resolved property value is null, an empty list is returned.- Parameters:
key- the key of the property value to retrieve- Returns:
- a list of string values associated with the specified key, or an empty list if the resolved property is null
-
getListProperty
Retrieves a list property value associated with the specified key. The method first resolves the property value using thegetResolvedProperty(String)method. If the resolved property value is null, it returns the list of string values provided as "defaults".- Parameters:
key- the key of the property value to retrievedefaults- the default list of string values to return if the resolved property is null- Returns:
- a list of string values associated with the specified key, or the default list if the resolved property is null. If the defaults is also null, then returns an empty list.
-
put
Deprecated.UseProperties.setProperty(String, String)instead!Add property only in the local PropertyLoader! Do not use this method and useProperties.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 underlyingHashtable. -
load
Load the contents of a properties file.Optionally, this may be a comma-separated list of files to load, e.g.
log4j2.properties,DeploymentSpecifics.propertieswhich will cause both files to be loaded in the listed order. -
getString
Gets aStringvalue Uses thegetResolvedProperty(String)method.- Parameters:
key- the Keydfault- the default value- Returns:
- String
-
getBoolean
Gets abooleanvalue Returns "true" if the retrieved value is "true", otherwise "false" Uses thegetResolvedProperty(String)method.- Parameters:
key- the Keydfault- the default value- Returns:
- double
-
getInt
Gets anintvalue Uses thegetResolvedProperty(String)method.- Parameters:
key- the Keydfault- the default value- Returns:
- int
-
getLong
Gets alongvalue Uses thegetResolvedProperty(String)method.- Parameters:
key- the Keydfault- the default value- Returns:
- long
-
getDouble
Gets adoublevalue Uses thegetResolvedProperty(String)method.- Parameters:
key- the Keydfault- the default value- Returns:
- double
-
Properties.setProperty(String, String)instead!