Class EnvarBasedValueSource
- java.lang.Object
-
- org.codehaus.plexus.interpolation.fixed.EnvarBasedValueSource
-
- All Implemented Interfaces:
FixedValueSource
public class EnvarBasedValueSource extends java.lang.Object implements FixedValueSource
ValueSource
which resolves expressions against the environment variables available from the underlying operating system (and possibly, the shell environment that created the present Java process). If the expression starts with 'env.', this prefix is trimmed before resolving the rest as an environment variable name.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
caseSensitive
private java.util.Properties
envars
private static java.util.Properties
envarsCaseInsensitive
private static java.util.Properties
envarsCaseSensitive
-
Constructor Summary
Constructors Constructor Description EnvarBasedValueSource()
Create a new value source for interpolation based on shell environment variables.EnvarBasedValueSource(boolean caseSensitive)
Create a new value source for interpolation based on shell environment variables.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.Properties
getEnvars(boolean caseSensitive)
java.lang.Object
getValue(java.lang.String expression, InterpolationState interpolationState)
If the expression starts with 'env.' then trim this prefix.(package private) static void
resetStatics()
reset static variables acting as a cache for testing purposes only
-
-
-
Constructor Detail
-
EnvarBasedValueSource
public EnvarBasedValueSource() throws java.io.IOException
Create a new value source for interpolation based on shell environment variables. In this case, envar keys ARE CASE SENSITIVE.- Throws:
java.io.IOException
- in case of an error.
-
EnvarBasedValueSource
public EnvarBasedValueSource(boolean caseSensitive) throws java.io.IOException
Create a new value source for interpolation based on shell environment variables.- Parameters:
caseSensitive
- Whether the environment variable key should be treated in a case-sensitive manner for lookups- Throws:
java.io.IOException
- in case of an error.
-
-
Method Detail
-
getEnvars
private static java.util.Properties getEnvars(boolean caseSensitive) throws java.io.IOException
- Throws:
java.io.IOException
-
getValue
public java.lang.Object getValue(java.lang.String expression, InterpolationState interpolationState)
If the expression starts with 'env.' then trim this prefix. Next, resolve the (possibly trimmed) expression as an environment variable name against the collection of environment variables that were read from the operating system when thisValueSource
instance was created.- Specified by:
getValue
in interfaceFixedValueSource
- Parameters:
expression
- envar expression, like 'HOME' or 'env.HOME'interpolationState
-InterpolationState
.- Returns:
- the environment variable value for the given expression
-
resetStatics
static void resetStatics()
reset static variables acting as a cache for testing purposes only
-
-