|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ptc.windchill.instassm.ReleaseId
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.1Versions 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.
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
.
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.
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.
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.
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
createFrom(java.lang.String)
,
createFrom(org.w3c.dom.Element)
Nested Class Summary | |
static interface |
ReleaseId.AssemblyIdResolver
Produce an assembly id for a release identifier that contains no assembly id. |
Field Summary | |
private String |
assemblyId_
|
private int |
build_
|
private Integer |
cachedHashCode_
|
private static String |
CLASSNAME
|
private String |
dateCode_
|
private int |
dsu_
|
private int |
major_
|
private int |
minor_
|
static ReleaseId |
NEGATIVE_INFINITY
|
static String |
NUMBER_ATTR
|
private static String |
OLD_BUILD_ATTR
|
private static String |
OLD_MAJOR_ATTR
|
private static String |
OLD_MICRO_ATTR
|
private static String |
OLD_MINOR_ATTR
|
static ReleaseId |
POSITIVE_INFINITY
|
private String |
releaseIdentifier_
|
private static String |
RESOURCE
|
private int |
servicePack_
|
private String |
shortenedReleaseIdComponent_
|
private static DecimalFormat |
twoPadFormat__
|
(package private) static String |
VERSION_SEPARATOR
|
static String |
VERSION_TAG
|
private String |
versionComponent_
|
private static ReleaseId.AssemblyIdResolver |
WNC_ASSEMBLY_ID_RESOLVER
|
private static Integer |
ZERO
|
Constructor Summary | |
private |
ReleaseId()
Constructor to support infinities. |
|
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 | |
Element |
asDOM(Document doc)
Creates a |
Element |
asDOM(Document doc,
String element_name)
Creates a |
private static int |
asIntZeroIfNull(Integer value)
|
private static int |
compareIntValues(int source,
int target)
|
int |
compareTo(Object other_)
Compares the argument to this ReleaseId. |
int |
compareTo(ReleaseId other)
Compares the argument to this ReleaseId. |
static ReleaseId |
createFrom(Element element)
Constructs a ReleaseId object from a DOM element. |
static ReleaseId |
createFrom(String version_string)
Constructs a ReleaseId object from a String. |
static ReleaseId |
createFrom(String version_string,
ReleaseId.AssemblyIdResolver assm_id_resolver)
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. |
private static String |
getAttr(Element element,
String attr_name,
String fallback_value)
Gets from the provided element the named attribute, returning the fallback value if the attribute is missing or is an empty string. |
int |
getBuild()
Returns the build number. |
private int |
getCombinedSpAndDsu()
|
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. |
static String |
getVersionSeparator()
|
boolean |
hasAssemblyId(String assembly_id)
Compares the ReleaseId's assembly id to that passed in as a parameter. |
int |
hashCode()
Supported API: true Extendable: false |
boolean |
hasSameAssemblyIdAs(ReleaseId other_version)
Compares the ReleaseId's assembly id to that of the other version. |
static void |
main(String[] args)
Usage: java -cp /Windchill/srclib/CommonCore.jar com.ptc.windchill.instassm.ReleaseId <release_id> ... |
String |
toString()
returns a String representation of this ReleaseId. |
private String |
twoPad(int number)
|
private static void |
validateAssemblyId(String potential_assembly_id)
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final DecimalFormat twoPadFormat__
private static final Integer ZERO
static final String VERSION_SEPARATOR
public static final String VERSION_TAG
public static final String NUMBER_ATTR
private static final String OLD_MAJOR_ATTR
private static final String OLD_MINOR_ATTR
private static final String OLD_MICRO_ATTR
private static final String OLD_BUILD_ATTR
private static final String RESOURCE
private static final String CLASSNAME
public static final ReleaseId POSITIVE_INFINITY
public static final ReleaseId NEGATIVE_INFINITY
private static final ReleaseId.AssemblyIdResolver WNC_ASSEMBLY_ID_RESOLVER
private String assemblyId_
private int major_
private int minor_
private int servicePack_
private int dsu_
private int build_
private String releaseIdentifier_
private String dateCode_
private Integer cachedHashCode_
private String versionComponent_
private String shortenedReleaseIdComponent_
Constructor Detail |
private ReleaseId()
public ReleaseId(String assembly_id, Integer major, Integer minor, Integer service_pack, Integer dsu, Integer build) throws ReleaseIdException
assembly_id
- Stringmajor
- Integerminor
- Integerservice_pack
- Integerdsu
- Integerbuild
- Integer
ReleaseIdException
public ReleaseId(String assembly_id, int major, int minor, int service_pack, int dsu, int build) throws ReleaseIdException
Method Detail |
public static final String getVersionSeparator()
private static final int asIntZeroIfNull(Integer value)
public final String getAssemblyId()
public final boolean hasAssemblyId(String assembly_id)
public final boolean hasSameAssemblyIdAs(ReleaseId other_version)
public final String getReleaseIdComponent()
private int getCombinedSpAndDsu()
public final String getShortenedReleaseIdComponent()
public final String getTwoPartVersionString()
public final String getThreePartVersionString()
public final String getShortenedMajorMinorServicePackComponent()
public final int getMajor()
public final int getMinor()
public final int getServicePack()
public final int getDsu()
public final int getBuild()
public String toString()
public int hashCode()
public boolean equals(Object other)
public int compareTo(Object other_)
compareTo
in interface Comparable
other_
- Object ReleaseId to be compared with this.
public int compareTo(ReleaseId other)
other
- ReleaseId ReleaseId to be compared with this.
private static final int compareIntValues(int source, int target)
public Element asDOM(Document doc)
doc
- w3c.org.dom.Document The document used to instantiate the Element.
public Element asDOM(Document doc, String element_name)
doc
- w3c.org.dom.Document The document used to instantiate the Element.element_name
- String The String to be used for the element tag.
public static ReleaseId createFrom(Element element) throws ReleaseIdException
ReleaseIdException
private static String getAttr(Element element, String attr_name, String fallback_value)
public static final ReleaseId createFrom(String version_string) throws ReleaseIdException
version_string
- String Non-null string in any of the acceptable forms(see class javadocs)
ReleaseIdException
- if version_string is not in an acceptable formpublic static final ReleaseId createFrom(String version_string, ReleaseId.AssemblyIdResolver assm_id_resolver) throws ReleaseIdException
version_string
- String Non-null string in any of the acceptable forms(see class javadocs)
ReleaseIdException
- if version_string is not in an acceptable formprivate static final void validateAssemblyId(String potential_assembly_id) throws ReleaseIdException
ReleaseIdException
private final String twoPad(int number)
public static void main(String[] args)
Usage: java -cp /Windchill/srclib/CommonCore.jar com.ptc.windchill.instassm.ReleaseId <release_id> ...
Example: java -cp /Windchill/srclib/CommonCore.jar com.ptc.windchill.instassm.ReleaseId wnc.7.0.2 7.1.0.3.4
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |