Source Code Cross Referenced for Version.java in  » RSS-RDF » curn » org » clapper » curn » 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 » RSS RDF » curn » org.clapper.curn 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*---------------------------------------------------------------------------*\
002:          $Id: Version.java 7041 2007-09-09 01:04:47Z bmc $
003:          ---------------------------------------------------------------------------
004:          This software is released under a BSD-style license:
005:
006:          Copyright (c) 2004-2007 Brian M. Clapper. All rights reserved.
007:
008:          Redistribution and use in source and binary forms, with or without
009:          modification, are permitted provided that the following conditions are
010:          met:
011:
012:          1. Redistributions of source code must retain the above copyright notice,
013:             this list of conditions and the following disclaimer.
014:
015:          2. The end-user documentation included with the redistribution, if any,
016:             must include the following acknowlegement:
017:
018:                "This product includes software developed by Brian M. Clapper
019:                (bmc@clapper.org, http://www.clapper.org/bmc/). That software is
020:                copyright (c) 2004-2007 Brian M. Clapper."
021:
022:             Alternately, this acknowlegement may appear in the software itself,
023:             if wherever such third-party acknowlegements normally appear.
024:
025:          3. Neither the names "clapper.org", "curn", nor any of the names of the
026:             project contributors may be used to endorse or promote products
027:             derived from this software without prior written permission. For
028:             written permission, please contact bmc@clapper.org.
029:
030:          4. Products derived from this software may not be called "curn", nor may
031:             "clapper.org" appear in their names without prior written permission
032:             of Brian M. Clapper.
033:
034:          THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
035:          WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
036:          MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
037:          NO EVENT SHALL BRIAN M. CLAPPER BE LIABLE FOR ANY DIRECT, INDIRECT,
038:          INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
039:          NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
040:          DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
041:          THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
042:          (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
043:          THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
044:        \*---------------------------------------------------------------------------*/
045:
046:        package org.clapper.curn;
047:
048:        import java.io.PrintWriter;
049:        import java.io.PrintStream;
050:        import java.util.Locale;
051:
052:        import org.clapper.util.misc.BuildInfo;
053:        import org.clapper.util.misc.BundleUtil;
054:        import org.clapper.util.misc.VersionBase;
055:
056:        /**
057:         * <p>Contains the software version for the <i>org.clapper.util</i>
058:         * library. Also contains a main program which, invoked, displays the
059:         * name of the API and the version on standard output.</p>
060:         *
061:         * @version <tt>$Revision: 7041 $</tt>
062:         *
063:         * @author Copyright &copy; 2004-2007 Brian M. Clapper
064:         */
065:        public final class Version extends VersionBase {
066:            /*----------------------------------------------------------------------*\
067:                                     Public Constants
068:            \*----------------------------------------------------------------------*/
069:
070:            /**
071:             * The name of the resource bundle containing the build info.
072:             */
073:            public static final String BUILD_INFO_BUNDLE_NAME = "org.clapper.curn.BuildInfoBundle";
074:
075:            /**
076:             * This class's bundle
077:             */
078:            public static final String VERSION_BUNDLE_NAME = Constants.BUNDLE_NAME;
079:
080:            /*----------------------------------------------------------------------*\
081:                                        Static Data
082:            \*----------------------------------------------------------------------*/
083:
084:            private static BuildInfo buildInfo = null;
085:
086:            /*----------------------------------------------------------------------*\
087:                                        Constructor
088:            \*----------------------------------------------------------------------*/
089:
090:            private Version() {
091:                // Cannot be instantiated.
092:            }
093:
094:            /*----------------------------------------------------------------------*\
095:                                       Main Program
096:            \*----------------------------------------------------------------------*/
097:
098:            /**
099:             * Get an instance of this class.
100:             *
101:             * @return a singleton instance of this class.
102:             */
103:            public static Version getInstance() {
104:                return new Version();
105:            }
106:
107:            /**
108:             * Get the web site where <i>curn</i> can be found.
109:             *
110:             * @return the web site string
111:             */
112:            public String getWebSite() {
113:                return BundleUtil.getString(VERSION_BUNDLE_NAME,
114:                        "curn.website", "?");
115:            }
116:
117:            /**
118:             * Get the full program version string, which contains the program
119:             * name, the version number and the build ID string. This is the string
120:             * that the {@link #showVersion()} method displays.
121:             *
122:             * @param locale the locale to use, or null for the default
123:             *
124:             * @return the full version string
125:             *
126:             * @see #showVersion()
127:             * @see #showVersion(PrintWriter)
128:             * @see #showVersion(PrintStream)
129:             * @see #getVersion
130:             */
131:            public String getFullVersion(final Locale locale) {
132:                String name = getApplicationName();
133:                String version = getVersion();
134:
135:                return BundleUtil.getMessage(VERSION_BUNDLE_NAME, locale,
136:                        "curn.fullVersion", "{0}, version {1} (build ID {2})",
137:                        new Object[] { name, version,
138:                                getBuildInfo().getBuildID() });
139:            }
140:
141:            /**
142:             * Get the full program version string, which contains the program
143:             * name, the version number and the build ID string. This is the string
144:             * that the {@link #showVersion()} method displays. This method assumes
145:             * the default locale.
146:             *
147:             * @return the full version string
148:             *
149:             * @see #showVersion()
150:             * @see #showVersion(PrintWriter)
151:             * @see #showVersion(PrintStream)
152:             * @see #getVersion
153:             */
154:            public String getFullVersion() {
155:                return getFullVersion(null);
156:            }
157:
158:            /**
159:             * Get the build ID. Calling this method is equivalent to:
160:             * <pre>getBuildInfo().getBuildID();</pre>
161:             *
162:             * @return the build ID string
163:             *
164:             * @see #getBuildInfo
165:             */
166:            public String getBuildID() {
167:                return getBuildInfo().getBuildID();
168:            }
169:
170:            /**
171:             * Display version information only to standard output.
172:             *
173:             * @see #showVersion(PrintWriter)
174:             * @see #showVersion(PrintStream)
175:             */
176:            public void showVersion() {
177:                showVersion(System.out);
178:            }
179:
180:            /**
181:             * Display version information to the specified <tt>PrintWriter</tt>.
182:             *
183:             * @param out  where to write the version string
184:             *
185:             * @see #showVersion()
186:             * @see #showVersion(PrintStream)
187:             */
188:            public void showVersion(final PrintWriter out) {
189:                out.println(getFullVersion(null));
190:            }
191:
192:            /**
193:             * Display version information to the specified <tt>PrintStream</tt>.
194:             *
195:             * @param out  where to write the version string
196:             *
197:             * @see #showVersion()
198:             * @see #showVersion(PrintWriter)
199:             */
200:            public void showVersion(final PrintStream out) {
201:                out.println(getFullVersion(null));
202:            }
203:
204:            /**
205:             * Display build information to standard output.
206:             *
207:             * @see #showBuildInfo(PrintWriter)
208:             * @see #showBuildInfo(PrintStream)
209:             * @see #getBuildInfo
210:             */
211:            public void showBuildInfo() {
212:                showBuildInfo(System.out);
213:            }
214:
215:            /**
216:             * Display build information to the specified <tt>PrintStream</tt>.
217:             *
218:             * @param out  where to write the build information
219:             *
220:             * @see #showBuildInfo()
221:             * @see #showBuildInfo(PrintWriter)
222:             * @see #getBuildInfo
223:             */
224:            public void showBuildInfo(final PrintStream out) {
225:                showBuildInfo(new PrintWriter(out));
226:            }
227:
228:            /**
229:             * Display build information to the specified <tt>PrintWriter</tt>.
230:             *
231:             * @param out  where to write the build information
232:             *
233:             * @see #showBuildInfo()
234:             * @see #showBuildInfo(PrintStream)
235:             * @see #getBuildInfo
236:             */
237:            public void showBuildInfo(final PrintWriter out) {
238:                showVersion(out);
239:                out.println(getCopyright());
240:                out.println();
241:                getBuildInfo().showBuildInfo(out);
242:                out.flush();
243:            }
244:
245:            /**
246:             * Get the <tt>BuildInfo</tt> object that holds the build information
247:             * data.
248:             *
249:             * @return the <tt>BuildInfo</tt> object.
250:             *
251:             * @see #showBuildInfo()
252:             * @see #showBuildInfo(PrintStream)
253:             * @see #showBuildInfo(PrintWriter)
254:             */
255:            public static BuildInfo getBuildInfo() {
256:                synchronized (Version.class) {
257:                    if (buildInfo == null)
258:                        buildInfo = new BuildInfo(BUILD_INFO_BUNDLE_NAME);
259:                }
260:
261:                return buildInfo;
262:            }
263:
264:            /*----------------------------------------------------------------------*\
265:                                     Protected Methods
266:            \*----------------------------------------------------------------------*/
267:
268:            /**
269:             * Get the class name of the version resource bundle, which contains
270:             * values for the product version, copyright, etc.
271:             *
272:             * @return the name of the version resource bundle
273:             */
274:            protected String getVersionBundleName() {
275:                return VERSION_BUNDLE_NAME;
276:            }
277:
278:            /**
279:             * Get the class name of the build info resource bundle, which contains
280:             * data about when the product was built, generated (presumably)
281:             * during the build by
282:             * {@link BuildInfo#makeBuildInfoBundle BuildInfo.makeBuildInfoBundle()}.
283:             *
284:             * @return the name of the build info resource bundle
285:             */
286:            protected String getBuildInfoBundleName() {
287:                return BUILD_INFO_BUNDLE_NAME;
288:            }
289:
290:            /**
291:             * Get the key for the version string. This key is presumed to be
292:             * in the version resource bundle.
293:             *
294:             * @return the version string key
295:             */
296:            protected String getVersionKey() {
297:                return "curn.version";
298:            }
299:
300:            /**
301:             * Get the key for the copyright string. This key is presumed to be
302:             * in the version resource bundle.
303:             *
304:             * @return the copyright string key
305:             */
306:            protected String getCopyrightKey() {
307:                return "curn.copyright";
308:            }
309:
310:            /**
311:             * Get the key for the name of the utility or application.
312:             *
313:             * @return the key
314:             */
315:            protected String getApplicationNameKey() {
316:                return "curn.name";
317:            }
318:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.