be.SIRAPRISE.client
Class Version

java.lang.Object
  extended by be.SIRAPRISE.client.Version
All Implemented Interfaces:
java.lang.Comparable<Version>

public class Version
extends java.lang.Object
implements java.lang.Comparable<Version>

Class to denote SIRA_PRISE versions and/or message type versions.

Author:
Erwin Smout

Field Summary
static Version ONE_FOUR
           
static Version ONE_ONE
           
static Version ONE_THREE
           
static Version ONE_TWO
           
static Version ONE_ZERO
          in order to not have to create identical object within each message type
 
Constructor Summary
Version(int fullVersion)
          Creates a Version object from a full numeric version indicator
Version(short majorVersion, short minorVersion)
          Creates a Version object from the given major and minor version numbers.
 
Method Summary
 int compareTo(Version o)
           
 boolean equals(java.lang.Object obj)
           
 int getFullVersion()
          Gets the full numeric indicator of the version value.
 Version getLowest(Version otherVersion)
          Compares two SIRA_PRISE Version indicators and returns the lowest (which is the one whose spec can be expected to define the functionality that the two versions have in common).
 short getMajorVersion()
          Gets The major version
 short getMinorVersion()
          Gets The minor version
 int hashCode()
           
 boolean isAtLeast(short majorVersion2, short minorVersion2)
          Checks whether this version indicates a version that is at least (i.e the same, or later than) the one indicated by the given arguments
 boolean isAtLeast(Version otherVersion)
          Checks whether this version indicates a version that is at least (i.e the same, or later than) the one indicated by the given arguments
 boolean isBefore(short majorVersion2, short minorVersion2)
          Checks whether this version indicates an earlier version than the one indicated by the given arguments
 boolean isBefore(Version otherVersion)
          Checks if this Version object designates an earlier version than the other one
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ONE_FOUR

public static final Version ONE_FOUR

ONE_ONE

public static final Version ONE_ONE

ONE_THREE

public static final Version ONE_THREE

ONE_TWO

public static final Version ONE_TWO

ONE_ZERO

public static final Version ONE_ZERO
in order to not have to create identical object within each message type

Constructor Detail

Version

public Version(int fullVersion)
Creates a Version object from a full numeric version indicator

Parameters:
fullVersion - A full numeric version indicator holding the major version number in its first two bytes and the minor version in its last two bytes.

Version

public Version(short majorVersion,
               short minorVersion)
Creates a Version object from the given major and minor version numbers.

Parameters:
majorVersion - The major version
minorVersion -
Method Detail

compareTo

public final int compareTo(Version o)
Specified by:
compareTo in interface java.lang.Comparable<Version>

equals

public final boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getFullVersion

public final int getFullVersion()
Gets the full numeric indicator of the version value.

Returns:
the full numeric indicator of the version value.

getLowest

public final Version getLowest(Version otherVersion)
Compares two SIRA_PRISE Version indicators and returns the lowest (which is the one whose spec can be expected to define the functionality that the two versions have in common).

Parameters:
otherVersion - the other SIRA_PRISE Version indicator
Returns:
the Version object indicating the lowest (oldest) version number

getMajorVersion

public final short getMajorVersion()
Gets The major version

Returns:
The major version

getMinorVersion

public final short getMinorVersion()
Gets The minor version

Returns:
The minor version

hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object

isAtLeast

public final boolean isAtLeast(short majorVersion2,
                               short minorVersion2)
Checks whether this version indicates a version that is at least (i.e the same, or later than) the one indicated by the given arguments

Parameters:
majorVersion2 - The major version number to which this version is to be compared
minorVersion2 - The minor version number to which this version is to be compared
Returns:
true if this version indicates a version that is at least (i.e the same, or later than) the one indicated by the given arguments

isAtLeast

public final boolean isAtLeast(Version otherVersion)
Checks whether this version indicates a version that is at least (i.e the same, or later than) the one indicated by the given arguments

Parameters:
otherVersion - A Version object designating another SIRA_PRISE version this one is to be compared to.
Returns:
true if this version indicates a version that is at least (i.e the same, or later than) the one indicated by the given arguments

isBefore

public final boolean isBefore(short majorVersion2,
                              short minorVersion2)
Checks whether this version indicates an earlier version than the one indicated by the given arguments

Parameters:
majorVersion2 - The major version number to which this version is to be compared
minorVersion2 - The minor version number to which this version is to be compared
Returns:
true if this version indicates an earlier version than the one indicated by the given arguments

isBefore

public final boolean isBefore(Version otherVersion)
Checks if this Version object designates an earlier version than the other one

Parameters:
otherVersion - A Version object designating another SIRA_PRISE version this one is to be compared to for "earlierness".
Returns:
true if this version designates an earlier version than the other Version

toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object