com.ptc.windchill.instassm
Class ReleaseId

java.lang.Object
  extended by com.ptc.windchill.instassm.ReleaseId
All Implemented Interfaces:
Comparable

public class ReleaseId
extends Object
implements Comparable

A ReleaseId is an assembly name plus set of five numbers that looks like: assmbly-id.major.minor.servicePack.dsu.build.

Assembly names (or ids) are short strings that match the regular expression:

    [a-zA-Z][a-zA-Z0-9]+
While they are not constrained in length they should be three or four characters long. Assembly ids should be treated as case-insensitive strings in all comparisons.

The version class is Comparable. Versions are expected be monotonically increasing over time for a given assembly id where each field is compared placing greater significance on the fields to the left. Thus:

     wnc.2.0.0.0.0 > wnc.1.0.0.0.0
     wnc.1.1.0.0.0 > wnc.1.0.0.0.0
     wnc.1.1.1.0.0 > wnc.1.1.0.0.0
     wnc.1.1.1.1.0 > wnc.1.1.1.0.0
     wnc.1.1.1.1.1 > wnc.1.1.1.1.1
 
Versions with different assembly ids will always report inequality via the equals method. However, if the compareTo() methods are used, the assembly ids will be compared lexicographically and then the version numbers will be compared left-to-right.

Background on a Format Change

Prior to 6.2.3 version numbers did not have an assembly id. They were added to allow for differing release rates of the Windchill Platform and each Solution that depends on the Platform.

Prior to Windchill 6.2 versions were major.minor.dsu.build. ServicePack number was added during the 6.0 maintenance cycle. Because there was a need to support specification of service pack level in 6.0 and Version did not have the extra field, the dsu part was encoded with the service pack number times 1000. So 6.2 service pack 1 DSU 3 would look like 6.2.1003.

Also prior to Windchill 6.2 versions were allowed to be specified with fewer than four numbers. Doing so would result in a version that only contains the specified numbers. Now five numbers are required in the string representation of a version. Thus all versions will in string form will have five fields, with zeros for fields that are not specified. For example, if you create a version with Version.createFrom("6.2"), the string form of this version will be 6.2.0.0.0.

6.2-to-6.2.3Backward Compatibility(String Representation)

For backward compatibility all version numbers are automatically assigned the wnc assembly id, unless a AssemblyIdResolver is provided to the createFrom(String,AssemblyResolver) method. The AssemblyIdResolver will be given an opportunity to determine an alternative assembly id through whatever means it chooses.

Pre-6.2 Backward Compatibility(String Representation)

Versions that are specified without all five fields are assumed to not contain the service pack value. If the dsu value is specified and is contains an encoded service pack number, then the service pack number will be set by dividing the dsu number by 1000, and the dsu number will be set by mod'ing the dsu number with 1000.

If a five digit number is specified, each field is interpreted verbatim. No decoding will occur.

Whenever possible, code should not manipulate version strings directly. Rather, it should create a Version instance from the String and use the Version instead.

6.2-to-6.2.3 Backward Compatibility(XML Representation)

As of 6.2 version numbers should be stored in a single string as an attribute or text element. Therefore, backward compatibility is the same as when parsing version in their string representation.

Pre-6.2 Backward Compatibility(XML Representation)

The Version class has always been able to "read" and "write" itself as a DOM Element. The representation for this element was:
   
where the element name could be tailored if desired, and the minor, micro, and build attributes weren't required.

Because of the change in version number representation, the XML structure has been changed. Rather than add another attribute for service pack, versions will now be represented in the format:

   
where the version's string representation is in the number attribute. This has been don't to reduce coupling between version number format and the XML structure, allowing us more room in the future to handle format changes.

The current version class can handle decoding XML Elements in either form. So as long as code that uses XML version represetations always creates a ReleaseId instance from the Element and uses the ReleaseId class rather than directly querying the Element, this code will be isolated from format changes.

