All Downloads are FREE. Search and download functionalities are using the official Maven repository.

JSci.Version Maven / Gradle / Ivy

Go to download

JSci is a set of open source Java packages. The aim is to encapsulate scientific methods/principles in the most natural way possible. As such they should greatly aid the development of scientific based software. It offers: abstract math interfaces, linear algebra (support for various matrix and vector types), statistics (including probability distributions), wavelets, newtonian mechanics, chart/graph components (AWT and Swing), MathML DOM implementation, ... Note: some packages, like javax.comm, for the astro and instruments package aren't listed as dependencies (not available).

The newest version!
package JSci;

import java.io.*;
import java.net.*;
import java.util.ResourceBundle;

/**
* The Version class contains information about the current and latest release.
* @version 1.3
* @author Mark Hale
*/
public final class Version extends Object implements Serializable {
        /**
        * Major version number.
        */
        public final int major;
        /**
        * Minor version number.
        */
        public final int minor;
        /**
        * Java platform required.
        */
        public final String platform;
        /**
        * The URL for the home of this version.
        */
        public final String home;
        /**
        * Gets the current version.
        */
        public static Version getCurrent() {
                ResourceBundle bundle = ResourceBundle.getBundle("JSci.Bundle");
                int major = Integer.parseInt(bundle.getString("version.major"));
                int minor = Integer.parseInt(bundle.getString("version.minor"));
                String platform = bundle.getString("version.platform");
                String home = bundle.getString("version.home");
                return new Version(major, minor, home, platform);
        }
        /**
        * Retrieves the latest version from the home URL.
        */
        public static Version getLatest() throws IOException {
                Version latest = null;
                try {
                        URL serurl = new URL(getCurrent().home+"version.ser");
                        ObjectInputStream in = new ObjectInputStream(serurl.openStream());
                        latest = (Version) in.readObject();
                        in.close();
                } catch(MalformedURLException murle) {
                } catch(ClassNotFoundException cnfe) {}
                return latest;
        }
        /**
        * Constructs a version object.
        */
        private Version(int major, int minor, String home, String platform) {
                this.major = major;
                this.minor = minor;
                this.home = home;
                this.platform = platform;
        }
        /**
        * Compares two versions for equality.
        */
        public boolean equals(Object o) {
                if(!(o instanceof Version))
                        return false;
                Version ver = (Version) o;
                return (major == ver.major) && (minor == ver.minor) && platform.equals(ver.platform);
        }
	public int hashCode() {
		return 37*(37*(37*17+major)+minor)+platform.hashCode();
	}
        /**
        * Returns the version number as a string.
        */
        public String toString() {
                return new StringBuffer().append(major).append('.').append(minor).toString();
        }
        /**
        * Returns true if this is later than another version.
        */
        public boolean isLater(Version ver) {
                return (major>ver.major) ||
                        (major == ver.major && minor>ver.minor);
        }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy