Package org.apache.http.util
Class VersionInfo
- java.lang.Object
-
- org.apache.http.util.VersionInfo
-
public class VersionInfo extends Object
Provides access to version information for HTTP components. Static methods are used to extract version information from property files that are automatically packaged with HTTP component release JARs.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.
- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description static String
PROPERTY_MODULE
static String
PROPERTY_RELEASE
static String
PROPERTY_TIMESTAMP
static String
UNAVAILABLE
A string constant for unavailable information.static String
VERSION_PROPERTY_FILE
The filename of the version information files.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.String
getTimestamp()
Obtains the timestamp of the versioned module or informal unit.static String
getUserAgent(String name, String pkg, Class<?> cls)
Sets the user agent to"<name>/<release> (Java/<java.version>)"
.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.
-
-
-
Field Detail
-
UNAVAILABLE
public static final String UNAVAILABLE
A string constant for unavailable information.- See Also:
- Constant Field Values
-
VERSION_PROPERTY_FILE
public static final String VERSION_PROPERTY_FILE
The filename of the version information files.- See Also:
- Constant Field Values
-
PROPERTY_MODULE
public static final String PROPERTY_MODULE
- See Also:
- Constant Field Values
-
PROPERTY_RELEASE
public static final String PROPERTY_RELEASE
- See Also:
- Constant Field Values
-
PROPERTY_TIMESTAMP
public static final String PROPERTY_TIMESTAMP
- See Also:
- Constant Field Values
-
-
Method Detail
-
getPackage
public final String getPackage()
Obtains the package name. The package name identifies the module or informal unit.- Returns:
- the package name, never
null
-
getModule
public final String getModule()
Obtains the name of the versioned module or informal unit. This data is read from the version information for the package.- Returns:
- the module name, never
null
-
getRelease
public final String getRelease()
Obtains the release of the versioned module or informal unit. This data is read from the version information for the package.- Returns:
- the release version, never
null
-
getTimestamp
public final String getTimestamp()
Obtains the timestamp of the versioned module or informal unit. This data is read from the version information for the package.- Returns:
- the timestamp, never
null
-
getClassloader
public final String getClassloader()
Obtains the classloader used to read the version information. This is just thetoString
output of the classloader, since the version information should not keep a reference to the classloader itself. That could prevent garbage collection.- Returns:
- the classloader description, never
null
-
toString
public String toString()
Provides the version information in human-readable format.
-
loadVersionInfo
public static VersionInfo[] loadVersionInfo(String[] pckgs, ClassLoader clsldr)
Loads version information for a list of packages.- Parameters:
pckgs
- the packages for which to load version infoclsldr
- the classloader to load from, ornull
for the thread context classloader- Returns:
- the version information for all packages found,
never
null
-
loadVersionInfo
public static VersionInfo loadVersionInfo(String pckg, ClassLoader clsldr)
Loads version information for a package.- Parameters:
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, ornull
for the thread context classloader- Returns:
- the version information for the argument package, or
null
if not available
-
getUserAgent
public static String getUserAgent(String name, String pkg, Class<?> cls)
Sets the user agent to"<name>/<release> (Java/<java.version>)"
.For example:
"Apache-HttpClient/4.3 (Java/1.6.0_35)"
- Parameters:
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, ornull
for the thread context class loader- Since:
- 4.3
-
-