001package org.cpsolver.ifs;
002
003import java.io.IOException;
004import java.io.InputStream;
005import java.util.Properties;
006
007/**
008 * IFS common constants. <br>
009 * <br>
010 * Build number and release date are to be set by apache ant.
011 * 
012 * @version IFS 1.3 (Iterative Forward Search)<br>
013 *          Copyright (C) 2006 - 2014 Tomáš Müller<br>
014 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
015 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
016 * <br>
017 *          This library is free software; you can redistribute it and/or modify
018 *          it under the terms of the GNU Lesser General Public License as
019 *          published by the Free Software Foundation; either version 3 of the
020 *          License, or (at your option) any later version. <br>
021 * <br>
022 *          This library is distributed in the hope that it will be useful, but
023 *          WITHOUT ANY WARRANTY; without even the implied warranty of
024 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
025 *          Lesser General Public License for more details. <br>
026 * <br>
027 *          You should have received a copy of the GNU Lesser General Public
028 *          License along with this library; if not see
029 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
030 */
031public class Constants {
032        private static Properties sProperties = null;
033        
034        private static Properties getProperties() {
035                if (sProperties == null) {
036                        sProperties = new Properties();
037                        InputStream in = Constants.class.getClassLoader().getResourceAsStream("cpsolver.version");
038                        if (in != null) {
039                                try {
040                                        sProperties.load(in);
041                                        in.close();
042                                } catch (IOException e) {}
043                        }
044                }
045                return sProperties;
046        }
047        
048    /**
049     * Version
050     * @return current solver version
051     */
052    public static String getVersion() {
053        return getProperties().getProperty("project.version", "1.3");
054    }
055
056    /**
057     * Build number
058     * @return current solver build number
059     */
060    public static String getBuildNumber() {
061        return getProperties().getProperty("cpsolver.build_nbr", "?");
062    }
063
064    /**
065     * Release date
066     * @return current solver release date
067     */
068    public static String getReleaseDate() {
069        return getProperties().getProperty("cpsolver.rel_date", "?");
070    }
071}