|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.schmant.support.JdkVersion
public final class JdkVersion
An object of this type represents the version of a JDK.
Instances of this class are immutable. An instance may be created by using
the constructor or (preferably) by using the static
parseVersion(String)
method.
JdkUtil
has methods for determining the version of a Java
installation.
JdkUtil
Field Summary | |
---|---|
static int |
SUPER_VERSION
The super version number (1). |
static JdkVersion |
VERSION_1_4
JDK version 1.4.0.0. |
static JdkVersion |
VERSION_1_5
JDK version 1.5.0.0. |
static JdkVersion |
VERSION_1_6
JDK version 1.6.0.0. |
static JdkVersion |
VERSION_1_7
JDK version 1.7.0.0. |
Constructor Summary | |
---|---|
JdkVersion(int sup,
int major,
int minor,
int update)
Create a Java version object. |
|
JdkVersion(String s)
Parse the Java version string into a version object. |
Method Summary | |
---|---|
boolean |
equals(Object o)
|
int |
getMajor()
Get the major version number, i.e. |
int |
getMinor()
Get the minor version number, i.e. |
int |
getSuper()
Get the super version number, i.e. |
int |
getUpdate()
Get the update version number, i.e. |
int |
hashCode()
|
boolean |
isNewerThan(JdkVersion v)
Is this JDK version newer than the supplied version? |
boolean |
isOlderThan(JdkVersion v)
Is this JDK version older than the supplied version? |
boolean |
isSameMajorAndMinorVersion(JdkVersion v)
Does this JDK version object have the same major and minor version numbers as the supplied object? For instance, JDK 1.4.1_05 has the same major and minor version as JDK 1.4.1_04, but not the same minor version as JDK 1.4.2. |
boolean |
isSameMajorVersion(JdkVersion v)
Does this JDK version object have the same major version as the supplied object? For instance, JDK 1.4.1 has the same major version as JDK 1.4.2, but not the same major version as JDK 1.5. |
boolean |
isSameOrNewerThan(JdkVersion v)
Is this JDK version the same or newer than the supplied version? |
boolean |
isSameOrOlderThan(JdkVersion v)
Is this JDK version the same or older than the supplied version? |
static JdkVersion |
parseVersion(String s)
Parse the version string into a JDK version object. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final JdkVersion VERSION_1_7
public static final JdkVersion VERSION_1_6
public static final JdkVersion VERSION_1_5
public static final JdkVersion VERSION_1_4
public static final int SUPER_VERSION
Constructor Detail |
---|
public JdkVersion(String s) throws IllegalArgumentException
java -version
returns, e.g. 1.5.0_14
for JDK 1.5.0_14 or 1.6.0_02
for
JDK 1.6.0_02.
Partial version strings can be used to. For instance, "1"
means
JDK 1.0.0_0 and "1.6"
means JDK 1.6.0_0.
Use the parseVersion(String)
instead of calling this constructor
directly.
s
- The Java version string.
IllegalArgumentException
- If the version string cannot be parsed.parseVersion(String)
public JdkVersion(int sup, int major, int minor, int update) throws IllegalArgumentException
sup
- The super version number. Must be 1
.major
- The major version number, for instance 6
. Must be
zero or greater.minor
- The minor version number, for instance 0
. Must be
zero or greater.update
- The update version number, for instance 22
. Must
be zero or greater.
IllegalArgumentException
- If any version number has an invalid
value.Method Detail |
---|
public static JdkVersion parseVersion(String s) throws IllegalArgumentException
s
- The string to parse.
IllegalArgumentException
- If the version string is invalid.JdkVersion(String)
public int getSuper()
1
.
1
.public int getMajor()
6
for JDK 1.6.
public int getMinor()
2
for JDK 1.4.2 or 0
for JDK 1.6.
public int getUpdate()
14
for JDK 1.5.0_14.
public boolean isNewerThan(JdkVersion v)
v
- The JDK version to test against.
true
if this JDK version is newer than the supplied
version.isSameOrNewerThan(JdkVersion)
,
isOlderThan(JdkVersion)
public boolean isSameOrNewerThan(JdkVersion v)
v
- The JDK version to test against.
true
if this JDK version is the same or newer than the
supplied version.isNewerThan(JdkVersion)
,
isSameOrOlderThan(JdkVersion)
public boolean isOlderThan(JdkVersion v)
v
- The JDK version to test against.
true
if this JDK version is older than the supplied
version.isSameOrOlderThan(JdkVersion)
,
isNewerThan(JdkVersion)
public boolean isSameOrOlderThan(JdkVersion v)
v
- The JDK version to test against.
true
if this JDK version is the same or older than the
supplied version.isOlderThan(JdkVersion)
,
isSameOrNewerThan(JdkVersion)
public boolean isSameMajorVersion(JdkVersion v)
v
- The other JDK version object.
true
if the supplied JDK version object has the same
major version as this object.isSameMajorAndMinorVersion(JdkVersion)
public boolean isSameMajorAndMinorVersion(JdkVersion v)
v
- The other JDK version object.
true
if the supplied JDK version object has the same
major and minor version numbers as this object.isSameMajorVersion(JdkVersion)
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |