This class is a 100% static placeholder for global methods and fields of ALib. Among the things implemented here are:
Public Static Fields | |
static Configuration | config =null |
static AString | configCategoryName = new AString( "ALIB" ) |
static Long | mainThreadID = Thread.currentThread().threadId() |
static final int | revision =0 |
static SmartLock | stdOutputStreamsLock = new SmartLock() |
static final int | version =2402 |
Public Static Methods | |
static void | init (Configuration config) |
synchronized static void | init (String[] args) |
static boolean | readBoolean (Substring src) |
static Case | readCase (Substring src) |
static Inclusion | readInclusion (Substring src) |
static void | sleep (Ticks ticks) |
static void | sleepMicros (long microsecs) |
static void | sleepMillis (int millisecs) |
static void | sleepNanos (long nanosecs) |
static boolean | sysInfo_IsAndroid () |
static void | terminationCleanUp () |
Protected Static Fields | |
static boolean | isInitialized = false |
Private Static Fields | |
static char[] | trueValuesBoolean = { 't', '1', 'y' } |
static char[] | trueValuesCase = { 's', 't', '1', 'y' } |
static char[] | trueValuesInclusion = { 'i', 't', '1', 'y' } |
Protected Static Methods | |
static void | init () |
|
staticprotected |
Used by init functions.
|
static |
|
static |
This method must be called prior to using ALib, e.g. at the beginning of the main()
method of an application. It is OK, to call this method more than once, which allows independent code blocks (e.g. libraries) to bootstrap ALIB independently. However, only the first invocation is effective
The very first invocation should not be interrupted by a parallel invocation of a second thread. Consequently, with more complex applications it is recommended to explicitly invoke this method once when the software is bootstrapped.
If command line parameters should be used for configuring ALox, then the very first call to this method has to provide the argc and argv parameters. Subsequent calls to this method with different parameters do not change the setup.
If other, custom configuration data sources should be used already with this method use overloaded method ALIB.init(Configuration).
args | Parameters taken from standard Java method main() (the list of command line arguments). Accepts null to ignore command line parameters. |
|
static |
Interprets given src as a boolean value. enums.Inclusion. If the case insensitive comparison of the first non-whitespace characters of the string with with values "t", "1", "y", "on", "ok" matches, true
is returned. Otherwise, including the case that src is 'nulled', false
is returned.
src | The string to 'parse'. |
Interprets given src as a value of enum type enums.Case. If the case insensitive comparison of the first non-whitespace characters of the string with values "s", "y", "t", "1" matches, Case.SENSITIVE is returned. Otherwise, including the case that src is 'nulled', Case.IGNORE is returned.
src | The string to 'parse'. |
Interprets given src as a value of enum type enums.Inclusion. If the case insensitive comparison of the first non-whitespace characters of the string with values "i", "y", "t", "1" matches, Inclusion.INCLUDE is returned. Otherwise, including the case that src is 'nulled', Inclusion.EXCLUDE is returned.
src | The string to 'parse'. |
|
static |
Suspends the current thread for the given number of milliseconds. Variants of this method are sleepMillis, sleepMicros and sleepNanos.
ticks | Sleep time in Ticks. |
|
static |
Suspends the current thread for the given number of microseconds. Variants of this method are sleep, sleepMillis and sleepNanos.
microsecs | Sleep time in microseconds. |
|
static |
Suspends the current thread for the given number of milliseconds. Variants of this method are sleep, sleepMicros and sleepNanos.
millisecs | Sleep time in milliseconds. |
|
static |
Suspends the current thread for the given number of nanoseconds. Variants of this method are sleep, sleepMillis and sleepNanos.
nanosecs | Sleep time in nanoseconds. |
|
static |
Detects if this is an Android application. This, in the current implementation is done by looking for class
true
if the calling process is running on Android
|
static |
Got nothing to do in Java.
|
static |
The configuration used by ALib. This is received or created with overloaded init methods. It might be shared with other libraries or can be an instance explicitly dedicated to the ALib library.
The option to use an exclusive one may be used to store ALib configuration variables in different configuration files, e.g. to reduce "clutter" of an applications' then "main" configuration file.
Changes should only be made at very initial, single threaded bootstrap code, with the invocation of the according method init(Configuration).
The name of the configuration category of configuration variables used by the AWorx library.
Defaults to "ALIB".
This value can be changed to avoid conflicts between applications (especially in respect to environment variable settings). Changes should be placed at very initial bootstrap code, before the invocation of init.
|
staticprotected |
State of initialization, used to avoid double initialization.
|
static |
The ID of the thread that initialized this static field. This is supposedly thread "main".
|
static |
This is a smart mutex that allows to lock an applications' standard output streams.
In multi-threaded processes, to protect the output streams from concurrent access, this smart lock might be used by any entity that writes data to the streams. Before it can be used (acquired and released), it is needed to register with the object using SmartLock.addAcquirer. This has to be done once per thread that aims to write to the stream. Then, prior to writing, this object has to be acquired and after writing released.
Because often, the standard output stream and standard error stream are identical, ALib provides one single lock for both, to protect also against interwoven standard output and error information.
If the 'entity' that is registering is not of type ThreadLock it is allowed to provide null
in the parameter of method AddAcquirer. In this case, the process of adding and removing acquirers is not performed in a thread safe way. Therefore it is advised to register so called anonymous (null
) acquirers only at bootstrap time, when no parallel threads were started, yet.
If an application is deemed to always write to the standard output streams from within multiple threads, an alternative to registering each writing entity, is to invoke AddAcquirer just two times in a row with null
at the start of a process and then never do this again (and never de-register). This way, no thread needs to register/deregister but threads may still Acquire and Release the lock without being registered. In other words, once a smart lock is enabled, subsequent registrations are just used to count and identify the de-registration.
|
staticprivate |
Strings used to identify a boolean value from a string representation
|
staticprivate |
Strings used to identify an enum Case from a string representation
|
staticprivate |
Strings used to identify an enum Inclusion from a string representation
|
static |
The version of ALib. The version number follows the scheme YYMM (2-digit year, 2-digit month) of the initial release date. Besides this version number, field revision indicates if this is a revised version of a former release.