KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jivesoftware > util > Version


1 /**
2  * $RCSfile: Version.java,v $
3  * $Revision: 1.2 $
4  * $Date: 2004/10/21 07:28:12 $
5  *
6  * Copyright (C) 2004 Jive Software. All rights reserved.
7  *
8  * This software is published under the terms of the GNU Public License (GPL),
9  * a copy of which is included in this distribution.
10  */

11 package org.jivesoftware.util;
12
13 /**
14  * Holds version information for Jive Messenger.
15  *
16  * @author Iain Shigeoka
17  */

18 public class Version {
19
20     /**
21      * The major number (ie 1.x.x).
22      */

23     private int major;
24
25     /**
26      * The minor version number (ie x.1.x).
27      */

28     private int minor;
29
30     /**
31      * The micro version number (ie x.x.1).
32      */

33     private int micro;
34
35     /**
36      * A status release number or -1 to indicate none.
37      */

38     private int statusVersion;
39
40     /**
41      * The release state of the product (Release, Release Candidate).
42      */

43     private ReleaseStatus status;
44
45     /**
46      * Cached version string information
47      */

48     private String JavaDoc versionString;
49
50     /**
51      * Create a new version information object.
52      *
53      * @param major the major release number.
54      * @param minor the minor release number.
55      * @param micro the micro release number.
56      * @param status the status of the release.
57      */

58     public Version(int major, int minor, int micro, ReleaseStatus status, int statusVersion) {
59         this.major = major;
60         this.minor = minor;
61         this.micro = micro;
62         this.status = status;
63         this.statusVersion = statusVersion;
64         if (status != null) {
65             if (status == ReleaseStatus.Release) {
66                 versionString = major + "." + minor + "." + micro;
67             }
68             else {
69                 if (statusVersion >= 0) {
70                     versionString = major + "." + minor + "." + micro + " " + status.toString() +
71                             " " + statusVersion;
72                 }
73                 else {
74                     versionString = major + "." + minor + "." + micro + " " + status.toString();
75                 }
76             }
77         }
78         else {
79             versionString = major + "." + minor + "." + micro;
80         }
81     }
82
83     /**
84      * Returns the version number of this instance of Jive Messenger as a
85      * String (ie major.minor.revision).
86      *
87      * @return The version as a string
88      */

89     public String JavaDoc getVersionString() {
90         return versionString;
91     }
92
93     /**
94      * Returns the release status of this product.
95      *
96      * @return the release status of this product.
97      */

98     public ReleaseStatus getStatus() {
99         return status;
100     }
101
102     /**
103      * Obtain the major release number for this product.
104      *
105      * @return The major release number 1.x.x
106      */

107     public int getMajor() {
108         return major;
109     }
110
111     /**
112      * Obtain the minor release number for this product.
113      *
114      * @return The minor release number x.1.x
115      */

116     public int getMinor() {
117         return minor;
118     }
119
120     /**
121      * Obtain the micro release number for this product.
122      *
123      * @return The micro release number x.x.1
124      */

125     public int getMicro() {
126         return micro;
127     }
128
129     /**
130      * Obtain the status relase number for this product. For example, if
131      * the release status is <strong>alpha</strong> the release may be <strong>5</strong>
132      * resulting in a release status of <strong>Alpha 5</strong>.
133      *
134      * @return The status version or -1 if none is set.
135      */

136     public int getStatusVersion() {
137         return statusVersion;
138     }
139
140     /**
141      * A class to represent the release status of the server. Product releases
142      * are indicated by type safe enum constants.
143      */

144     public enum ReleaseStatus {
145         Release, Release_Candidate, Beta, Alpha;
146     }
147 }
148
Popular Tags