public abstract class SystemReader extends Object
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.
| Constructor and Description | 
|---|
SystemReader()  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
checkPath(byte[] path)
Check tree path entry for validity. 
 | 
void | 
checkPath(String path)
Check tree path entry for validity. 
 | 
MonotonicClock | 
getClock()
Get clock instance preferred by this system. 
 | 
abstract long | 
getCurrentTime()
Get the current system time 
 | 
DateFormat | 
getDateTimeInstance(int dateStyle,
                   int timeStyle)
Returns a date/time format instance for the given styles. 
 | 
abstract String | 
getenv(String variable)
Get value of the system variable 
 | 
abstract String | 
getHostname()
Gets the hostname of the local host. 
 | 
static SystemReader | 
getInstance()
Get time since epoch, with up to millisecond resolution. 
 | 
Locale | 
getLocale()
Get the locale to use 
 | 
abstract String | 
getProperty(String key)
Get value of the system property 
 | 
SimpleDateFormat | 
getSimpleDateFormat(String pattern)
Returns a simple date format instance as specified by the given pattern. 
 | 
SimpleDateFormat | 
getSimpleDateFormat(String pattern,
                   Locale locale)
Returns a simple date format instance as specified by the given pattern. 
 | 
TimeZone | 
getTimeZone()
Get system time zone, possibly mocked for testing 
 | 
abstract int | 
getTimezone(long when)
Get the local time zone 
 | 
boolean | 
isMacOS()
Whether we are running on Mac OS X 
 | 
boolean | 
isWindows()
Whether we are running on Windows. 
 | 
abstract FileBasedConfig | 
openSystemConfig(Config parent,
                FS fs)
Open the gitonfig configuration found in the system-wide "etc" directory 
 | 
abstract FileBasedConfig | 
openUserConfig(Config parent,
              FS fs)
Open the git configuration found in the user home 
 | 
static void | 
setInstance(SystemReader newReader)
Set the new instance to use when accessing properties. 
 | 
protected void | 
setPlatformChecker()
Should be used in tests when the platform is explicitly changed. 
 | 
public static SystemReader getInstance()
public static void setInstance(SystemReader newReader)
newReader - the new instance to use when accessing properties, or null for
            the default instance.protected final void setPlatformChecker()
public abstract String getHostname()
public abstract String getenv(String variable)
variable - system variable to readpublic abstract String getProperty(String key)
key - of the system property to readpublic abstract FileBasedConfig openUserConfig(Config parent, FS fs)
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.public abstract FileBasedConfig openSystemConfig(Config parent, FS fs)
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.public abstract long getCurrentTime()
public MonotonicClock getClock()
public abstract int getTimezone(long when)
when - a system timestamppublic TimeZone getTimeZone()
public Locale getLocale()
public SimpleDateFormat getSimpleDateFormat(String pattern)
pattern - the pattern as defined in
            SimpleDateFormat.SimpleDateFormat(String)public SimpleDateFormat getSimpleDateFormat(String pattern, Locale locale)
pattern - the pattern as defined in
            SimpleDateFormat.SimpleDateFormat(String)locale - locale to be used for the SimpleDateFormatpublic DateFormat getDateTimeInstance(int dateStyle, int timeStyle)
dateStyle - the date style as specified in
            DateFormat.getDateTimeInstance(int, int)timeStyle - the time style as specified in
            DateFormat.getDateTimeInstance(int, int)public boolean isWindows()
public boolean isMacOS()
public void checkPath(String path) throws CorruptObjectException
 Scans a multi-directory path string such as "src/main.c".
path - path string to scan.CorruptObjectException - path is invalid.public void checkPath(byte[] path)
               throws CorruptObjectException
 Scans a multi-directory path string such as "src/main.c".
path - path string to scan.CorruptObjectException - path is invalid.Copyright © 2020 Eclipse JGit Project. All rights reserved.