com.isti.util
Class IstiVersion

java.lang.Object
  extended by com.isti.util.IstiVersion
All Implemented Interfaces:
java.lang.Comparable

public class IstiVersion
extends java.lang.Object
implements java.lang.Comparable

Class IstiVersion describes a particular version of something: a product, API, etc.


Field Summary
static java.lang.String BETA_STRING
          Beta string.
static java.lang.String DIVIDER
          Divider string for version numbers.
 
Constructor Summary
IstiVersion(int[] args)
          Creates a version that isn't a beta version.
IstiVersion(int[] args, boolean beta)
          Creates a version.
IstiVersion(int major, int minor)
          Creates a version that isn't a beta version.
IstiVersion(int major, int minor, int patch)
          Creates a version that isn't a beta version.
IstiVersion(int major, int minor, int patch, int build)
          Creates a version that isn't a beta version.
IstiVersion(int major, int minor, int patch, int build, boolean beta)
          Creates a version.
IstiVersion(java.lang.String complete)
          Creates a version.
IstiVersion(java.lang.String[] args)
          Creates a version that isn't a beta version.
IstiVersion(java.lang.String[] args, boolean beta)
          Creates a version.
IstiVersion(java.lang.String major, java.lang.String minor)
          Creates a version that isn't a beta version.
IstiVersion(java.lang.String major, java.lang.String minor, java.lang.String patch)
          Creates a version that isn't a beta version.
IstiVersion(java.lang.String major, java.lang.String minor, java.lang.String patch, java.lang.String build)
          Creates a version that isn't a beta version.
IstiVersion(java.lang.String major, java.lang.String minor, java.lang.String patch, java.lang.String build, boolean beta)
          Creates a version.
 
Method Summary
 int compareTo(IstiVersion o)
          Compares this IstiVersion with the specified IstiVersion.
 int compareTo(java.lang.Object o)
          Compares this IstiVersion with the specified IstiVersion.
protected  java.lang.String createVersionString()
          Creates the version string.
 boolean equals(IstiVersion o)
          Compares this IstiVersion to the specified object.
 boolean equals(java.lang.Object o)
          Compares this IstiVersion to the specified object.
protected static int[] getArgs(java.lang.String complete)
          Gets the arguments specified by the complete version string.
protected static int[] getArgs(java.lang.String[] args)
          Gets the arguments specified by argument strings.
 int getBuild()
          Gets the build.
 int getMinor()
          Gets the minor version.
 int getPatch()
          Gets the patch version.
 boolean isBeta()
          Determines if this is a beta version.
protected static boolean isBeta(java.lang.String complete)
          Determines if the complete version string contains beta.
protected static int parseInt(java.lang.String s)
          Parses the string argument as a signed decimal integer.
 java.lang.String toString()
          Returns a string representation of this version.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BETA_STRING

public static final java.lang.String BETA_STRING
Beta string.

See Also:
Constant Field Values

DIVIDER

public static final java.lang.String DIVIDER
Divider string for version numbers.

See Also:
Constant Field Values
Constructor Detail

IstiVersion

public IstiVersion(java.lang.String complete)
Creates a version. The string is searched for a valid version string (such as "1.49.01") starting at the end of the string. Beta versions should contain "beta" (such as "1.47Beta"). Any other non-numeric characters leading or trailing a version number are ignored.

Parameters:
complete - the complete version string.

IstiVersion

public IstiVersion(int major,
                   int minor)
Creates a version that isn't a beta version.

Parameters:
major - the major version.
minor - the minor version.

IstiVersion

public IstiVersion(java.lang.String major,
                   java.lang.String minor)
Creates a version that isn't a beta version.

Parameters:
major - the major version.
minor - the minor version.

IstiVersion

public IstiVersion(int major,
                   int minor,
                   int patch)
Creates a version that isn't a beta version.

Parameters:
major - the major version.
minor - the minor version.
patch - the patch version.

IstiVersion

public IstiVersion(java.lang.String major,
                   java.lang.String minor,
                   java.lang.String patch)
Creates a version that isn't a beta version.

Parameters:
major - the major version.
minor - the minor version.
patch - the patch version.