Example Mappings

    1             =>  wnc.1.0.0.0.0
    1.2           =>  wnc.1.2.0.0.0
    1.2.3         =>  wnc.1.2.0.3.0
    1.2.3.4       =>  wnc.1.2.0.3.4
    1.2.3.4.5     =>  wnc.1.2.3.4.5
    1.2.3004      =>  wnc.1.2.3.4.0
    1.2.3004.5    =>  wnc.1.2.3.4.5
    1.2.0.3004.5  =>  wnc.1.2.0.3004.5
    1.2.6.3004.5  =>  wnc.1.2.6.3004.5
 

Important Note

The version 6.0.2 is always treated as 6.0.0.1000.0 / 6.0.1.0.0. This is because it was meant to be a service pack. However, the service pack-numbering scheme could not be introduced because the version classes were unable to handle numbers of 1000 or greater properly. There wasn't sufficient time to correct the problem for the 6.0 service pack 1 release, so it's version number was changed to 6.0.2.0 even though this release wasn't a DSU release. The problem was corrected immediately, and support for automatically mapping from 6.0.2 to 6.0.1.0.0 was added to later product versions, giving the appearances of correct numbering and preventing future problems.

Supported API: true

Extendable: false

See Also:
createFrom(java.lang.String), createFrom(org.w3c.dom.Element)

Nested Class Summary
static interface com.ptc.windchill.instassm.ReleaseId.AssemblyIdResolver
          Produce an assembly id for a release identifier that contains no assembly id.
 
Constructor Summary
ReleaseId(String assembly_id, Integer major, Integer minor, Integer service_pack, Integer dsu, Integer build)
          Constructs a version from all numeric values

Supported API: true

Extendable: false
ReleaseId(String assembly_id, int major, int minor, int service_pack, int dsu, int build)
          

Supported API: true

Extendable: false
 
Method Summary
 int compareTo(Object other_)
          Compares the argument to this ReleaseId.
static ReleaseId createFrom(String version_string)
          Constructs a ReleaseId object from a String.
 boolean equals(Object other)
          Returns true if the argument is a ReleaseId object and have equal major, minor, dsu, and build levels.
 String getAssemblyId()
          Returns the assembly identifier.
 int getBuild()
          Returns the build number.
 int getDsu()
          Returns the dsu number.
 int getMajor()
          Returns the major number.
 int getMinor()
          Returns the minor number.
 String getReleaseIdComponent()
          Returns the version.
 int getServicePack()
          Returns the service pack number.
 String getShortenedMajorMinorServicePackComponent()
          Returns the sortened version which is the concatenation of just the major and minor verison numbers separated by period.
 String getShortenedReleaseIdComponent()
          Returns the sortened version which is the concatenation of the major, minor, and dsu without the build number separated by periods and stripping any insignificant zeros off of the right-hand portion of the string.
 String getThreePartVersionString()
          Returns the first three parts of the version number.
 String getTwoPartVersionString()
          Returns the first two parts of the version number.
 int hashCode()
          

Supported API: true

Extendable: false
 String toString()
          returns a String representation of this ReleaseId.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReleaseId

public ReleaseId(String assembly_id,
                 Integer major,
                 Integer minor,
                 Integer service_pack,
                 Integer dsu,
                 Integer build)
          throws com.ptc.windchill.instassm.ReleaseIdException
Constructs a version from all numeric values

Supported API: true

Extendable: false

Parameters:
assembly_id - String
major - Integer
minor - Integer
service_pack - Integer
dsu - Integer
build - Integer
Throws:
ReleaseIdException

ReleaseId

public ReleaseId(String assembly_id,
                 int major,
                 int minor,
                 int service_pack,
                 int dsu,
                 int build)
          throws com.ptc.windchill.instassm.ReleaseIdException


Supported API: true

Extendable: false

Throws:
com.ptc.windchill.instassm.ReleaseIdException
Method Detail

getAssemblyId

public final String getAssemblyId()
Returns the assembly identifier.

Supported API: true

Extendable: false

