Betty v1.1.0

christophedelory.xml
Class Version

java.lang.Object
  extended by christophedelory.xml.Version
All Implemented Interfaces:
Serializable, Cloneable

public class Version
extends Object
implements Cloneable, Serializable

A generic version information, composed of a version number, a revision number and a step number.

Version:
$Revision$
Author:
Christophe Delory
See Also:
Serialized Form

Field Summary
static Version CURRENT
          The current version of this project.
 
Constructor Summary
Version(int version, int revision, int step)
          Builds a new Version instance which should keep a specific version, revision and step numbers.
 
Method Summary
 int compareTo(Object o)
          Compares this version with the specified object for order.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 int getRevision()
          Returns the revision number kept by this instance.
 int getStep()
          Returns the step number kept by this instance.
 int getVersion()
          Returns the version number kept by this instance.
 int hashCode()
          Returns a hash code value for this object.
 String toString()
          Returns a string representation of this version information.
static Version valueOf(String name)
          Builds a version information from the specified string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CURRENT

public static Version CURRENT
The current version of this project. Defaults to "0.0.0".

Constructor Detail

Version

public Version(int version,
               int revision,
               int step)
Builds a new Version instance which should keep a specific version, revision and step numbers.

Parameters:
version - the version number.
revision - the revision number.
step - the step number.
Throws:
IndexOutOfBoundsException - if one of the numbers is strictly negative.
Method Detail

valueOf

public static Version valueOf(String name)
Builds a version information from the specified string.

Parameters:
name - the version string.
Throws:
NullPointerException - if the version string is null.
IllegalArgumentException - if the version string is malformed.
IndexOutOfBoundsException - if one of the numbers is strictly negative.
NumberFormatException - if the version string contains a non-parsable integer.
See Also:
toString()

getVersion

public int getVersion()
Returns the version number kept by this instance.

Returns:
a version number.

getRevision

public int getRevision()
Returns the revision number kept by this instance.

Returns:
a revision number.

getStep

public int getStep()
Returns the step number kept by this instance.

Returns:
a step number.

compareTo

public int compareTo(Object o)
Compares this version with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
o - the object to be compared. A Version instance is expected.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if the specified object's type prevents it from being compared to this object.
NullPointerException - if the specified object is null.

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one. Two version information are the same if their version and revision and step numbers are the same.

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare. A Version instance is expected.
Returns:
true if this object is the same as the obj argument; false otherwise.

hashCode

public int hashCode()
Returns a hash code value for this object. This method is supported for the benefit of hashtables such as those provided by Hashtable.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.

toString

public String toString()
Returns a string representation of this version information. It takes the following form: "<version>.<revision>.<step>".

Overrides:
toString in class Object
Returns:
a string representing this version information.

© 2008-2009 Christophe Delory

Copyright © 2008-2009 Christophe Delory. All Rights Reserved.