00001
00002
00003
00004
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 getTdaqVersion() {
00060 return getProperty("Sct.TdaqVersion", "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 }
00074
00076 public String getAllInformation() {
00077 String s = "System version: " + getVersion() + " named " + getVersionName();
00078 s += "\n\nBuild Information\nBuild System: " + getBuildSystem() + "\nBuild Host: " + getBuildHost();
00079 s += "\nBuild Date: " + getBuildDate() + "\nCmtConfig: " + getCmtConfig() + "\nRodDaq Version: ";
00080 s += getRodDaqVersion() + "\nTdaq Version: ";
00081 s += getTdaqVersion() + "\nRoot Version: " + getRootVersion() + "\nGcc Version: " + getGccVersion();
00082 return s;
00083 }
00084
00085
00086
00088 private Version() {
00089 java.io.InputStream is = getClass().getClassLoader().getResourceAsStream("Sct/version.properties");
00090 if (is != null) {
00091 try {
00092 this.load(is);
00093 } catch (java.io.IOException e) {
00094
00096 }
00097 }
00098
00099 String tag = getProperty("Sct.TagName");
00100 if (tag != null && tag.length() > 7) {
00101 version = tag.substring(7, tag.length()-1);
00102 } else {
00103 version = "SctRodDaq_0_0_Exp";
00104 }
00105
00106 try {
00107 System.out.println(version);
00108 Matcher m = Pattern.compile("\\p{Alpha}+_(\\d+_\\d+).*").matcher(version);
00109 if (m.matches()) {
00110 String v = m.group(1);
00111 v = v.replace('_', '.');
00112 versionNumber = Double.parseDouble(v);
00113 }
00114 } catch (NumberFormatException e) {
00115
00116 }
00117 majorVersion = (int)Math.floor(versionNumber);
00118 minorVersion = (int)Math.floor((versionNumber - majorVersion)*101);
00119 }
00120
00121 private String version;
00122 private double versionNumber = 0.0;
00123 private int majorVersion = -1;
00124 private int minorVersion = -1;
00125 }