First this class attempts to read version information from key Attributes.Name.IMPLEMENTATION_VERSION
in the Java manifest by using the Java api.
Should this operation fail, it looks for a MANIFEST.MF in the file system in order to
read version information from the first file found.
In case this also fails, it looks for the project's Maven POM file to extract version information from the xml structure.
| Modifier and Type | Field and Description |
|---|---|
| private static final Map | CACHE
Cache of version information by class. |
| private static final System. | |
| private int | |
| private int | |
| private String |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static void | |
| public static VersionInfo | |
| pack-priv VersionInfo | Returns: This VersionInfo instance with the version details populated.The package of the class to find the version for. p)Finds the version information by checking the package, manifest, or Maven POM file. |
| public int | Returns: The major version number, or 0 if not found or unparsable.Returns the major version number. |
| public int | Returns: The minor version number, or 0 if not found or unparsable.Returns the minor version number. |
| public String | |
| pack-priv String | Returns: The version string, or null if not found.Reads the version information from a MANIFEST.MF file in the file system. |
| pack-priv String | Returns: The version string, or null if not found.Reads the version information from a pom.xml file in the file system. |
| public String | Returns: A formatted string with version, major, and minor numbers.Overrides java. Returns a string representation of the version info. |
| CACHE | back to summary |
|---|---|
| private static final Map<Class<?>, VersionInfo> CACHE Cache of version information by class. | |
| LOGGER | back to summary |
|---|---|
| private static final System. | |
| majorVersion | back to summary |
|---|---|
| private int majorVersion | |
| minorVersion | back to summary |
|---|---|
| private int minorVersion | |
| version | back to summary |
|---|---|
| private String version | |
| VersionInfo | back to summary |
|---|---|
| pack-priv VersionInfo() Default constructor. | |
| clearCache | back to summary |
|---|---|
| pack-priv static void clearCache() Clears the internal cache of version information. This is primarily for testing purposes. | |
| find | back to summary |
|---|---|
| public static VersionInfo find(Class<?> clazz) Finds and returns the version information for a given class. The method uses a cache to avoid redundant lookups.
| |
| findVersion | back to summary |
|---|---|
| pack-priv VersionInfo findVersion(Package p) Finds the version information by checking the package, manifest, or Maven POM file.
| |
| getMajorVersion | back to summary |
|---|---|
| public int getMajorVersion() Returns the major version number.
| |
| getMinorVersion | back to summary |
|---|---|
| public int getMinorVersion() Returns the minor version number.
| |
| getVersion | back to summary |
|---|---|
| public String getVersion() Returns the full version string.
| |
| readFromManifest | back to summary |
|---|---|
| pack-priv String readFromManifest() Reads the version information from a MANIFEST.MF file in the file system.
| |
| readFromMavenPom | back to summary |
|---|---|
| pack-priv String readFromMavenPom() Reads the version information from a pom.xml file in the file system.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of the version info. | |