Returns:
a non-null String

getReleaseIdComponent

public final String getReleaseIdComponent()
Returns the version. A version is the concatenation of the major, minor, dsu, and build levels, separated by periods. If the version is 6.2.x then the value could be four parts and include the service pack and DSU as separate fields. If major.minor is anything else, then the service pack and DSU will be combined into a single number.

Supported API: true

Extendable: false

Returns:
non-null String in the form of "major.minor.servicePack.dsu.build", e.g. 6.1.01.01

getShortenedReleaseIdComponent

public final String getShortenedReleaseIdComponent()
Returns the sortened version which is the concatenation of the major, minor, and dsu without the build number separated by periods and stripping any insignificant zeros off of the right-hand portion of the string. If the version is 6.2.x then the value could be four parts and include the service pack and DSU as separate fields. If major.minor is anything else, then the service pack and DSU will be combined into a single number.

Supported API: true

Extendable: false

Returns:
non-null String

getTwoPartVersionString

public final String getTwoPartVersionString()
Returns the first two parts of the version number.

Supported API: true

Extendable: false

Returns:
non-null String

getThreePartVersionString

public final String getThreePartVersionString()
Returns the first three parts of the version number. The third number will ALWAYS be the combined servicepack-DSU value.

Supported API: true

Extendable: false

Returns:
non-null String

getShortenedMajorMinorServicePackComponent

public final String getShortenedMajorMinorServicePackComponent()
Returns the sortened version which is the concatenation of just the major and minor verison numbers separated by period. The minor number will be stripped if it is zero.

Supported API: true

Extendable: false

Returns:
non-null String

getMajor

public final int getMajor()
Returns the major number.

Supported API: true

Extendable: false

Returns:
a value greater than or equal to zero

getMinor

public final int getMinor()
Returns the minor number.

Supported API: true

Extendable: false

Returns:
a value greater than or equal to zero

getServicePack

public final int getServicePack()
Returns the service pack number.

Supported API: true

Extendable: false

Returns:
a value greater than or equal to zero

getDsu

public final int getDsu()
Returns the dsu number.

Supported API: true

Extendable: false

Returns:
a value greater than or equal to zero

getBuild

public final int getBuild()
Returns the build number.

Supported API: true

Extendable: false

Returns:
a value greater than or equal to zero

toString

public String toString()
returns a String representation of this ReleaseId. If the version is 6.2.x then the value of the service pack and DSU will be output as separate fields (e.g. wnc.6.2.6.0.20). Otherwise, the service pack and DSU numbers will be combined into a single number (e.g. 6.1.1001.5).

Supported API: true

Extendable: false

Overrides:
toString in class Object
Returns:
a non-null String

hashCode

public int hashCode()


Supported API: true

Extendable: false

Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Returns true if the argument is a ReleaseId object and have equal major, minor, dsu, and build levels.

Supported API: true

Extendable: false

Overrides:
equals in class Object
Parameters:
other_ - Object should be an instance of ReleaseId or ReleaseId subclass
Returns:
boolean true if the both ReleaseIds have equal version Strings

compareTo

public int compareTo(Object other_)
Compares the argument to this ReleaseId. If they are equal, return zero. If this ReleaseId is less than the argument, returns a negative number. If this ReleaseId is greater than the argument, returns a positive number. If other_ is not a ReleaseId instance, returns -1.

Supported API: true

Extendable: false

Specified by:
compareTo in interface Comparable
Parameters:
other_ - Object ReleaseId to be compared with this.
Returns:
int

createFrom

public static final ReleaseId createFrom(String version_string)
                                  throws com.ptc.windchill.instassm.ReleaseIdException
Constructs a ReleaseId object from a String. Assembly id will be wnc if it is not specified in the string.

Supported API: true

Extendable: false

Parameters:
version_string - String Non-null string in any of the acceptable forms(see class javadocs)
Returns:
a non-null ReleaseId
Throws:
ReleaseIdException - if version_string is not in an acceptable form