Source Code Cross Referenced for VersionNumber.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » vdl » toolkit » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » pegasus 2.1.0 » org.griphyn.vdl.toolkit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file or a portion of this file is licensed under the terms of
003:         * the Globus Toolkit Public License, found in file GTPL, or at
004:         * http://www.globus.org/toolkit/download/license.html. This notice must
005:         * appear in redistributions of this file, with or without modification.
006:         *
007:         * Redistributions of this Software, with or without modification, must
008:         * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
009:         * some other similar material which is provided with the Software (if
010:         * any).
011:         *
012:         * Copyright 1999-2004 University of Chicago and The University of
013:         * Southern California. All rights reserved.
014:         */
015:
016:        package org.griphyn.vdl.toolkit;
017:
018:        import java.io.*;
019:        import org.griphyn.common.util.Version;
020:        import gnu.getopt.*;
021:
022:        /**
023:         * This class just prints the current version number on stdout.
024:         *
025:         * @author Jens-S. Vöckler
026:         * @author Yong Zhao
027:         * @version $Revision: 146 $
028:         */
029:        public class VersionNumber {
030:            /**
031:             * application's own name.
032:             */
033:            private String m_application = null;
034:
035:            /**
036:             * ctor: Constructs a new instance with the given application name.
037:             * @param appName is the name of the application
038:             */
039:            public VersionNumber(String appName) {
040:                m_application = appName;
041:            }
042:
043:            /**
044:             * Prints the usage string.
045:             */
046:            public void showUsage() {
047:                String linefeed = System.getProperty("line.separator", "\r\n");
048:
049:                System.out
050:                        .println("$Id: VersionNumber.java 146 2007-05-29 21:26:10Z gmehta $"
051:                                + linefeed
052:                                + "PEGASUS version "
053:                                + Version.instance().toString() + linefeed);
054:
055:                System.out.println("Usage: " + m_application
056:                        + " [-f | -V | -m]");
057:                System.out
058:                        .println(linefeed
059:                                + "Options:"
060:                                + linefeed
061:                                + " -V|--version   print version information about itself and exit."
062:                                + linefeed
063:                                + "    --verbose   increases the verbosity level (ignored)."
064:                                + linefeed
065:                                + " -f|--full      also shows the internal built time stamp."
066:                                + linefeed
067:                                + " -m|--match     matches internal version with installation."
068:                                + linefeed
069:                                + " -q|--quiet     in match mode, no news are good news, use exit code."
070:                                + linefeed
071:                                + linefeed
072:                                + "The following exit codes are produced:"
073:                                + linefeed
074:                                + " 0  :-)  Success"
075:                                + linefeed
076:                                + " 1  :-|  Detected a mis-match in match mode. Your installation is bad!"
077:                                + linefeed
078:                                + " 2  :-(  Runtime error detected, please read the message."
079:                                + linefeed
080:                                + " 3  8-O  Fatal error merits a program abortion."
081:                                + linefeed);
082:            }
083:
084:            /**
085:             * Creates a set of options.
086:             * @return the assembled long option list
087:             */
088:            protected LongOpt[] generateValidOptions() {
089:                LongOpt[] lo = new LongOpt[7];
090:
091:                lo[0] = new LongOpt("version", LongOpt.NO_ARGUMENT, null, 'V');
092:                lo[1] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h');
093:                lo[2] = new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 1);
094:
095:                lo[3] = new LongOpt("full", LongOpt.NO_ARGUMENT, null, 'f');
096:                lo[4] = new LongOpt("build", LongOpt.NO_ARGUMENT, null, 'f');
097:                lo[5] = new LongOpt("match", LongOpt.NO_ARGUMENT, null, 'm');
098:                lo[6] = new LongOpt("quiet", LongOpt.NO_ARGUMENT, null, 'q');
099:
100:                return lo;
101:            }
102:
103:            public static void main(String args[]) {
104:                int result = 0;
105:                VersionNumber me = null;
106:
107:                try {
108:                    me = new VersionNumber("vds-version");
109:                    Getopt opts = new Getopt(me.m_application, args, "Vfhmq",
110:                            me.generateValidOptions());
111:                    opts.setOpterr(false);
112:                    String installed = null;
113:                    String internal = null;
114:                    boolean build = false;
115:                    boolean quiet = false;
116:                    Version v = Version.instance();
117:
118:                    int option = 0;
119:                    while ((option = opts.getopt()) != -1) {
120:                        switch (option) {
121:                        case 1:
122:                            break;
123:
124:                        case 'V':
125:                            System.out
126:                                    .println("$Id: VersionNumber.java 146 2007-05-29 21:26:10Z gmehta $");
127:                            System.out.println("PEGASUS version "
128:                                    + v.toString());
129:                            return;
130:
131:                        case 'f':
132:                            build = true;
133:                            break;
134:
135:                        case 'm':
136:                            installed = v.determineInstalled();
137:                            internal = v.determineBuilt() + " "
138:                                    + v.determinePlatform();
139:                            if (!quiet) {
140:                                System.out.println("Compiled into PEGASUS: "
141:                                        + internal);
142:                                System.out.println("Provided by inst.: "
143:                                        + installed);
144:                            }
145:
146:                            if (v.matches()) {
147:                                if (!quiet)
148:                                    System.out
149:                                            .println("OK: Internal version matches installation.");
150:                                return;
151:                            } else {
152:                                System.out
153:                                        .println("ERROR: Internal version does not match installed version!");
154:                                System.out
155:                                        .println("Your installation is suspicious, please correct!");
156:                                System.exit(1);
157:                            }
158:                            break;
159:
160:                        case 'q':
161:                            quiet = true;
162:                            break;
163:
164:                        case 'h':
165:                        default:
166:                            me.showUsage();
167:                            return;
168:                        }
169:                    }
170:
171:                    // action
172:                    System.out.print(v.toString());
173:                    if (build)
174:                        System.out.print('-' + v.determinePlatform() + '-'
175:                                + v.determineBuilt());
176:                    System.out.println();
177:
178:                } catch (RuntimeException rte) {
179:                    System.err.println("ERROR: " + rte.getMessage());
180:                    result = 2;
181:
182:                } catch (Exception e) {
183:                    e.printStackTrace();
184:                    System.err.println("FATAL: " + e.getMessage());
185:                    result = 3;
186:                }
187:
188:                if (result != 0)
189:                    System.exit(result);
190:            }
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.