com.foxsmart.ic.util
Class Version

java.lang.Object
  extended by com.foxsmart.ic.util.Version
All Implemented Interfaces:
java.lang.Comparable

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

The Version class represents any version of something (e.g. a Product). The version supports up to 4 sub-parts in the form of A.B.C.D and a string suffix. Each of the A.B.C.D parts must be an integer. For each part, the part before it must be present. The "A" part is required while the other parts are optional. The suffix is optional and may be present regardless of any of the parts before it.


Constructor Summary
Version(java.lang.Integer a, java.lang.Integer b, java.lang.Integer c, java.lang.Integer d, java.lang.String suffix)
          Constructs a version based on the individual pieces.
Version(java.lang.String version)
          Constructs a version object based on a string representation of one.
 
Method Summary
 int compareTo(java.lang.Object versionObject)
          Compares the passed in version with this version.
 boolean equals(java.lang.Object versionObject)
          Determines if 2 versions are equal.
 java.lang.Integer getA()
          Gets the "A" portion of the version.
 java.lang.Integer getB()
          Gets the "B" portion of the version.
 java.lang.Integer getC()
          Gets the "C" portion of the version.
 java.lang.Integer getD()
          Gets the "D" portion of the version.
 java.lang.String getSuffix()
          Gets the suffix portion of the version.
 java.lang.String toString()
          Returns the string representation of the version in the form of "A.B.C.D Suffix".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Version

public Version(java.lang.Integer a,
               java.lang.Integer b,
               java.lang.Integer c,
               java.lang.Integer d,
               java.lang.String suffix)
        throws java.lang.IllegalArgumentException
Constructs a version based on the individual pieces.

Parameters:
a - The A part of the version.
b - The B part of the version.
c - The C part of the version.
d - The D part of the version.
suffix - The suffix part of the version.
Throws:
java.lang.IllegalArgumentException - if the format is invalid.

Version

public Version(java.lang.String version)
        throws java.lang.IllegalArgumentException
Constructs a version object based on a string representation of one. (i.e. A.B.C.D Suffix).

Parameters:
version - The version in the form of "A.B.C.D Suffix" as a string.
Throws:
java.lang.IllegalArgumentException - if the format is invalid.
Method Detail

toString

public java.lang.String toString()
Returns the string representation of the version in the form of "A.B.C.D Suffix".

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object versionObject)
Determines if 2 versions are equal.

Overrides:
equals in class java.lang.Object
Parameters:
versionObject - The Version to compare.
Returns:
True if the 2 versions are equal or false if not.

compareTo

public int compareTo(java.lang.Object versionObject)
Compares the passed in version with this version.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
versionObject - the version to compare.
Returns:
1, 0, or -1 depending on the comparrison results.

getA

public java.lang.Integer getA()
Gets the "A" portion of the version.

Returns:
the "A" portion.

getB

public java.lang.Integer getB()
Gets the "B" portion of the version.

Returns:
the "B" portion.

getC

public java.lang.Integer getC()
Gets the "C" portion of the version.

Returns:
the "C" portion.

getD

public java.lang.Integer getD()
Gets the "D" portion of the version.

Returns:
the "D" portion.

getSuffix

public java.lang.String getSuffix()
Gets the suffix portion of the version.

Returns:
the suffix.


Copyright © 2005-2008 Fox Smart, Inc. All Rights Reserved.