public abstract class SystemReader
extends java.lang.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 |
---|---|
abstract long |
getCurrentTime() |
java.text.DateFormat |
getDateTimeInstance(int dateStyle,
int timeStyle)
Returns a date/time format instance for the given styles.
|
abstract java.lang.String |
getenv(java.lang.String variable) |
abstract java.lang.String |
getHostname()
Gets the hostname of the local host.
|
static SystemReader |
getInstance() |
java.util.Locale |
getLocale() |
abstract java.lang.String |
getProperty(java.lang.String key) |
java.text.SimpleDateFormat |
getSimpleDateFormat(java.lang.String pattern)
Returns a simple date format instance as specified by the given pattern.
|
java.util.TimeZone |
getTimeZone() |
abstract int |
getTimezone(long when) |
abstract FileBasedConfig |
openSystemConfig(Config parent,
FS fs) |
abstract FileBasedConfig |
openUserConfig(Config parent,
FS fs) |
static void |
setInstance(SystemReader newReader) |
public static SystemReader getInstance()
public static void setInstance(SystemReader newReader)
newReader
- the new instance to use when accessing properties.public abstract java.lang.String getHostname()
public abstract java.lang.String getenv(java.lang.String variable)
variable
- system variable to readpublic abstract java.lang.String getProperty(java.lang.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 abstract int getTimezone(long when)
when
- TODOpublic java.util.TimeZone getTimeZone()
public java.util.Locale getLocale()
public java.text.SimpleDateFormat getSimpleDateFormat(java.lang.String pattern)
pattern
- the pattern as defined in
SimpleDateFormat.SimpleDateFormat(String)
public java.text.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)
Copyright © 2012. All Rights Reserved.