KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > Version


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase;
11
12 import java.io.*;
13
14 /**
15  * MMBase version reporter. The only goal of this class is providing the current version of
16  * MMBase. The function 'get' will return it as one String.
17  *
18  * @author Daniel Ockeloen
19  * @author Michiel Meeuwissen
20  * @version $Id: Version.java,v 1.39.2.3 2006/12/05 22:06:48 michiel Exp $
21  */

22 public class Version {
23
24     /**
25      * Returns the 'name' part of the MMBase version. This will normally be 'MMBase'.
26      * @return Name part of version
27      * @since MMBase-1.6
28      */

29     public static String JavaDoc getName() {
30         return "MMBase";
31     }
32
33     /**
34      * Returns the major version number of this MMBase.
35      * @return major version number
36      * @since MMBase-1.6
37      */

38     public static int getMajor() {
39         return 1;
40     }
41     /**
42      * Returns the minor version number of this MMBase.
43      * @return minor version number
44      * @since MMBase-1.6
45      */

46     public static int getMinor() {
47         return 8;
48     }
49
50     /**
51      * Returns the patch level number of this MMBase.
52      * @return patch level number
53      * @since MMBase-1.6
54      */

55     public static int getPatchLevel() {
56         return 3;
57     }
58
59     /**
60      * Returns the build date of this MMBase. During the build, the
61      * value of this is stored in builddate.properties.
62      * @return build date of this MMBase
63      *
64      * @since MMBase-1.6
65      */

66     public static String JavaDoc getBuildDate() {
67         String JavaDoc resource = "";
68         InputStream builddate = Version.class.getResourceAsStream("builddate.properties");
69         if (builddate != null) {
70             try {
71                 BufferedReader buffer = new BufferedReader(new InputStreamReader(builddate));
72                 resource = buffer.readLine();
73                 buffer.close();
74             } catch (IOException e) {
75                 // error
76
resource = "" + e;
77             }
78         }
79         return resource;
80     }
81
82     /**
83      * Returns the version number of this MMBase.
84      * @return version number
85      * @since MMBase-1.6
86      */

87     public static String JavaDoc getNumber() {
88         return getMajor() + "." + getMinor() + "." + getPatchLevel() + (isRelease() ? "-" + getReleaseStatus() + " " : ".") + getBuildDate();
89     }
90
91     /**
92      * Returns if this is a release version of MMBase. If this is false this MMBase is only a CVS snapshot.
93      * @return is a release version
94      * @since MMBase-1.6
95      */

96     public static boolean isRelease() {
97         return true;
98     };
99
100     /**
101      * A String describing the status of this release. Like 'final' or 'rc3'.
102      * @return status of this release
103      * @since MMBase-1.7
104      */

105     public static String JavaDoc getReleaseStatus() {
106         return "final";
107     };
108
109     /**
110      * Returns the version of this MMBase.
111      * @return version of this MMBase
112      * @since MMBase-1.6
113      */

114     public static String JavaDoc get() {
115         return getName() + " " + getNumber();
116     }
117
118
119     /**
120      * Prints the version of this mmbase on stdout.
121      * can be usefull on command line:
122      * <code>java -jar mmbase.jar<code>
123      *
124      * @param args command line args
125      */

126     public static void main(String JavaDoc args[]) {
127         System.out.println(get());
128     }
129
130 }
131
Popular Tags