/*
 * Copyright (c) 2013 CERT-SE. All rights reserved.
 */

package se.sitic.megatron.util;


/**
 * Returns application version and other build variables.
 * <p> 
 * This class is created from "Version.template" by an Ant script. 
 */
public class Version {
    private final static String APP_NAME = "Megatron";
    private final static String APP_VERSION = "1.1.0";
    private final static String APP_TAG = "v1.1.0";
    private final static String BUILD_DATE = "2014-11-17 10:27:17";
    private final static String ANT_VERSION = "Apache Ant(TM) version 1.8.2 compiled on December 3 2011";
    private final static String ANT_JAVA_VERSION = "1.7";


    public static String getJavaVersion() {
        return System.getProperty("java.version", "[n/a]");
    }


    public static String getJavaClassPath() {
        return System.getProperty("java.class.path", "[n/a]");
    }


    public static String getAppName() {
        return APP_NAME;
    }


    public static String getAppVersion() {
        return APP_VERSION;
    }


    public static String getAppTag() {
        return APP_TAG;
    }
    
    
    public static String getBuildDate() {
        return BUILD_DATE;
    } 
    
    
    public static String getAntVersion() {
        return ANT_VERSION;
    } 


    public static String getAntJavaVersion() {
        return ANT_JAVA_VERSION;
    } 
    
    
    /**
     * Returns application name + version. 
     */
    public static String getVersion(boolean includeBuildDate) {
        StringBuilder result = new StringBuilder(120);
        
        result.append(APP_NAME).append(" ").append(APP_VERSION);
        if (includeBuildDate) {
            result.append(" (").append(BUILD_DATE).append(")");
        }
        
        return result.toString();
    }
    
    
    /**
     * Returns all attributes in this class formatted, e.g. version, 
     * build date etc.
     */
    public static String getVersionInfo() {
        StringBuilder result = new StringBuilder(1024); 
        
        final String newLine = System.getProperty("line.separator", "\r\n");
        result.append(getVersion(true)).append(newLine);
        result.append("  Tag: ").append(APP_TAG).append(newLine);
        result.append("  Java Version: ").append(getJavaVersion()).append(newLine);
        result.append("  Classpath: ").append(getJavaClassPath()).append(newLine);
        result.append("  Ant Version: ").append(ANT_VERSION).append(newLine);
        result.append("  Ant Java Version: ").append(ANT_JAVA_VERSION).append(newLine);
        
        return result.toString();
    }
    
}

@@ -16,17 +16,17 @@
  (c) 201
-3
+7
  CERT-SE
@@ -354,25 +354,25 @@
 SION = %221.1.
-0
+1
 %22;%0A    priva
@@ -410,17 +410,17 @@
 = %22v1.1.
-0
+1
 %22;%0A    p
@@ -467,24 +467,24 @@
 %22201
-4-11-17 10:27:17
+7-03-29 12:32:59
 %22;%0A 
@@ -558,11 +558,11 @@
 n 1.
-8.2
+9.4
  com
@@ -574,23 +574,23 @@
  on 
-December 3
+January 27
  201
-1
+5
 %22;%0A 
@@ -642,17 +642,17 @@
 ON = %221.
-7
+8
 %22;%0A%0A%0A   

Version 1.1.1, for info see release-note.txt