Package org.ptolemy.commons
Class ThreeDigitVersionSpecification
- java.lang.Object
-
- org.ptolemy.commons.VersionSpecification
-
- org.ptolemy.commons.ThreeDigitVersionSpecification
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<VersionSpecification>
public class ThreeDigitVersionSpecification extends VersionSpecification implements java.lang.Comparable<VersionSpecification>
A simple implementation of a version specification, based on a merge of OSGi-conventions and Ptolemy (which in turn seems to be based on JNLP).Concretely, this means:
- Reuse concept of numeric (int) major.minor.micro version number with optional trailing string-based qua lifier
- Don't care about the concrete concatenated format, possible delimiters etc. (i.e. do not enforce the usage of "."-separated version formatting)
- Allow an arbitrary count of qualifiers
- Compare qualifiers using plain text-compare
- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- ErwinDL
- See Also:
- Serialized Form
- Pt.AcceptedRating:
- Yellow (ErwinDL)
- Pt.ProposedRating:
- Yellow (ErwinDL)
-
-
Field Summary
-
Fields inherited from class org.ptolemy.commons.VersionSpecification
_versionString
-
-
Constructor Summary
Constructors Constructor Description ThreeDigitVersionSpecification(int major, int minor, int micro, java.lang.String... qualifiers)
Construct a three digit version specification.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(VersionSpecification otherVersionSpecification)
Compare this specification to the argument.boolean
equals(java.lang.Object object)
Return true of the argument is equal to this object.int
getMajor()
Return the major (leading) verson digit.int
getMicro()
Return the micro (third) verson digit.int
getMinor()
Return the minor (middle) verson digit.java.lang.String[]
getQualifiers()
Return the optional array of version qualifiers.int
hashCode()
Return the hash code of this object.ThreeDigitVersionSpecification
increaseMajor()
Return a new version spec with increased major digit.ThreeDigitVersionSpecification
increaseMicro()
Return a new version spec with increased micro digit.ThreeDigitVersionSpecification
increaseMinor()
Return a new version spec with increased minor digit.java.lang.String
toString()
Produce a string representation that is itself valid again to be parsed as a VersionSpecification.-
Methods inherited from class org.ptolemy.commons.VersionSpecification
parse
-
-
-
-
Constructor Detail
-
ThreeDigitVersionSpecification
public ThreeDigitVersionSpecification(int major, int minor, int micro, java.lang.String... qualifiers)
Construct a three digit version specification.- Parameters:
major
- The major version number.minor
- The minor version number.micro
- The micro version number.qualifiers
- An optional array of arbitrary version qualifiers.
-
-
Method Detail
-
compareTo
public int compareTo(VersionSpecification otherVersionSpecification)
Compare this specification to the argument.- Specified by:
compareTo
in interfacejava.lang.Comparable<VersionSpecification>
- Parameters:
otherVersionSpecification
- The version specification to which to compare.- Returns:
- 0 if they have the same major, minor and micro versions. Return 1 if the the argument is null or if the qualifiers of the other are greater this one.. Return -1 if this version has no qualifiers and the other one does or if the qualifiers of the other are less than this one.
-
equals
public boolean equals(java.lang.Object object)
Return true of the argument is equal to this object.- Overrides:
equals
in classjava.lang.Object
- Parameters:
object
- The other object to which to compare.- Returns:
- true if the argument is equal to this object.
-
getMajor
public int getMajor()
Return the major (leading) verson digit.- Returns:
- the major (leading) version digit
-
getMinor
public int getMinor()
Return the minor (middle) verson digit.- Returns:
- the minor (middle) version digit
-
getMicro
public int getMicro()
Return the micro (third) verson digit.- Returns:
- the micro (third) version digit
-
getQualifiers
public java.lang.String[] getQualifiers()
Return the optional array of version qualifiers. When no qualifiers are present, this returns an empty array.- Returns:
- the optional array of version qualifiers.
-
hashCode
public int hashCode()
Return the hash code of this object.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The hash code.
-
increaseMicro
public ThreeDigitVersionSpecification increaseMicro()
Return a new version spec with increased micro digit. This method does not change the current version spec instance.- Returns:
- a new version spec with increased micro digit.
-
increaseMinor
public ThreeDigitVersionSpecification increaseMinor()
Return a new version spec with increased minor digit. This method does not change the current version spec instance.- Returns:
- a new version spec with increased minor digit.
-
increaseMajor
public ThreeDigitVersionSpecification increaseMajor()
Return a new version spec with increased major digit. This method does not change the current version spec instance.- Returns:
- a new version spec with increased major digit.
-
toString
public java.lang.String toString()
Produce a string representation that is itself valid again to be parsed as a VersionSpecification.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The string representation.
-
-