KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > tools > sysinfo


1 /*
2
3    Derby - Class org.apache.derby.tools.sysinfo
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.tools;
23
24 import org.apache.derby.iapi.services.info.ProductVersionHolder;
25 import org.apache.derby.iapi.services.info.JVMInfo;
26 import org.apache.derby.impl.tools.sysinfo.Main;
27
28 /**
29     
30    This class displays system information to system out.
31      
32     To run from the command-line, enter the following:
33     <p>
34     <code>java org.apache.derby.tools.sysinfo</code>
35     <p>
36     <p>
37     Also available on this class are methods which allow you to determine
38     the version of the code for the system without actually booting a database.
39     Please note that this is the Derby version of the .jar files, not of your databases.
40     <p>
41     The numbering scheme for released Derby products is <b><code>m1.m2.m3 </code></b>
42     where <b><code>m1</code></b> is the major release version, <b><code>m2</code></b> is the minor release version,
43     and <b><code>m3</code></b> is the maintenance level. Versions of the product with the same
44     major and minor version numbers are considered feature compatible.
45     <p>Valid major and minor versions are always greater than zero. Valid maintenance
46     versions are greater than or equal to zero.
47
48
49 */

50 public class sysinfo {
51
52   static public void main(String JavaDoc[] args) {
53     Main.main(args);
54   }
55
56   private sysinfo() { // no instances allowed
57
}
58
59     /**
60         The genus name for the Apache Derby code. Use this to determine the version of the
61         Apache Derby embedded code in derby.jar.
62     */

63     public static final String JavaDoc DBMS="DBMS";
64
65     /**
66      * The genus name for the tools code. Use this to determine the version of
67         code in derbytools.jar
68      */

69     public static final String JavaDoc TOOLS="tools";
70
71     /**
72      * The genus name for the network server code. Use this to determine the version of
73         code in derbynet.jar
74      */

75     public static final String JavaDoc NET="net";
76
77     /**
78      * The genus name for the client code. Use this to determine the version of
79         code in derbyclient.jar
80      */

81     public static final String JavaDoc CLIENT="dnc";
82
83
84     /**
85         gets the major version of the Apache Derby embedded code.
86         @return the major version. Returns -1 if not found.
87      */

88   static public int getMajorVersion()
89   {
90     return getMajorVersion(DBMS);
91   }
92
93
94     /**
95         gets the major version of the specified code library.
96         @param genus which library to get the version of. Valid inputs include
97             DBMS, TOOLS, NET, CLIENT
98         @return the major version. Return -1 if the information is not found.
99     */

100   static public int getMajorVersion(String JavaDoc genus)
101   {
102         ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus);
103         if (pvh == null)
104         {
105             return -1;
106         }
107
108         return pvh.getMajorVersion();
109   }
110
111
112     /**
113         gets the minor version of the Apache Derby embedded code.
114         @return the minor version. Returns -1 if not found.
115      */

116   static public int getMinorVersion()
117   {
118     return getMinorVersion(DBMS);
119   }
120
121     /**
122         gets the minor version of the specified code library.
123         @param genus which library to get the version of. Valid inputs include
124             DBMS, TOOLS, NET, CLIENT.
125         @return the minor version. Return -1 if the information is not found.
126     */

127   static public int getMinorVersion(String JavaDoc genus)
128   {
129         ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus);
130         if (pvh == null)
131         {
132             return -1;
133         }
134
135         return pvh.getMinorVersion();
136   }
137
138     /**
139         gets the build number for the Apache Derby embedded library
140         @return the build number, or -1 if the information is not found.
141     */

142   static public String JavaDoc getBuildNumber()
143   {
144     return getBuildNumber("DBMS");
145   }
146
147     /**
148         gets the build number for the specified library
149         @param genus which library to get the build number for. Valid inputs are
150             DBMS, TOOLS, NET, CLIENT.
151         @return the build number, or ???? if the information is not found.
152     */

153   static public String JavaDoc getBuildNumber(String JavaDoc genus)
154   {
155         ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus);
156         if (pvh == null)
157         {
158             return "????";
159         }
160
161         return pvh.getBuildNumber();
162   }
163
164
165     /**
166         gets the product name for the Apache Derby embedded library
167         @return the name
168     */

169   static public String JavaDoc getProductName()
170   {
171     return getProductName("DBMS");
172   }
173
174     /**
175         gets the external name for the specified code library.
176         @param genus which library to get the name for
177         @return the name.
178     */

179
180   static public String JavaDoc getProductName(String JavaDoc genus)
181   {
182         ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus);
183         if (pvh == null)
184         {
185             return Main.getTextMessage ("SIF01.K");
186         }
187
188         return pvh.getProductName();
189   }
190
191   /**
192     Return the version information string for the specified library including alpha or beta indicators.
193   */

194   static public String JavaDoc getVersionString() {
195     return getVersionString(DBMS);
196   }
197
198   /**
199     Return the version information string for the Apache Derby embedded library including alpha or beta indicators.
200   */

201   static public String JavaDoc getVersionString(String JavaDoc genus) {
202
203         ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus);
204         if (pvh == null)
205         {
206             return Main.getTextMessage ("SIF01.K");
207         }
208         
209         return pvh.getVersionBuildString(false);
210   }
211
212   public static void getInfo (java.io.PrintWriter JavaDoc out) {
213     Main.getMainInfo(out, false);
214   }
215 }
216
Popular Tags