IstiVersion

public IstiVersion(int major,
                   int minor,
                   int patch,
                   int build)
Creates a version that isn't a beta version.

Parameters:
major - the major version.
minor - the minor version.
patch - the patch version.
build - the build version.

IstiVersion

public IstiVersion(int major,
                   int minor,
                   int patch,
                   int build,
                   boolean beta)
Creates a version.

Parameters:
major - the major version.
minor - the minor version.
patch - the patch version.
build - the build version.
beta - true if beta, false otherwise.

IstiVersion

public IstiVersion(java.lang.String major,
                   java.lang.String minor,
                   java.lang.String patch,
                   java.lang.String build)
Creates a version that isn't a beta version.

Parameters:
major - the major version.
minor - the minor version.
patch - the patch version.
build - the build version.

IstiVersion

public IstiVersion(java.lang.String major,
                   java.lang.String minor,
                   java.lang.String patch,
                   java.lang.String build,
                   boolean beta)
Creates a version.

Parameters:
major - the major version.
minor - the minor version.
patch - the patch version.
build - the build version.
beta - true if beta, false otherwise.

IstiVersion

public IstiVersion(int[] args)
Creates a version that isn't a beta version.

Parameters:
args - an array of versions.

IstiVersion

public IstiVersion(int[] args,
                   boolean beta)
Creates a version.

Parameters:
args - an array of versions.
beta - true if beta, false otherwise.

IstiVersion

public IstiVersion(java.lang.String[] args)
Creates a version that isn't a beta version.

Parameters:
args - an array of versions.

IstiVersion

public IstiVersion(java.lang.String[] args,
                   boolean beta)
Creates a version.

Parameters:
args - an array of versions.
beta - true if beta, false otherwise.
Method Detail

createVersionString

protected java.lang.String createVersionString()
Creates the version string.

Returns:
the version string.

getArgs

protected static int[] getArgs(java.lang.String complete)
Gets the arguments specified by the complete version string.

Parameters:
complete - the complete version string.
Returns:
array of arguments.

getArgs

protected static int[] getArgs(java.lang.String[] args)
Gets the arguments specified by argument strings.

Parameters:
args - the argument strings.
Returns:
array of arguments.

isBeta

protected static boolean isBeta(java.lang.String complete)
Determines if the complete version string contains beta.

Parameters:
complete - the complete version string.
Returns:
true if beta.

parseInt

protected static int parseInt(java.lang.String s)
Parses the string argument as a signed decimal integer.

Parameters:
s - a string.
Returns:
the integer represented by the argument in decimal.

compareTo

public int compareTo(java.lang.Object o)
Compares this IstiVersion with the specified IstiVersion. If the specified Object is a IstiVersion, this function behaves like compareTo(IstiVersion). Otherwise, it throws a ClassCastException (as Versions are comparable only to other Versions).

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the Object to be compared.
Returns:
the value 0 if the versions are equal; a value less than 0 if this version is less than the specified version; and a value greater than 0 if this version is greater than the specified version.
Throws:
ClassCastException - if the argument is not a IstiVersion.

compareTo

public int compareTo(IstiVersion o)
Compares this IstiVersion with the specified IstiVersion.

Parameters:
o - the Object to be compared.
Returns:
the value 0 if the versions are equal; a value less than 0 if this version is less than the specified version; and a value greater than 0 if this version is greater than the specified version.

equals

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

Overrides:
equals in class java.lang.Object
Parameters:
o - the Object to be compared.
Returns:
true if the IstiVersion are equal; false otherwise.

equals

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

Parameters:
o - the Object to be compared.
Returns:
true if the IstiVersion are equal; false otherwise.

getBuild

public int getBuild()
Gets the build.

Returns:
the buld.

getMinor

public int getMinor()
Gets the minor version.

Returns:
the minor version.

getPatch

public int getPatch()
Gets the patch version.

Returns:
the patch version.

isBeta

public boolean isBeta()
Determines if this is a beta version.

Returns:
true if beta, false otherwise.

toString

public java.lang.String toString()
Returns a string representation of this version.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this version.