Top Description Fields Constructors Methods
org.apache.http.util

public Class VersionInfo

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, java.util.ArrayList, .List, .Map, .Properties

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

Modifier and TypeField and Description
private final String
infoClassloader

The classloader from which the version info was obtained.

private final String
infoModule

The module from the version info.

private final String
infoPackage

The package that contains the version information.

private final String
infoRelease

The release from the version info.

private final String
infoTimestamp

The timestamp from the version info.

public static final String
public static final String
public static final String
public static final String
UNAVAILABLE

A string constant for unavailable information.

public static final String
VERSION_PROPERTY_FILE

The filename of the version information files.

Constructor Summary

AccessConstructor and Description
protected
VersionInfo(final String
the package
pckg
,
final String
the module, or null
module
,
final String
the release, or null
release
,
final String
the build time, or null
time
,
final String
the class loader, or null
clsldr
)

Instantiates version information.

Method Summary

Modifier and TypeMethod and Description
protected static VersionInfo

Returns:

the version information
fromMap
(final String
the package for the version information
pckg
,
final Map<?, ?>
the map from string keys to string values, for example java.util.Properties
info
,
final ClassLoader
the classloader, or null
clsldr
)

Instantiates version information from properties.

public final String

Returns:

the classloader description, never null
getClassloader
()

Obtains the classloader used to read the version information.

public final String

Returns:

the module name, never null
getModule
()

Obtains the name of the versioned module or informal unit.

public final String

Returns:

the package name, never null
getPackage
()

Obtains the package name.

public final String

Returns:

the release version, never null
getRelease
()

Obtains the release of the versioned module or informal unit.

public final String

Returns:

the timestamp, never null
getTimestamp
()

Obtains the timestamp of the versioned module or informal unit.

public static String
getUserAgent(final String
the component name, like "Apache-HttpClient".
name
,
final String
the package for which to load version information, for example "org.apache.http". The package name should NOT end with a dot.
pkg
,
final Class<?>
the class' class loader to load from, or null for the thread context class loader
cls
)

Sets the user agent to "<name>/<release> (Java/<java.version>)".

public static VersionInfo[]

Returns:

the version information for all packages found, never null
loadVersionInfo
(final String[]
the packages for which to load version info
pckgs
,
final ClassLoader
the classloader to load from, or null for the thread context classloader
clsldr
)

Loads version information for a list of packages.

public static VersionInfo

Returns:

the version information for the argument package, or null if not available
loadVersionInfo
(final String
the package for which to load version information, for example "org.apache.http". The package name should NOT end with a dot.
pckg
,
final ClassLoader
the classloader to load from, or null for the thread context classloader
clsldr
)

Loads version information for a package.

public String

Returns:

a string holding this version information
toString
()

Overrides java.lang.Object.toString.

Provides the version information in human-readable format.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

infoClassloaderback to summary
private final String infoClassloader

The classloader from which the version info was obtained.

infoModuleback to summary
private final String infoModule

The module from the version info.

infoPackageback to summary
private final String infoPackage

The package that contains the version information.

infoReleaseback to summary
private final String infoRelease

The release from the version info.

infoTimestampback to summary
private final String infoTimestamp

The timestamp from the version info.

PROPERTY_MODULEback to summary
public static final String PROPERTY_MODULE
PROPERTY_RELEASEback to summary
public static final String PROPERTY_RELEASE
PROPERTY_TIMESTAMPback to summary
public static final String PROPERTY_TIMESTAMP
UNAVAILABLEback to summary
public static final String UNAVAILABLE

A string constant for unavailable information.

VERSION_PROPERTY_FILEback to summary
public static final String VERSION_PROPERTY_FILE

The filename of the version information files.

Constructor Detail

VersionInfoback to summary
protected VersionInfo(final String pckg, final String module, final String release, final String time, final String clsldr)

Instantiates version information.

Parameters
pckg:String

the package

module:String

the module, or null

release:String

the release, or null

time:String

the build time, or null

clsldr:String

the class loader, or null

Method Detail

fromMapback to summary
protected static VersionInfo fromMap(final String pckg, final Map<?, ?> info, final ClassLoader clsldr)

Instantiates version information from properties.

Parameters
pckg:String

the package for the version information

info:Map<?, ?>

the map from string keys to string values, for example java.util.Properties

clsldr:ClassLoader

the classloader, or null

Returns:VersionInfo

the version information

getClassloaderback to summary
public final String getClassloader()

Obtains the classloader used to read the version information. This is just the toString output of the classloader, since the version information should not keep a reference to the classloader itself. That could prevent garbage collection.

Returns:String

the classloader description, never null

getModuleback to summary
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:String

the module name, never null

getPackageback to summary
public final String getPackage()

Obtains the package name. The package name identifies the module or informal unit.

Returns:String

the package name, never null

getReleaseback to summary
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:String

the release version, never null

getTimestampback to summary
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:String

the timestamp, never null

getUserAgentback to summary
public static String getUserAgent(final String name, final String pkg, final 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:String

the component name, like "Apache-HttpClient".

pkg:String

the package for which to load version information, for example "org.apache.http". The package name should NOT end with a dot.

cls:Class<?>

the class' class loader to load from, or null for the thread context class loader

Since
4.3
loadVersionInfoback to summary
public static VersionInfo[] loadVersionInfo(final String[] pckgs, final ClassLoader clsldr)

Loads version information for a list of packages.

Parameters
pckgs:String[]

the packages for which to load version info

clsldr:ClassLoader

the classloader to load from, or null for the thread context classloader

Returns:VersionInfo[]

the version information for all packages found, never null

loadVersionInfoback to summary
public static VersionInfo loadVersionInfo(final String pckg, final ClassLoader clsldr)

Loads version information for a package.

Parameters
pckg:String

the package for which to load version information, for example "org.apache.http". The package name should NOT end with a dot.

clsldr:ClassLoader

the classloader to load from, or null for the thread context classloader

Returns:VersionInfo

the version information for the argument package, or null if not available

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Provides the version information in human-readable format.

Returns:String

a string holding this version information

Annotations
@Override