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.common.util;
017:
018: import java.io.*;
019:
020: /* DO NOT EDIT! This file is generated automatically */
021:
022: /**
023: * This class solely defines the version numbers of PEGASUS. The template
024: * file will be substituted by ant during the built process to compile
025: * in the built timestamp.<p>
026: *
027: * When using the class, the methods for the version number digits
028: * will always return an integer. In order to obtain the full version
029: * number, including any "release candidate" suffices, please prefer
030: * the <code>toString</code> method over combining the separate version
031: * integers yourself.
032: *
033: * @author Karan Vahi
034: * @author Jens-S. Vöckler
035: * @version $Revision: 472 $
036: * $Id: Version.in 472 2008-02-21 19:47:05Z gmehta $
037: */
038: public class Version {
039: /**
040: * This constant defines the major version number.
041: */
042: public static final int MAJOR = 2;
043:
044: /**
045: * This constant defines the minor version number.
046: */
047: public static final int MINOR = 1;
048:
049: /**
050: * This constant defines the patch level version.
051: */
052: public static final int PLEVEL = 0;
053:
054: /**
055: * Instance variable keeping track of the Singleton.
056: */
057: protected static Version c_instance = null;
058:
059: /**
060: * C'tor: construct an element, which is empty anyway.
061: */
062: private Version() {
063: // empty
064: }
065:
066: /**
067: * Accessor to the singleton.
068: */
069: public static Version instance() {
070: if (Version.c_instance == null)
071: Version.c_instance = new Version();
072: return Version.c_instance;
073: }
074:
075: /**
076: * Returns a string containing the concatenated version.
077: * Note: This class may also return suffixes beyond the version.
078: *
079: * @return a concatenated string.
080: */
081: public String toString() {
082: return (Integer.toString(MAJOR) + '.' + Integer.toString(MINOR)
083: + '.' + Integer.toString(PLEVEL) + ""); // !! HERE !!
084: }
085:
086: /**
087: * Basename of the build stamp file.
088: */
089: public static final String STAMP_FILENAME = "stamp";
090:
091: /**
092: * Determines the built as a time stamp.
093: * @return the formatted time stamp of the built.
094: */
095: public String determineBuilt() {
096: return "20080222215700Z";
097: }
098:
099: /**
100: * Determines the build platform.
101: * @return an identifier for the build platform.
102: */
103: public String determinePlatform() {
104: return "darwin9-i386";
105: }
106:
107: /**
108: * Determines the built and architecture of the installation. These
109: * are usually separated by a linear white-space.
110: *
111: * @return the formatted time stamp of the built, if available, and an
112: * identifier for the architecture. An string indicating that the
113: * build is unknown is returned on failure.
114: */
115: public String determineInstalled() {
116: String result = "unknown unknown";
117: String pegasushome = System.getProperty("pegasus.home");
118: if (pegasushome != null) {
119: try {
120: File stampfile = new File(pegasushome, STAMP_FILENAME);
121: if (stampfile.canRead()) {
122: BufferedReader br = new BufferedReader(
123: new FileReader(stampfile));
124: String built = br.readLine();
125: br.close();
126: if (built != null && built.length() > 0)
127: result = built;
128: }
129: } catch (IOException ioe) {
130: // ignore
131: }
132: }
133:
134: return result;
135: }
136:
137: /**
138: * Determines, if the compiled version and the installed version
139: * match. The match is done by comparing the timestamps and
140: * architectures.
141: *
142: * @return true, if versions match, false otherwise.
143: */
144: public boolean matches() {
145: String s[] = determineInstalled().split("\\s+");
146: return (s.length >= 2
147: && s[0].equalsIgnoreCase(determineBuilt()) && s[1]
148: .equalsIgnoreCase(determinePlatform()));
149: }
150: }
|