net.sourceforge.simplegamenet.specs.to
Class Version

java.lang.Object
  extended bynet.sourceforge.simplegamenet.specs.to.Version
All Implemented Interfaces:
Comparable, Serializable

public class Version
extends Object
implements Comparable, Serializable

A version to check if a client and server are using compatible SimpleGameNet framework and game module packages. A version consists out of one or several levels of int values, each considered more important then the next.

Version:
1.0, 2003-06-18
Author:
Geoffrey De Smet
See Also:
GameFactory, Serialized Form

Constructor Summary
Version(int level0Value)
          Initializes a newly created Version object with 1 level.
Version(int[] levelValues)
          Initializes a newly created Version object with a variable amount of levels.
Version(int level0Value, int level1Value)
          Initializes a newly created Version object with 2 levels.
Version(int level0Value, int level1Value, int level2Value)
          Initializes a newly created Version object with 3 levels.
 
Method Summary
 int compareTo(Object object)
          Compares two versions by comparing their level values, beginning from the highest level.
 boolean equals(Object object)
          Compares this version to the specified object.
 String toString()
          Returns the string representation of this Version.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Version

public Version(int level0Value)
Initializes a newly created Version object with 1 level. It is recommended not to use this constructor, but to use at least 2 levels to define a version instead.

Parameters:
level0Value - the value of the only level

Version

public Version(int level0Value,
               int level1Value)
Initializes a newly created Version object with 2 levels.

Parameters:
level0Value - the value of the first and most important level
level1Value - the value of the second and least important level

Version

public Version(int level0Value,
               int level1Value,
               int level2Value)
Initializes a newly created Version object with 3 levels.

Parameters:
level0Value - the value of the first and most important level
level1Value - the value of the second level
level2Value - the value of the third level

Version

public Version(int[] levelValues)
Initializes a newly created Version object with a variable amount of levels.

Parameters:
levelValues - the values of each level, starting with the most important level first
Method Detail

equals

public boolean equals(Object object)
Compares this version to the specified object. The result is true if and only if the argument is not null and is a version that represents the same sequence of values as this version.

Versions with a different amount of levels are compared to the same amount of levels by padding 0 values to the version with less levels. For example: 1.3, 1.3.0 and 1.3.0.0 are considered to be equal, while 1.4 and 1.4.1 are considered to be unequal.

Parameters:
object - the object to compare this version against
Returns:
true if the versions are equal

compareTo

public int compareTo(Object object)
Compares two versions by comparing their level values, beginning from the highest level. For example: 1.8.12 will be considered older then 2.0.0.

Versions with a different amount of levels are compared to the same amount of levels by padding 0 values to the version with less levels. For example: 1.3 compared to 1.3.0 will be considered equal, while 1.4 compared to 1.4.1 will be considered older.

Specified by:
compareTo in interface Comparable
Parameters:
object - the object to compare this version against
Returns:
the value 0 if the argument version is equal to this version, a value less than 0 if this version is older than the argument and a value greater than 0 if this version is newer than the argument.

toString

public String toString()
Returns the string representation of this Version. The string is composed by appending each level and padding a "." between 2 levels.

Returns:
the string representation of this Version


Copyright © 2003-2004 The 3 Belgians. All Rights Reserved.