KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jimm > datavision > info


1 package jimm.datavision;
2 import jimm.util.Getopts;
3
4 /**
5  * This class is a holder of version and copyright information.
6  *
7  * @author Jim Menard, <a HREF="mailto:jimm@io.com">jimm@io.com</a>
8  */

9 public class info {
10
11 public static final int VERSION_MAJOR = 1;
12 public static final int VERSION_MINOR = 0;
13 public static final int VERSION_TWEAK = 0;
14
15 public static final String JavaDoc Version =
16     "" + VERSION_MAJOR + "." + VERSION_MINOR + "." + VERSION_TWEAK;
17 public static final String JavaDoc Copyright =
18     "Copyright (c) 2001-2005 Jim Menard, jimm@io.com";
19 public static final String JavaDoc URL = "http://datavision.sourceforge.net";
20
21 /**
22  * usage: info [-v] [-c] [-u] [-n]
23  *
24  * Prints version (-v), copyright (-c), and/or URL (-u). If -n is specified,
25  * each is terminated with a newline. If it is not, no newline is output but
26  * they are separated by spaces if more than one of -v, -c, or -u was also
27  * specified.
28  */

29 public static void main(String JavaDoc[] args) {
30     Getopts g = new Getopts("vcun", args);
31     boolean moreThanOne =
32     ((g.hasOption('v') ? 1 : 0)
33      + (g.hasOption('c') ? 1 : 0)
34      + (g.hasOption('u') ? 1 : 0)) > 1;
35     String JavaDoc separator = g.hasOption('n') ? "\n" : " ";
36
37     if (g.hasOption('v')) System.out.print(Version);
38     if (moreThanOne) System.out.print(separator);
39     if (g.hasOption('c')) System.out.print(Copyright);
40     if (moreThanOne) System.out.print(separator);
41     if (g.hasOption('u')) System.out.print(URL);
42
43     if (g.hasOption('n')) System.out.println();
44 }
45
46 }
47
Popular Tags