From: David ‘Bombe’ Roden Date: Wed, 24 Dec 2008 01:55:01 +0000 (+0100) Subject: Move current version to Main. X-Git-Tag: 0.7~15 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b9bf0fcac997c3cabf84348d18bccff041673da2;p=jSite.git Move current version to Main. --- diff --git a/src/de/todesbaum/jsite/main/Main.java b/src/de/todesbaum/jsite/main/Main.java index b04473d..8218abc 100644 --- a/src/de/todesbaum/jsite/main/Main.java +++ b/src/de/todesbaum/jsite/main/Main.java @@ -70,6 +70,9 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen /** Whether the debug mode is activated. */ private static boolean debug = false; + /** The version. */ + private static final Version VERSION = new Version(0, 6, 2); + /** The configuration. */ private Configuration configuration; @@ -210,7 +213,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen @SuppressWarnings("synthetic-access") public void actionPerformed(ActionEvent e) { - JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.about.message"), Version.getVersion()), null, JOptionPane.INFORMATION_MESSAGE, jSiteIcon); + JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.about.message"), getVersion().toString()), null, JOptionPane.INFORMATION_MESSAGE, jSiteIcon); } }; @@ -362,6 +365,15 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen return SUPPORTED_LOCALES[0]; } + /** + * Returns the version. + * + * @return The version + */ + public static final Version getVersion() { + return VERSION; + } + // // ACTIONS // diff --git a/src/de/todesbaum/jsite/main/Version.java b/src/de/todesbaum/jsite/main/Version.java index ec7df39..2b80c36 100644 --- a/src/de/todesbaum/jsite/main/Version.java +++ b/src/de/todesbaum/jsite/main/Version.java @@ -26,9 +26,6 @@ package de.todesbaum.jsite.main; */ public class Version implements Comparable { - /** The version. */ - private static final Version VERSION = new Version(0, 6, 2); - /** The components of the version information. */ private final int[] components; @@ -64,12 +61,25 @@ public class Version implements Comparable { } /** - * Returns the version. + * Parses a version from the given string. * - * @return The version + * @param versionString + * The version string to parse + * @return The parsed version, or null if the string could not + * be parsed */ - public static final String getVersion() { - return VERSION.toString(); + public static Version parse(String versionString) { + String[] componentStrings = versionString.split("\\."); + int[] components = new int[componentStrings.length]; + int index = -1; + for (String componentString : componentStrings) { + try { + components[++index] = Integer.parseInt(componentString); + } catch (NumberFormatException nfe1) { + return null; + } + } + return new Version(components); } /**