public class DefaultExecutionContext extends Object implements ExecutionContext
Modifier and Type | Field and Description |
---|---|
static ExecutionContextFactory |
FACTORY
Factory returning a new instance of
DefaultExecutionContext using
the default constructor. |
Constructor and Description |
---|
DefaultExecutionContext() |
DefaultExecutionContext(File currentDirectory) |
Modifier and Type | Method and Description |
---|---|
ConverterRegistry |
getConverterRegistry() |
File |
getCurrentDirectory()
Returns the current directory, never null.
|
Map<String,String> |
getEnv() |
Locale |
getLocale() |
File |
getRelativeToCurrentDirectory(File file)
Returns the given file but relative to the
current directory if the given file path is not absolute. |
Properties |
getSys() |
File |
getTempDirectory() |
String |
getUser()
Returns the user name, usually defined by the
"user.name" system
property. |
File |
getUserHome()
Returns the user home directory, usually defined by the
"user.home" system property. |
<V> ValueConverter<V> |
getValueConverterFor(Class<V> type) |
VariableContext |
getVariableContext() |
void |
setCurrentDirectory(File currentDirectory) |
void |
setCurrentDirectory(String currentDirectory) |
void |
setLocale(Locale locale) |
public static final ExecutionContextFactory FACTORY
DefaultExecutionContext
using
the default constructor.public DefaultExecutionContext()
public DefaultExecutionContext(File currentDirectory)
public void setCurrentDirectory(File currentDirectory)
public void setCurrentDirectory(String currentDirectory)
public File getRelativeToCurrentDirectory(File file)
ExecutionContext
current directory
if the given file path is not absolute. Most commands
should resolve files through this method since the unix4j current
directory and the Java current directory are not the same.getRelativeToCurrentDirectory
in interface ExecutionContext
file
- the file to return relative to the current directory if it
denotes a relative pathcurrent directory
public File getCurrentDirectory()
ExecutionContext
"user.dir"
system property is returned.getCurrentDirectory
in interface ExecutionContext
"user.dir"
system
property it has not been set explicitlySystem.getProperties()
public String getUser()
ExecutionContext
"user.name"
system
property.getUser
in interface ExecutionContext
"user.name"
system
propertySystem.getProperties()
public File getUserHome()
ExecutionContext
"user.home"
system property.getUserHome
in interface ExecutionContext
"user.home"
system propertySystem.getProperties()
public File getTempDirectory()
getTempDirectory
in interface ExecutionContext
public Locale getLocale()
getLocale
in interface ExecutionContext
public Properties getSys()
getSys
in interface ExecutionContext
public VariableContext getVariableContext()
getVariableContext
in interface ExecutionContext
public ConverterRegistry getConverterRegistry()
getConverterRegistry
in interface ExecutionContext
public <V> ValueConverter<V> getValueConverterFor(Class<V> type)
getValueConverterFor
in interface ExecutionContext
Copyright © 2024. All rights reserved.