--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.tools.sysinfo\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to You under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.tools;\r
+\r
+import org.apache.derby.iapi.services.info.ProductVersionHolder;\r
+import org.apache.derby.iapi.services.info.JVMInfo;\r
+import org.apache.derby.impl.tools.sysinfo.Main;\r
+\r
+/**\r
+ \r
+ This class displays system information to system out.\r
+ \r
+ To run from the command-line, enter the following:\r
+ <p>\r
+ <code>java org.apache.derby.tools.sysinfo</code>\r
+ <p>\r
+ <p>\r
+ Also available on this class are methods which allow you to determine\r
+ the version of the code for the system without actually booting a database.\r
+ Please note that this is the Derby version of the .jar files, not of your databases.\r
+ <p>\r
+ The numbering scheme for released Derby products is <b><code>m1.m2.m3 </code></b>\r
+ where <b><code>m1</code></b> is the major release version, <b><code>m2</code></b> is the minor release version,\r
+ and <b><code>m3</code></b> is the maintenance level. Versions of the product with the same\r
+ major and minor version numbers are considered feature compatible. \r
+ <p>Valid major and minor versions are always greater than zero. Valid maintenance\r
+ versions are greater than or equal to zero.\r
+\r
+\r
+*/\r
+public class sysinfo {\r
+\r
+ static public void main(String[] args) {\r
+ Main.main(args);\r
+ }\r
+\r
+ private sysinfo() { // no instances allowed\r
+ }\r
+\r
+ /**\r
+ The genus name for the Apache Derby code. Use this to determine the version of the\r
+ Apache Derby embedded code in derby.jar.\r
+ */\r
+ public static final String DBMS="DBMS";\r
+\r
+ /**\r
+ * The genus name for the tools code. Use this to determine the version of \r
+ code in derbytools.jar\r
+ */\r
+ public static final String TOOLS="tools";\r
+\r
+ /**\r
+ * The genus name for the network server code. Use this to determine the version of \r
+ code in derbynet.jar\r
+ */\r
+ public static final String NET="net";\r
+\r
+ /**\r
+ * The genus name for the client code. Use this to determine the version of \r
+ code in derbyclient.jar\r
+ */\r
+ public static final String CLIENT="dnc";\r
+\r
+\r
+ /**\r
+ gets the major version of the Apache Derby embedded code.\r
+ @return the major version. Returns -1 if not found.\r
+ */\r
+ static public int getMajorVersion()\r
+ {\r
+ return getMajorVersion(DBMS);\r
+ }\r
+\r
+\r
+ /**\r
+ gets the major version of the specified code library. \r
+ @param genus which library to get the version of. Valid inputs include\r
+ DBMS, TOOLS, NET, CLIENT\r
+ @return the major version. Return -1 if the information is not found. \r
+ */ \r
+ static public int getMajorVersion(String genus)\r
+ {\r
+ ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus);\r
+ if (pvh == null)\r
+ {\r
+ return -1;\r
+ }\r
+\r
+ return pvh.getMajorVersion();\r
+ }\r
+\r
+\r
+ /**\r
+ gets the minor version of the Apache Derby embedded code.\r
+ @return the minor version. Returns -1 if not found.\r
+ */\r
+ static public int getMinorVersion()\r
+ {\r
+ return getMinorVersion(DBMS);\r
+ }\r
+\r
+ /**\r
+ gets the minor version of the specified code library. \r
+ @param genus which library to get the version of. Valid inputs include\r
+ DBMS, TOOLS, NET, CLIENT.\r
+ @return the minor version. Return -1 if the information is not found. \r
+ */ \r
+ static public int getMinorVersion(String genus)\r
+ {\r
+ ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus);\r
+ if (pvh == null)\r
+ {\r
+ return -1;\r
+ }\r
+\r
+ return pvh.getMinorVersion();\r
+ }\r
+\r
+ /**\r
+ gets the build number for the Apache Derby embedded library\r
+ @return the build number, or -1 if the information is not found.\r
+ */\r
+ static public String getBuildNumber()\r
+ {\r
+ return getBuildNumber("DBMS");\r
+ }\r
+\r
+ /**\r
+ gets the build number for the specified library\r
+ @param genus which library to get the build number for. Valid inputs are\r
+ DBMS, TOOLS, NET, CLIENT.\r
+ @return the build number, or ???? if the information is not found.\r
+ */\r
+ static public String getBuildNumber(String genus)\r
+ {\r
+ ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus);\r
+ if (pvh == null)\r
+ {\r
+ return "????";\r
+ }\r
+\r
+ return pvh.getBuildNumber();\r
+ }\r
+\r
+\r
+ /**\r
+ gets the product name for the Apache Derby embedded library\r
+ @return the name\r
+ */\r
+ static public String getProductName()\r
+ {\r
+ return getProductName("DBMS");\r
+ }\r
+\r
+ /**\r
+ gets the external name for the specified code library.\r
+ @param genus which library to get the name for\r
+ @return the name.\r
+ */\r
+\r
+ static public String getProductName(String genus)\r
+ {\r
+ ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus);\r
+ if (pvh == null)\r
+ {\r
+ return Main.getTextMessage ("SIF01.K");\r
+ }\r
+\r
+ return pvh.getProductName();\r
+ }\r
+\r
+ /**\r
+ Return the version information string for the specified library including alpha or beta indicators.\r
+ */\r
+ static public String getVersionString() {\r
+ return getVersionString(DBMS);\r
+ }\r
+\r
+ /**\r
+ Return the version information string for the Apache Derby embedded library including alpha or beta indicators.\r
+ */\r
+ static public String getVersionString(String genus) {\r
+\r
+ ProductVersionHolder pvh = ProductVersionHolder.getProductVersionHolderFromMyEnv(genus);\r
+ if (pvh == null)\r
+ {\r
+ return Main.getTextMessage ("SIF01.K");\r
+ }\r
+ \r
+ return pvh.getVersionBuildString(false);\r
+ }\r
+\r
+ public static void getInfo (java.io.PrintWriter out) {\r
+ Main.getMainInfo(out, false);\r
+ }\r
+}\r