org.eclipse.jgit.util
Class SystemReader
java.lang.Object
org.eclipse.jgit.util.SystemReader
public abstract class SystemReader
- extends Object
Interface to read values from the system.
When writing unit tests, extending this interface with a custom class
permits to simulate an access to a system variable or property and
permits to control the user's global configuration.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SystemReader
public SystemReader()
getInstance
public static SystemReader getInstance()
- Returns:
- the live instance to read system properties.
setInstance
public static void setInstance(SystemReader newReader)
- Parameters:
newReader - the new instance to use when accessing properties.
getHostname
public abstract String getHostname()
- Gets the hostname of the local host. If no hostname can be found, the
hostname is set to the default value "localhost".
- Returns:
- the canonical hostname
getenv
public abstract String getenv(String variable)
- Parameters:
variable - system variable to read
- Returns:
- value of the system variable
getProperty
public abstract String getProperty(String key)
- Parameters:
key - of the system property to read
- Returns:
- value of the system property
openUserConfig
public abstract FileBasedConfig openUserConfig(Config parent,
FS fs)
- Parameters:
parent - a config with values not found directly in the returned configfs - the file system abstraction which will be necessary to perform
certain file system operations.
- Returns:
- the git configuration found in the user home
openSystemConfig
public abstract FileBasedConfig openSystemConfig(Config parent,
FS fs)
- Parameters:
parent - a config with values not found directly in the returned
config. Null is a reasonable value here.fs - the file system abstraction which will be necessary to perform
certain file system operations.
- Returns:
- the gitonfig configuration found in the system-wide "etc"
directory
getCurrentTime
public abstract long getCurrentTime()
- Returns:
- the current system time
getTimezone
public abstract int getTimezone(long when)
- Parameters:
when - TODO
- Returns:
- the local time zone
getTimeZone
public TimeZone getTimeZone()
- Returns:
- system time zone, possibly mocked for testing
- Since:
- 1.2
getLocale
public Locale getLocale()
- Returns:
- the locale to use
- Since:
- 1.2
Copyright © 2011. All Rights Reserved.