Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

Version.java

00001 /*
00002  * Version.java
00003  *
00004  * Created on 21 October 2003, 12:24
00005  */
00006 
00007 package Sct;
00008 
00009 import java.util.regex.*;
00010 
00015 public final class Version extends java.util.Properties {
00016     
00017     public final static Version instance = new Version();
00018     
00019     public String getVersionName() {
00020         return version;
00021     }
00022     
00023     public double getVersion() {
00024         return versionNumber;
00025     }
00026     
00027     public int getMajorVersion() {
00028         return majorVersion;        
00029     }
00030     
00031     public int getMinorVersion() {
00032         return minorVersion;
00033     }
00034     
00035     //{
00042 
00043     public String getBuildSystem() {
00044         return getProperty("Sct.BuildSystem", "No information available");
00045     }
00047     public String getBuildHost() {
00048         return getProperty("Sct.BuildHost", "No information available");
00049     }
00051     public String getBuildDate() {
00052         return getProperty("Sct.BuildDate", "No information available");
00053     }
00055     public String getCmtConfig() {
00056         return getProperty("Sct.CmtConfig", "No information available");
00057     }
00059     public String getOnlineVersion() {
00060         return getProperty("Sct.OnlineVersion", "No information available");
00061     }
00063     public String getRootVersion() {
00064         return getProperty("Sct.RootVersion", "No information available");
00065     }
00067     public String getGccVersion() {
00068         return getProperty("Sct.GccVersion", "No information available");
00069     }
00071     public String getRodDaqVersion() {
00072         return getProperty("Sct.RodDaqVersion", "No information available");
00073     }
00075     public String getDataFlowVersion() {
00076         return getProperty("Sct.DataFlowVersion", "No information available");
00077     }
00078     
00080     public String getAllInformation() {
00081         String s = "System version: " + getVersion() + " named " + getVersionName();
00082         s += "\n\nBuild Information\nBuild System: " + getBuildSystem() + "\nBuild Host: " + getBuildHost();
00083         s += "\nBuild Date: " + getBuildDate() + "\nCmtConfig: " + getCmtConfig() + "\nRodDaq Version: ";
00084         s += getRodDaqVersion() + "\nDataFlow Version: " + getDataFlowVersion() + "\nOnline Version: ";
00085         s += getOnlineVersion() + "\nRoot Version: " + getRootVersion() + "\nGcc Version: " + getGccVersion();
00086         return s;
00087     }
00088     
00089     //}
00090     
00092     private Version() {
00093         java.io.InputStream is = getClass().getClassLoader().getResourceAsStream("Sct/version.properties");
00094         if (is != null) {
00095             try {
00096                 this.load(is);
00097             } catch (java.io.IOException e) {
00098                 //Ignore this error as well
00100             }
00101         }
00102 
00103         String tag = getProperty("Sct.TagName");
00104         if (tag != null && tag.length() > 7) {
00105             version = tag.substring(7, tag.length()-1);
00106         } else {
00107             version = "SctRodDaq_0_0_Exp";
00108         }
00109 
00110         try {
00111             System.out.println(version);
00112             Matcher m = Pattern.compile("\\p{Alpha}+_(\\d+_\\d+).*").matcher(version);
00113             if (m.matches()) {
00114                 String v = m.group(1);
00115                 v = v.replace('_', '.');
00116                 versionNumber = Double.parseDouble(v);
00117             }
00118         } catch (NumberFormatException e) {
00119             //Do nothing - stay with negative version numbers.
00120         }
00121         majorVersion = (int)Math.floor(versionNumber);
00122         minorVersion = (int)Math.floor((versionNumber - majorVersion)*101);
00123     }
00124     
00125     private String version;
00126     private double versionNumber = 0.0;
00127     private int majorVersion = -1;
00128     private int minorVersion = -1;
00129 }

Generated on Thu Jul 15 09:55:51 2004 for SCT DAQ/DCS Software - Java by doxygen 1.3.5