Changeset 365 in tmcsimulator for trunk/src/tmcsim/common/RevisionNumber.java


Ignore:
Timestamp:
04/11/2019 07:01:03 PM (7 years ago)
Author:
jdalbey
Message:

RevisionNumber?.java, SimulationManagerView?.java : Fix defect #119

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/common/RevisionNumber.java

    r6 r365  
    22 
    33import java.io.File; 
     4import java.io.IOException; 
     5import java.util.Properties; 
    46import java.util.Scanner; 
    57import java.util.logging.Level; 
     
    1517 * @author jdalbey 
    1618 */ 
    17 public class RevisionNumber 
     19public final class RevisionNumber 
    1820{ 
    1921 
    2022    private static Logger logger = Logger.getLogger("tmcsim.common"); 
    2123    // Read the subversion revision info and return it 
    22  
     24    /** 
     25     * Read the version number from the application properties. The file 
     26     * 'application.properties' is generated by build.xml. 
     27     * 
     28     * @return a version string obtained from application.properties file, or 
     29     * "Version: unknown" if an IOerror prevents us from reading the file. 
     30     */ 
     31    public static String getAppVersion() 
     32    { 
     33        String propfilename = "/tmcsim/application.properties"; 
     34        String propKey = "Application.revision"; 
     35        String version = "unknown"; 
     36        try 
     37        { 
     38            Properties props = new Properties(); 
     39            props.load(RevisionNumber.class.getResourceAsStream(propfilename)); 
     40            version = (String) props.get(propKey); 
     41        } catch (IOException ex) 
     42        { 
     43            Logger.getLogger("tmcsim/common").log(Level.SEVERE, 
     44                    "getAppVersion(): IOError reading " + propfilename); 
     45        } catch (NullPointerException npe) 
     46        { 
     47            Logger.getLogger("tmcsim/common").log(Level.SEVERE, 
     48                    "getAppVersion().load:  Missing file: " + propfilename); 
     49        } 
     50        return "revision: " + version; 
     51    } 
     52     
    2353    /** 
    2454     * Return the version number as a string. The revision number is generated 
Note: See TracChangeset for help on using the changeset viewer.