net.sf.magicproject.tools
Class JavaVersion

java.lang.Object
  extended by net.sf.magicproject.tools.JavaVersion
All Implemented Interfaces:
java.lang.Comparable<JavaVersion>

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

Immutable version class constructed from a Java version string (ir without for the current JREs version). The Java version takes the form:

major.middle.minor[_update][-identifier]

Object's of this class can be used to compare Java different versions. Note that for the purposes of comparison the identifier is considered only in so much as it is present or not - its actual value is unimportant. Therefore for two otherwise identical versions the presence of an identifier in one will make it a lower version than the other. This is because standard identifier values have not been identified by Sun.

Author:
Wayne Grant, Fabrice Daugan

Constructor Summary
JavaVersion()
          Construct a JavaVersion object for the current Java environment.
JavaVersion(java.lang.String sJavaVersion)
          Construct a JavaVersion object from the supplied string.
 
Method Summary
 int compareTo(JavaVersion object)
          Compare this JavaVersion object with another object.
 boolean equals(java.lang.Object object)
           
 int getMajor()
          Get Java version's major number.
 int getMiddle()
          Get Java version's middle number.
 int getMinor()
          Get Java version's minor number.
 int hashCode()
           
 java.lang.String toString()
          Get a string representation of the Java version.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaVersion

public JavaVersion()
Construct a JavaVersion object for the current Java environment.


JavaVersion

public JavaVersion(java.lang.String sJavaVersion)
Construct a JavaVersion object from the supplied string.

Parameters:
sJavaVersion - The Java version string
Method Detail

getMajor

public int getMajor()
Get Java version's major number.

Returns:
Minor number

getMiddle

public int getMiddle()
Get Java version's middle number.

Returns:
Minor number

getMinor

public int getMinor()
Get Java version's minor number.

Returns:
Minor number

compareTo

public int compareTo(JavaVersion object)
Compare this JavaVersion object with another object.

Specified by:
compareTo in interface java.lang.Comparable<JavaVersion>
Parameters:
object - Object to compare JavaVersion with
Returns:
0 if the equal, -1 if less, 1 if more than this supplied

equals

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

hashCode

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

toString

public java.lang.String toString()
Get a string representation of the Java version.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the Java version


Copyright © 2003-2007 Magic-Project. All Rights Reserved.