Skip to content
Version.java 4.28 KiB
Newer Older
package dk.gov.oiosi.configuration;
 * Administrative class to keep track of the version number of the OIORASP release.
 * This class is created to be similar to Version classes in Apache project, e.g. org.apache.xalan.Version, but naming is adopted from
 * http://en.wikipedia.org/wiki/Software_versioning#Change_significance
 * In future it can be used by configuration procedures to check proper library related environment update.
 * Do not mix it with dk.gov.oiosi.common.Version, which is Version of server and contains another information.
 *
 * @since OIORASP 1.3.0
    private static int major;
    private static int minor;
    private static int maintenance;
    private static String revision;

     * Get the basic version string for the current OIORASP release. Version String formatted like
     * <CODE>"<B>OIORASP</B> <B>Java</B> a.b.c.d"</CODE>.
     * where a=major version number, b=minor version number, c=maintenance version number, d=revision number
     *
     * @return String denoting our current version
     */
    public static String getVersion() {
        return getProduct() + " " + getImplementationLanguage() + " " + getMajorVersionNum() + "." + getMinorVersionNum() + "." + getMaintenanceVersionNum() + "." + getRevisionNum();
    }

    /**
     * Get the basic version number for the current OIORASP release. Version String formatted like
     * <p/>
     * <CODE>"a.b.c"</CODE>.
     * <p/>
     * where a=major version number, b=minor version number, c=maintenance version number
     *
     * @return String denoting our current version
     */
    public static String getVersionNumber() {
        return getMajorVersionNum() + "." + getMinorVersionNum() + "." + getMaintenanceVersionNum();
    /**
     * Print the processor version to the command line.
     *
     * @param argv command line arguments, unused.
     */
    public static void main(String[] argv) {
        System.out.println(getVersion());
    }
    /**
     * @return Name of product: OIORASP.
     */
    public static String getProduct() {
        return "OIORASP";
    }
    /**
     * @return Implementation Language: Java.
     */
    public static String getImplementationLanguage() {
        return "Java";
    }
     * @return Major version number. This changes only when there is a significant, externally apparent enhancement from the previous
     *         release. 'n' represents the n'th version.
     *         Clients should carefully consider the implications of new versions as external interfaces and behaviour may have changed.
     */
    public static int getMajorVersionNum() {
        return major;
     * @return Minor number. This changes when: - a new set of functionality is to be added, eg, implementation of a new W3C specification.
     *         - API or behaviour change. - it's designated as a reference release.
    public static int getMinorVersionNum() {
        return minor;
     * @return Maintenance Drop Number. This identifier is used to designate maintenance drop applied to a specific release and contains
     *         fixes for defects reported. It maintains compatibility with the release and contains no API changes.
     */
    public static int getMaintenanceVersionNum() {
        return maintenance;
    }

    /**
     * @return Revision code. This identifier gets the SVN commit number from which this software is compiled.
     */
    public static String getRevisionNum() {
        return revision;
    }

    /**
     * Load and parse the version number held by ConfigurationHandler.
     * <p/>
     * Method is designed to be called from dk.gov.oiosi.configuration.ConfigurationHandler#loadXMLConfiguration() to have inversion of
     * control.
     */
    static void initNumbering() {
        if (major == 0 && ConfigurationHandler.getVersionNumber() != null) {
            String[] a = ConfigurationHandler.getVersionNumber().split("\\.");
            major = Integer.parseInt(a[0]);
            minor = Integer.parseInt(a[1]);
            maintenance = Integer.parseInt(a[2]);
            revision = a[3];
        }