Top Description Inners Fields Constructors Methods
org.eclipse.jgit.util

public abstract Class SystemReader

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.util.SystemReader.Default, org.eclipse.jgit.util.SystemReader.Delegate
Imports
java.io.File, .IOException, java.net.InetAddress, .UnknownHostException, java.nio.charset.Charset, .IllegalCharsetNameException, .UnsupportedCharsetException, java.nio.file.InvalidPathException, .Path, .Paths, java.text.DateFormat, .SimpleDateFormat, java.time.Instant, .LocalDateTime, .ZoneId, .ZoneOffset, java.util.Locale, .TimeZone, java.util.concurrent.atomic.AtomicReference, org.eclipse.jgit.errors.ConfigInvalidException, .CorruptObjectException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.Config, .Constants, .ObjectChecker, .StoredConfig, org.eclipse.jgit.storage.file.FileBasedConfig, .UserConfigFile, org.eclipse.jgit.util.time.MonotonicClock, .MonotonicSystemClock, org.slf4j.Logger, .LoggerFactory

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static class
SystemReader.Delegate

Delegating SystemReader.

Field Summary

Modifier and TypeField and Description
private static final SystemReader
private volatile Charset
private static final String
private static volatile SystemReader
private static volatile Boolean
private static volatile Boolean
private static volatile Boolean
private AtomicReference<FileBasedConfig>
private static final Logger
private static final boolean
private ObjectChecker
private AtomicReference<FileBasedConfig>
private AtomicReference<FileBasedConfig>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
checkPath(String
path string to scan.
path
)

Check tree path entry for validity.

public void
checkPath(byte[]
path string to scan.
path
)

Check tree path entry for validity.

public LocalDateTime

Returns:

the current system time
civilNow
()

Get "now" as civil time, in the System timezone

public MonotonicClock

Returns:

clock instance preferred by this system.
getClock
()

Get clock instance preferred by this system.

public abstract long

Returns:

the current system time
getCurrentTime
()
Deprecated since 7.1. Use now()

Get the current system time

public DateFormat

Returns:

the date format
getDateTimeInstance
(int dateStyle, int timeStyle)

Returns a date/time format instance for the given styles.

public Charset

Returns:

the Charset
getDefaultCharset
()

Retrieves the default Charset depending on the system locale.

public abstract String

Returns:

value of the system variable
getenv
(String
system variable to read
variable
)

Get value of the system variable

public abstract String

Returns:

the canonical hostname
getHostname
()

Gets the hostname of the local host.

public static SystemReader

Returns:

the current SystemReader instance.
getInstance
()

Get the current SystemReader instance

public StoredConfig

Returns:

the jgit configuration located at $XDG_CONFIG_HOME/jgit/config
getJGitConfig
()

Get the jgit configuration located at $XDG_CONFIG_HOME/jgit/config.

public Locale

Returns:

the locale to use
getLocale
()

Get the locale to use

private String
public abstract String

Returns:

value of the system property
getProperty
(String
of the system property to read
key
)

Get value of the system property

public SimpleDateFormat

Returns:

the simple date format
getSimpleDateFormat
(String pattern)

Returns a simple date format instance as specified by the given pattern.

public SimpleDateFormat

Returns:

the simple date format
getSimpleDateFormat
(String pattern, Locale
locale to be used for the SimpleDateFormat
locale
)

Returns a simple date format instance as specified by the given pattern.

public StoredConfig

Returns:

the gitconfig configuration found in the system-wide "etc" directory
getSystemConfig
()

Get the gitconfig configuration found in the system-wide "etc" directory.

public abstract int

Returns:

the local time zone
getTimezone
(long
a system timestamp
when
)
Deprecated since 7.1. Use getTimeZoneAt(Instant) instead.

Get the local time zone

public TimeZone

Returns:

system time zone, possibly mocked for testing
getTimeZone
()
Deprecated since 7.1. Use getTimeZoneId()

Get system time zone, possibly mocked for testing

public ZoneOffset

Returns:

the local time zone
getTimeZoneAt
(Instant
a system timestamp
when
)

Get the local time zone offset at "when" time

public ZoneId

Returns:

system time zone, possibly mocked for testing
getTimeZoneId
()

Get system time zone, possibly mocked for testing

public StoredConfig

Returns:

the git configuration found in the user home
getUserConfig
()

Get the git configuration found in the user home.

public Path

Returns:

a Path denoting the directory, which may exist or not, or null if the environment variable is not set and there is no home directory, or the path is invalid.
getXdgConfigDirectory
(FS
FS to get the user's home directory
fileSystem
)

Gets the directory denoted by environment variable XDG_CONFIG_HOME.

private void
init()

private static boolean
public boolean

Returns:

true if we are running on Linux.
isLinux
()

Whether we are running on Linux.

public boolean

Returns:

true if we are running on Mac OS X
isMacOS
()

Whether we are running on Mac OS X

public boolean

Returns:

whether performance trace is enabled
isPerformanceTraceEnabled
()

Whether performance trace is enabled

public boolean

Returns:

true if we are running on Windows.
isWindows
()

Whether we are running on Windows.

public Instant

Returns:

the current system time
now
()

Get the current system time

public abstract FileBasedConfig

Returns:

the jgit configuration located at $XDG_CONFIG_HOME/jgit/config
openJGitConfig
(Config
a config with values not found directly in the returned config
parent
,
FS
the file system abstraction which will be necessary to perform certain file system operations.
fs
)

Open the jgit configuration located at $XDG_CONFIG_HOME/jgit/config.

public abstract FileBasedConfig

Returns:

the gitconfig configuration found in the system-wide "etc" directory
openSystemConfig
(Config
a config with values not found directly in the returned config. Null is a reasonable value here.
parent
,
FS
the file system abstraction which will be necessary to perform certain file system operations.
fs
)

Open the gitconfig configuration found in the system-wide "etc" directory.

public abstract FileBasedConfig

Returns:

the git configuration found in the user home
openUserConfig
(Config
a config with values not found directly in the returned config
parent
,
FS
the file system abstraction which will be necessary to perform certain file system operations.
fs
)

Open the git configuration found in the user home.

public static void
setInstance(SystemReader
the new instance to use when accessing properties, or null for the default instance.
newReader
)

Set a new SystemReader instance to use when accessing properties.

protected final void
setPlatformChecker()

Should be used in tests when the platform is explicitly changed.

private void
updateAll(Config
configuration to reload if outdated
config
)

Update config and its parents if they seem modified

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait