public final class CommandEnvironment extends Object
Command
executes.
The environment is represented as a base and a set of additive changes. This makes it simple to add and change values or reset the environment to a known state. To remove or unset a variable, use a system-dependent method to read the current environment as a map, remove the necessary variables, then set the modified environment on top of an empty base.
Modifier and Type | Class and Description |
---|---|
static class |
CommandEnvironment.BaseEnvironment
Defines the target of environment changes.
|
Modifier and Type | Method and Description |
---|---|
CommandEnvironment |
copy()
Returns a copy of this environment.
|
static CommandEnvironment |
defaultEnvironment()
Returns a default environment with no changes.
|
static CommandEnvironment |
emptyEnvironment()
Returns an empty environment with no changes.
|
CommandEnvironment.BaseEnvironment |
getBase()
Returns this environment's base.
|
Map<String,String> |
getChanges()
Returns an unmodifiable view of the changes in this environment.
|
boolean |
isDefault()
Determines if this environment is the unmodified default environment.
|
CommandEnvironment |
set(String name,
String value)
Sets the given variable in this environment.
|
CommandEnvironment |
setAll(Map<String,String> env)
Sets all the variables defined by the given map in this environment.
|
public CommandEnvironment copy()
public static CommandEnvironment emptyEnvironment()
public static CommandEnvironment defaultEnvironment()
public CommandEnvironment set(String name, String value)
name
- the name of the variablevalue
- the value of the variableCommandEnvironment
public CommandEnvironment setAll(Map<String,String> env)
env
- a map from variable names to valuesCommandEnvironment
public CommandEnvironment.BaseEnvironment getBase()
public boolean isDefault()
true
if this environment uses the default base and has no
changes