public class VersionInfo extends Object
All available version information is provided in strings, where the string format is informal and subject to change without notice. Version information is provided for debugging output and interpretation by humans, not for automated processing in applications.
| Modifier and Type | Field and Description |
|---|---|
static String |
PROPERTY_MODULE |
static String |
PROPERTY_RELEASE |
static String |
PROPERTY_TIMESTAMP
Deprecated.
This will be removed in 6.0.
|
static String |
UNAVAILABLE
A string constant for unavailable information.
|
static String |
VERSION_PROPERTY_FILE
The filename of the version information files.
|
| Modifier | Constructor and Description |
|---|---|
protected |
VersionInfo(String pckg,
String module,
String release,
String time,
String clsldr)
Instantiates version information.
|
| Modifier and Type | Method and Description |
|---|---|
protected static VersionInfo |
fromMap(String pckg,
Map<?,?> info,
ClassLoader clsldr)
Instantiates version information from properties.
|
String |
getClassloader()
Obtains the classloader used to read the version information.
|
String |
getModule()
Obtains the name of the versioned module or informal unit.
|
String |
getPackage()
Obtains the package name.
|
String |
getRelease()
Obtains the release of the versioned module or informal unit.
|
static String |
getSoftwareInfo(String name,
String pkg,
Class<?> cls)
Gets software information as
"<name>/<release> (Java/<java.version>)". |
String |
getTimestamp()
Deprecated.
This will be removed in 6.0.
|
static VersionInfo[] |
loadVersionInfo(String[] pckgs,
ClassLoader clsldr)
Loads version information for a list of packages.
|
static VersionInfo |
loadVersionInfo(String pckg,
ClassLoader clsldr)
Loads version information for a package.
|
String |
toString()
Provides the version information in human-readable format.
|
public static final String UNAVAILABLE
public static final String VERSION_PROPERTY_FILE
public static final String PROPERTY_MODULE
public static final String PROPERTY_RELEASE
@Deprecated public static final String PROPERTY_TIMESTAMP
public final String getPackage()
nullpublic final String getModule()
nullpublic final String getRelease()
null@Deprecated public final String getTimestamp()
nullpublic final String getClassloader()
toString output of the classloader,
since the version information should not keep a reference to
the classloader itself. That could prevent garbage collection.nullpublic String toString()
public static VersionInfo[] loadVersionInfo(String[] pckgs, ClassLoader clsldr)
pckgs - the packages for which to load version infoclsldr - the classloader to load from, or
null for the thread context classloadernullpublic static VersionInfo loadVersionInfo(String pckg, ClassLoader clsldr)
pckg - the package for which to load version information,
for example "org.apache.http".
The package name should NOT end with a dot.clsldr - the classloader to load from, or
null for the thread context classloadernull if not availableprotected static VersionInfo fromMap(String pckg, Map<?,?> info, ClassLoader clsldr)
pckg - the package for the version informationinfo - the map from string keys to string values,
for example Propertiesclsldr - the classloader, or nullpublic static String getSoftwareInfo(String name, String pkg, Class<?> cls)
"<name>/<release> (Java/<java.version>)". If release is
UNAVAILABLE, it will be omitted.
For example:
"Apache-HttpClient/4.3 (Java/1.6.0_35)"
name - the component name, like "Apache-HttpClient".pkg - the package for which to load version information, for example "org.apache.http". The package name
should NOT end with a dot.cls - the class' class loader to load from, or null for the thread context class loaderCopyright © 2005–2021 The Apache Software Foundation. All rights reserved.