Class PropertyUtils
- java.lang.Object
-
- org.apache.maven.shared.filtering.PropertyUtils
-
public final class PropertyUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Modifier Constructor Description private
PropertyUtils()
Private empty constructor to prevent instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
getPropertyValue(java.lang.String k, java.util.Properties p, org.slf4j.Logger logger)
Retrieves a property value, replacing values like ${token} using the Properties to look them up.static java.util.Properties
loadPropertyFile(java.io.File propfile, boolean fail, boolean useSystemProps)
Reads a property file, resolving all internal variables.static java.util.Properties
loadPropertyFile(java.io.File propfile, boolean fail, boolean useSystemProps, org.slf4j.Logger logger)
Reads a property file, resolving all internal variables.static java.util.Properties
loadPropertyFile(java.io.File propFile, java.util.Properties baseProps)
Reads a property file, resolving all internal variables, using the supplied base properties.static java.util.Properties
loadPropertyFile(java.io.File propFile, java.util.Properties baseProps, org.slf4j.Logger logger)
Reads a property file, resolving all internal variables, using the supplied base properties.private static void
logCircularDetection(java.util.List<java.lang.String> valueChain, java.lang.String nk, org.slf4j.Logger logger)
Logs the detected cycle in properties resolution
-
-
-
Method Detail
-
loadPropertyFile
public static java.util.Properties loadPropertyFile(java.io.File propFile, java.util.Properties baseProps) throws java.io.IOException
Reads a property file, resolving all internal variables, using the supplied base properties.The properties are resolved iteratively, so if the value of property A refers to property B, then after resolution the value of property B will contain the value of property B.
- Parameters:
propFile
- The property file to load.baseProps
- Properties containing the initial values to substitute into the properties file.- Returns:
- Properties object containing the properties in the file with their values fully resolved.
- Throws:
java.io.IOException
- if profile does not exist, or cannot be read.
-
loadPropertyFile
public static java.util.Properties loadPropertyFile(java.io.File propFile, java.util.Properties baseProps, org.slf4j.Logger logger) throws java.io.IOException
Reads a property file, resolving all internal variables, using the supplied base properties.The properties are resolved iteratively, so if the value of property A refers to property B, then after resolution the value of property B will contain the value of property B.
- Parameters:
propFile
- The property file to load.baseProps
- Properties containing the initial values to substitute into the properties file.logger
- Logger instance- Returns:
- Properties object containing the properties in the file with their values fully resolved.
- Throws:
java.io.IOException
- if profile does not exist, or cannot be read.- Since:
- 3.1.2
-
loadPropertyFile
public static java.util.Properties loadPropertyFile(java.io.File propfile, boolean fail, boolean useSystemProps) throws java.io.IOException
Reads a property file, resolving all internal variables.- Parameters:
propfile
- The property file to loadfail
- whether to throw an exception when the file cannot be loaded or to return nulluseSystemProps
- whether to incorporate System.getProperties settings into the returned Properties object.- Returns:
- the loaded and fully resolved Properties object
- Throws:
java.io.IOException
- if profile does not exist, or cannot be read.
-
loadPropertyFile
public static java.util.Properties loadPropertyFile(java.io.File propfile, boolean fail, boolean useSystemProps, org.slf4j.Logger logger) throws java.io.IOException
Reads a property file, resolving all internal variables.- Parameters:
propfile
- The property file to loadfail
- whether to throw an exception when the file cannot be loaded or to return nulluseSystemProps
- whether to incorporate System.getProperties settings into the returned Properties object.logger
- Logger instance- Returns:
- the loaded and fully resolved Properties object
- Throws:
java.io.IOException
- if profile does not exist, or cannot be read.- Since:
- 3.1.2
-
getPropertyValue
private static java.lang.String getPropertyValue(java.lang.String k, java.util.Properties p, org.slf4j.Logger logger)
Retrieves a property value, replacing values like ${token} using the Properties to look them up. It will leave unresolved properties alone, trying for System properties, and implements reparsing (in the case that the value of a property contains a key), and will not loop endlessly on a pair like test = ${test}.- Parameters:
k
-p
-logger
- Logger instance- Returns:
- The filtered property value.
-
logCircularDetection
private static void logCircularDetection(java.util.List<java.lang.String> valueChain, java.lang.String nk, org.slf4j.Logger logger)
Logs the detected cycle in properties resolution- Parameters:
valueChain
- the sequence of properties resolved so farnk
- the key the closes the cyclelogger
- Logger instance
-
-