Source code: rcs/RCS_VERSION.java
1 /* RCS_VERSION.java
2 * Provides a means for Java Applications to check the version of the
3 * RCS Library being used.
4 * The install_rcs script uses sed to replace 4.29 in
5 * RCS_VERSION.java.perm --> RCS_VERSION.java
6 * file with the appropriate version number. This is to provide consistency
7 * in the version numbers between Java and C++.
8 */
9
10
11 package rcs;
12
13 import java.util.StringTokenizer;
14 import java.util.Properties;
15
16
17 /**
18 * Class for checking at run-time which version of the RCS Library
19 * is being used.
20 * <pre>
21 * Related Documentation:
22 * <A HREF="http://isd.cme.nist.gov/proj/rcs_lib">RCS Library</a>,
23 * <A HREF="http://isd.cme.nist.gov/proj/rcs_lib/rcsvers.html">RCS Version Functions</a>
24 *
25 * Source Code:
26 * <A HREF="RCS_VERSION.java">RCS_VERSION.java</a>
27 *
28 * </pre>
29 *
30 * @author Will Shackleford -- <A HREF="mailto:shackle@cme.nist.gov">shackle@cme.nist.gov</a>
31 *
32 */
33 public class RCS_VERSION extends Object
34 {
35 /**
36 * String in which the version number 4.29 is stored.
37 */
38 public static final String version_string = "4.29";
39
40 /**
41 * String in which the library was compiled is stored.
42 */
43 public static final String date_string = "Mon May 15 13:18:12 EDT 2000";
44
45 /**
46 * String in which a brief message describing the library, it's version
47 * and compile date etc. is stored.
48 */
49 public static final String info_string = "@(#)" + " RCS_LIBRARY_VERSION: " + 4.29 + " Compiled on "+ "Mon May 15 13:18:12 EDT 2000"+ " for the java platform.\n";
50
51 /**
52 * Function that returns the info_string.
53 *
54 * @returns info_string
55 */
56 public String toString()
57 {
58 return super.toString() + info_string;
59 }
60
61 /**
62 * Function that prints the info_string to System.out
63 */
64 static public void print()
65 {
66 System.out.println(info_string);
67 }
68
69 /**
70 * Running this class as a stand-alone application displays
71 * the RCS Library version information and the Java System
72 * properties.
73 *
74 * @param args NOT used.
75 */
76 static public void main(String args[])
77 {
78 System.out.println("RCS Library Properties:");
79 print();
80 Properties props = System.getProperties();
81 props.save(System.out,"Java System Properties");
82 }
83
84
85 /**
86 * Compare the version of the library with some other version.
87 * If the argument only includes a major version number, the
88 * minor version number is ignored.
89 *
90 * @param str_to_compare A version to compare with the library being used.
91 *
92 * @returns 0 if the versions are match, a negative number if
93 * the library is older than the version passed as an argument,
94 * or a positive number if the library is newer than the
95 * version passed as an argument.
96 */
97 static public int compare(String str_to_compare)
98 {
99 try
100 {
101 StringTokenizer compare_tokenizer = new StringTokenizer(str_to_compare,".");
102 StringTokenizer version_tokenizer = new StringTokenizer(version_string,".");
103 while(version_tokenizer.hasMoreTokens() && compare_tokenizer.hasMoreTokens())
104 {
105
106 String version_token = version_tokenizer.nextToken();
107 String compare_token = compare_tokenizer.nextToken();
108 int version_number = Integer.valueOf(version_token).intValue();
109 int compare_number = Integer.valueOf(compare_token).intValue();
110 if(version_number - compare_number != 0)
111 {
112 return version_number-compare_number;
113 }
114 }
115 }
116 catch(Exception e)
117 {
118 e.printStackTrace();
119 }
120 return 0;
121 }
122 }
123