|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
oracle.ide.util.VersionNumber
public final class VersionNumber
This class encapsulates the notion of a version number or version string, which can be defined as a string of characters, usually digits, separated by dots ('.'). An example is 8.1.7.0.0.
VersionNumber has methods that can compare one instance of VersionNumber to another. During comparison, VersionNumber attempts to interpret the parts of the version string as numbers; if two corresponding parts cannot be compared as numbers, they are compared lexicographically.
Whether or not two VersionNumber instances have the same number of parts, comparisons occur in a left-to-right manner, part by part. As soon as a difference is detected, then it can be determined which version number is earlier or later. Examples:
8.1.7 comes after 8.1.6.9.0 comes after 8.9.9.9.9.9.9.8.0.5 equals 8.0.5.8.0.6 comes before 8.0.6.0.2.0a comes before 2.0b.abc.xyz.qrs comes before qrs.xyz.This class implements Comparable so that collections of VersionNumber can be easily sorted.
This class implements StringConversion so that instances of VersionNumber can be persisted and reloaded by Objecg2Dom.
| Constructor Summary | |
|---|---|
VersionNumber(java.lang.String versionString)This creates an instance of VersionNumber based on the dot-separated version string that is passed in. |
|
| Method Summary | |
|---|---|
int |
compareTo(java.lang.Object o) |
int |
countParts()Returns the number of dot-separated fields contained in the version. |
boolean |
equals(java.lang.Object o)Compares this instance of VersionNumber with the specified VersionNumber and returns true if the version represented are identical. |
java.lang.String |
getPart(int offset)Returns the part of the version string requested or null if the offset is out of bounds. |
int |
hashCode() |
boolean |
isAfter(VersionNumber version)Returns true if this VersionNumber is after the specified VersionNumber. |
boolean |
isAfter(VersionNumber version, boolean orEquals)This is a convenience method that simply calls !isBefore(version, !orEquals). |
boolean |
isBefore(VersionNumber version)Returns true if this VersionNumber is before the specified VersionNumber. |
boolean |
isBefore(VersionNumber version, boolean orEquals)Compares the parts of the this VersionNumber with the parts of the specified VersionNumber to determine whether this VersionNumber represents a version that comes before the specified version. |
java.lang.String |
toString()Returns the VersionNumber in dot-separated notation as a String. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public VersionNumber(java.lang.String versionString)
VersionNumber based on the dot-separated version string that is passed in.| Method Detail |
|---|
public int countParts()
2. If the version string is "3", then this method returns 1.public java.lang.String getPart(int offset)
null if the offset is out of bounds.public final boolean isAfter(VersionNumber version)
true if this VersionNumber is after the specified VersionNumber. Returns false if this VersionNumber is equal to or before the specified VersionNumber.
public final boolean isAfter(VersionNumber version,
boolean orEquals)
!isBefore(version, !orEquals).public final boolean isBefore(VersionNumber version)
true if this VersionNumber is before the specified VersionNumber. Returns false if this VersionNumber is equal to or after the specified VersionNumber.
public boolean isBefore(VersionNumber version,
boolean orEquals)
VersionNumber with the parts of the specified VersionNumber to determine whether this VersionNumber represents a version that comes before the specified version. Parts are compared one at a time, and the result is returned as soon as it is determined. For each comparison, an attempt is first made to convert both version parts to an int using Integer.parseInt(). If this succeeds, then the version parts are compared numerically. If the conversion to int fails because of a NumberFormatException, the version parts are compared lexicographically using String.compareTo(...). These steps are followed for each version part, so it may be the case that some parts are compared numerically and others lexicographically.
If one VersionNumber instance has extra zeros at the end, while the one it is being compared to does not have extra zeros, then the VersionNumber with the extra zeros is considered to be later than the VersionNumber without the extra zeros.
public int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparablepublic boolean equals(java.lang.Object o)
VersionNumber with the specified VersionNumber and returns true if the version represented are identical.equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
VersionNumber in dot-separated notation as a String.toString in class java.lang.Object
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||