gov.llnl.babel.symbols

Class Version


public class Version
extends java.lang.Object

Class Version represents a symbol version of the general form "V1.V2...Vn" where Vi is a non-negative integer. Trailing zeros in the version number are not significant. That is, "1.2" is the same as "1.2.0" and "1.2.0.0.0".

Constructor Summary

Version()
Create a new Version class that will be constructed through member function appendVersionNumber.
Version(String version)
Create a new Version class by parsing a version string of the form "V1.V2...Vn" where each Vi is a non-negative integer.

Method Summary

void
appendVersionNumber(int v)
Add another version number to the existing version description.
int
getVersionLength()
Return the number of sub-parts in the version description.
int
getVersionNumberAt(int i)
Return the version number at a particular location of the version string using zero-based indexing.
String
getVersionString()
Return the current version description as a version string.
int
hashCode()
Return a hash code for a version.
boolean
isGreaterThan(Version other)
Return whether this version is greater than the version in the argument.
boolean
isSame(Version other)
Return whether two version objects represent the same version number.
boolean
isUnspecified()

Constructor Details

Version

public Version()
Create a new Version class that will be constructed through member function appendVersionNumber. An empty version is considered to be version "0".

Version

public Version(String version)
            throws NumberFormatException
Create a new Version class by parsing a version string of the form "V1.V2...Vn" where each Vi is a non-negative integer. If the version is not of this form, then the constructor throws a NumberFormatException.

Method Details

appendVersionNumber

public void appendVersionNumber(int v)
Add another version number to the existing version description. If current version is "V1.V2...Vn" and this number is Vm, then the new version description will be "V1.V2...Vn.Vm". If the version is a non-negative integer, then a NumberFormatException is thrown.

getVersionLength

public int getVersionLength()
Return the number of sub-parts in the version description. For a version string "V1.V2...Vn", this routine returns the value of n.

getVersionNumberAt

public int getVersionNumberAt(int i)
Return the version number at a particular location of the version string using zero-based indexing. If the requested index is less than zero or is equal to or greater than the version length, then zero is returned.

getVersionString

public String getVersionString()
Return the current version description as a version string. If no version has been set, then the returned version is "0". Otherwise, the version is of the form "V1.V2...Vn".

hashCode

public int hashCode()
Return a hash code for a version.

isGreaterThan

public boolean isGreaterThan(Version other)
Return whether this version is greater than the version in the argument. Version "W1.W2...Wn" is considered greater than version "V1.V2...Vn" if for some i, Wj equals Vj for all j less than i and Wi is greater than Vi. If the two versions have different lengths, then the shorter version is padded with zeros.

isSame

public boolean isSame(Version other)
Return whether two version objects represent the same version number. Note that version "1.2.0" is considered the same as "1.2" since trailing zeros are ignored.

isUnspecified

public boolean isUnspecified()