1 /*
2 CIMVersion.java
3
4 (C) Copyright IBM Corp. 2005, 2010
5
6 THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
7 ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
8 CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
9
10 You can obtain a current copy of the Eclipse Public License from
11 http://www.opensource.org/licenses/eclipse-1.0.php
12
13 @author : Roberto Pineiro, IBM, roberto.pineiro@us.ibm.com
14 * @author : Chung-hao Tan, IBM ,chungtan@us.ibm.com
15 *
16 * Change History
17 * Flag Date Prog Description
18 *-------------------------------------------------------------------------------
19 * 2807325 2009-06-22 blaschke-oss Change licensing from CPL to EPL
20 * 2834838 2009-08-11 blaschke-oss Add interface to retrieve version number and product name
21 * 3027618 2010-07-14 blaschke-oss Close files/readers in finally blocks
22 */
23
24 package org.metricshub.wbem.sblim.cimclient.internal.cim;
25
26 /*-
27 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
28 * WBEM Java Client
29 * ჻჻჻჻჻჻
30 * Copyright 2023 - 2025 MetricsHub
31 * ჻჻჻჻჻჻
32 * Licensed under the Apache License, Version 2.0 (the "License");
33 * you may not use this file except in compliance with the License.
34 * You may obtain a copy of the License at
35 *
36 * http://www.apache.org/licenses/LICENSE-2.0
37 *
38 * Unless required by applicable law or agreed to in writing, software
39 * distributed under the License is distributed on an "AS IS" BASIS,
40 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41 * See the License for the specific language governing permissions and
42 * limitations under the License.
43 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
44 */
45
46 import java.io.FileNotFoundException;
47 import java.io.IOException;
48 import java.io.InputStream;
49 import java.util.Properties;
50
51 /**
52 * Class CIMVersion is responsible for providing the exact version number,
53 * product name, etc. of the Java CIM Client
54 */
55 public class CIMVersion {
56 private static String PRODUCT_NAME = "n/a";
57
58 private static String VERSION = "n/a";
59
60 private static String COPYRIGHT = "n/a";
61
62 private static String BUILDDATE = "n/a";
63
64 private static String BUILDTIME = "n/a";
65
66 static {
67 Properties properties = new Properties();
68 InputStream versionIS = null;
69 try {
70 versionIS = CIMVersion.class.getClassLoader().getResourceAsStream("org/sblim/cimclient/version.txt");
71 properties.load(versionIS);
72 PRODUCT_NAME = properties.getProperty("PRODUCTNAME");
73 VERSION = properties.getProperty("VERSION");
74 COPYRIGHT = properties.getProperty("COPYRIGHT");
75 BUILDDATE = properties.getProperty("BUILDDATE");
76 BUILDTIME = properties.getProperty("BUILDTIME");
77 } catch (FileNotFoundException e) {
78 System.out.println("Error: Could not open version.txt");
79 } catch (IOException e) {
80 System.out.println("Error while reading version.txt");
81 } finally {
82 if (versionIS != null) {
83 try {
84 versionIS.close();
85 } catch (IOException e) {
86 /* Ignore exception on close */
87 }
88 }
89 }
90 }
91
92 /**
93 * Gets the build date
94 *
95 * @return The build date
96 */
97 public static String getBuildDate() {
98 return BUILDDATE;
99 }
100
101 /**
102 * Gets the build time
103 *
104 * @return The build time
105 */
106 public static String getBuildTime() {
107 return BUILDTIME;
108 }
109
110 /**
111 * Gets the copyright statement
112 *
113 * @return THe copyright
114 */
115 public static String getCopyright() {
116 return COPYRIGHT;
117 }
118
119 /**
120 * Gets the product name
121 *
122 * @return The product name
123 */
124 public static String getProductName() {
125 return PRODUCT_NAME;
126 }
127
128 /**
129 * Gets the version
130 *
131 * @return The version
132 */
133 public static String getVersion() {
134 return VERSION;
135 }
136
137 /**
138 * toString
139 *
140 * @see java.lang.Object#toString()
141 */
142 @Override
143 public String toString() {
144 return (PRODUCT_NAME + "\n" + VERSION + "\n" + COPYRIGHT + "\n" + BUILDDATE + "\n" + BUILDTIME);
145 }
146
147 /**
148 * main
149 *
150 * @param args
151 */
152 public static void main(String[] args) {
153 System.out.println(new CIMVersion());
154 }
155 }