Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

javax.ide.util
Class Version

java.lang.Object
  extended by javax.ide.util.Version
All Implemented Interfaces:
java.lang.Comparable<Version>

public final class Version
extends java.lang.Object
implements java.lang.Comparable<Version>

Represents the version number of an extension or component. A version number is an immutable ordered sequence of integer values.

Version numbers can be represented in two forms. When you construct a new Version object using a String representation of the version number, this String representation is stored and returned by the toString() method. This form of the version number will retain any redundant leading zeros in any of the integer values which make up the version number.

Conversely, in the canonical form, a version number does not retain leading zeros. The canonical form of new Version( "1.02.03" ) would be "1.2.3". You can retrieve the canonical form of a Version object using the toCanonicalString() method.


Constructor Summary
Version(java.lang.String versionLabel)
          Constructs a Version object from a String representation.
 
Method Summary
 int compareTo(Version other)
          Compare this version object with another version object.
 boolean equals(java.lang.Object other)
          Compare this version object with another version object for equality.
 int hashCode()
           
static boolean isValid(java.lang.String versionLabel)
          Determines whether the specified version label is valid.
 java.lang.String toCanonicalString()
          Get this version number as a canonicalized string.
 int[] toIntArray()
          Converts this Version to an int array.
 java.lang.String toString()
          Get this version number as a string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Version

public Version(java.lang.String versionLabel)
        throws java.lang.NumberFormatException
Constructs a Version object from a String representation.

Parameters:
versionLabel - a String representation of a version number. This must start with an integer and contain only integers and periods.
Throws:
java.lang.NumberFormatException - if the specified version label contains non-numeric characters other than periods.
Method Detail

isValid

public static boolean isValid(java.lang.String versionLabel)
Determines whether the specified version label is valid. A version number is valid if it consists only of numeric characters and periods.

Parameters:
versionLabel - a version label.
Returns:
true if the version label is valid, false otherwise.
Throws:
java.lang.NullPointerException - if versionLabel is null.
Since:
2.0

toIntArray

public int[] toIntArray()
Converts this Version to an int array.

Returns:
a newly allocated int array whose length is equal to the number of integer values in this version object and whose contents are the integer values represented by this version.

compareTo

public int compareTo(Version other)
Compare this version object with another version object. Comparison of two version numbers applies to the canonical form of the version number. For example, the result of evaluating the expression new Version( "1.05.07" ).compareTo( new Version( "1.5.0006" ) ) is a positive integer indicating that version 1.5.7 is greater than 1.5.6.

Specified by:
compareTo in interface java.lang.Comparable<Version>
Parameters:
other - another instance of Version.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

toString

public java.lang.String toString()
Get this version number as a string. The string returned is equal to the string provided in the constructor. For example, new Version( "1.05.06" ).toString(); would return "1.05.06".

Overrides:
toString in class java.lang.Object
Returns:
the string representation of this version.
See Also:
toCanonicalString()

toCanonicalString

public java.lang.String toCanonicalString()
Get this version number as a canonicalized string. Leading zeros will be removed from all numerical components of the version. For example, new Version( "1.05.06" ).toString(); would return "1.5.6".

Returns:
a canonical string representation of this version.
See Also:
toString()

equals

public boolean equals(java.lang.Object other)
Compare this version object with another version object for equality. Equality of two version numbers applies to the canonical form of the version number. For example, the result of evaluating the expression new Version( "1.05.06" ).equals( new Version( "1.5.0006" ) ) is true.

Overrides:
equals in class java.lang.Object
Parameters:
other - another instance of Version.
Returns:
true if this version is equal to the other version.

hashCode

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

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

Copyright © 1997, 2013, Oracle. All rights reserved.